Lesson 3 of 3 Securing Databases

Configuring Defender for Databases

This lesson explains which plan protects which database service, and what the plans detect.

Learning outcomes

After completing this lesson, you will be able to:

  • Match a database service to its plan.
  • Describe SQL vulnerability assessment and baselines.
  • Identify typical threat alerts.
  • Explain the prerequisites for SQL Server on machines.

The plans

Defender for Databases is a family of plans in Defender for Cloud, and the first task is to match a service to the right plan. The following table shows the mapping.

PlanCovers
Defender for Azure SQL DatabasesAzure SQL Database, elastic pools, Azure SQL Managed Instance and Azure Synapse dedicated SQL pools
Defender for SQL Servers on MachinesSQL Server on Azure VMs, and SQL Server enabled by Azure Arc
Defender for open-source relational databasesAzure Database for PostgreSQL and for MySQL flexible servers, and Amazon RDS engines
Defender for Azure Cosmos DBAzure Cosmos DB for NoSQL

Exam scenarios often test the hosting model. SQL Server running inside an Azure VM is not Azure SQL Database, so it needs the machines plan. An on-premises SQL Server needs Azure Arc first. Azure Cosmos DB for MongoDB is not supported, as the Cosmos DB plan covers only the NoSQL API, so a scenario using another API cannot be solved by this plan.

Match the pairs

Which database plan?

Exam skills 2.2.3

Match each database service with the Defender plan that covers it.

Log in to try this activity Interactive activities are free with an account.

Vulnerability assessment

The SQL plans include SQL vulnerability assessment, which scans for configuration weaknesses, excessive permissions and unprotected sensitive data. It runs a set of rules, and it compares results with a baseline that a team accepts. Anything that deviates from the baseline appears as a finding, so a team can agree what is acceptable and then watch for change. Findings appear as Defender for Cloud recommendations, such as a recommendation that SQL databases should have vulnerability findings resolved.

True or false

Vulnerability assessment and threats

Exam skills 2.2.3

Check how SQL vulnerability assessment and threat detection work.

Log in to try this activity Interactive activities are free with an account.

Threat detection

Advanced Threat Protection watches for anomalous activity. For Azure SQL, typical alerts include potential SQL injection, access from an unusual location or an unfamiliar principal, a brute-force attack on credentials, and a suspicious pattern of data export. For open-source relational databases, the plan alerts on anomalous access patterns and brute-force attempts.

Defender for Azure Cosmos DB detects potential SQL injection against the NoSQL API, access from suspicious sources, and unusual data extraction. It works on the service's logs, and does not read account data, so it adds no latency and needs no change to the application.

Enabling the plans

Enable each plan on the Defender plans page for the subscription, under the Databases section, by selecting the resource types that are wanted. Enabling at subscription level covers new resources, and Azure Policy can enforce it. Azure SQL can also be enabled at server level from the server's Microsoft Defender for Cloud page.

Defender for SQL Servers on Machines needs a monitoring mechanism on the machine: the plan uses an agent or extension to collect data. Azure SQL does not need one, as the service is managed. An on-premises SQL Server must be connected through Azure Arc, and the SQL extension provides visibility.

Responding to an alert

An alert gives details such as the source address, the principal and, for SQL injection, the vulnerable statement. The sequence for a SQL injection alert might be as follows.

  1. Validate

    Check the statement and the application in the alert. Some alerts come from penetration tests.

  2. Contain

    Block the source, and restrict the application's database rights.

  3. Fix

    Change the code to use parameterized queries.

  4. Hunt

    Use audit logs to find what the attacker read.

  5. Learn

    Add a rule or test so that the flaw cannot return.

Put in order

Responding to SQL injection

Exam skills 2.2.3

Put the response to a SQL injection alert in order.

Log in to try this activity Interactive activities are free with an account.
Worked example

Matching plans to services

A company runs Azure SQL Managed Instance, SQL Server 2022 on Azure VMs, an on-premises SQL Server 2019 instance, Azure Database for PostgreSQL flexible server, and Azure Cosmos DB for MongoDB. It wants threat detection everywhere that Defender for Cloud allows. Which plans and prerequisites apply?

Managed Instance needs Defender for Azure SQL Databases. SQL Server on Azure VMs needs Defender for SQL Servers on Machines, and the same plan covers the on-premises server once it is connected through Azure Arc. PostgreSQL flexible server needs Defender for open-source relational databases.

Azure Cosmos DB for MongoDB cannot be protected, since the plan supports only the NoSQL API, and this limit should be reported rather than hidden. Defender for Servers does not replace the SQL plan, because it does not analyse database activity.

Check yourself

Which plan protects SQL Server running on an Azure VM?

Show answer

Defender for SQL Servers on Machines, since the database is not the Azure SQL Database service.

Exam Tips

Remember for the exam

  • Match the plan to the hosting model, not just to the engine.
  • On-premises SQL Server needs Azure Arc first.
  • Defender for Azure Cosmos DB supports only the NoSQL API.
  • Vulnerability assessment compares results with an approved baseline.