Microsoft Defender for Cloud Executor¶
Category: Cloud Security
Script: ms_defender_for_cloud.py
Integration: REST API (OAuth2)
Faraday Plugin: Raw JSON
Website: https://azure.microsoft.com/en-us/products/defender-for-cloud
Description¶
Imports security alerts and security assessments (recommendations) from Microsoft Defender for Cloud into Faraday. The executor queries the Azure Resource Manager API for one subscription and creates one Faraday host per affected Azure resource, with the alerts and assessments as vulnerabilities.
Prerequisites¶
- An Azure subscription with Microsoft Defender for Cloud enabled
- An Azure AD app registration (service principal) with a client secret
- The service principal needs the
Security Readerrole (or higher) on the subscription - Network access to
login.microsoftonline.comandmanagement.azure.com
Configuration¶
Environment Variables (Setup)¶
| Variable | Required | Description |
|---|---|---|
AZURE_TENANT_ID |
Yes | Azure AD tenant (directory) ID of the service principal |
AZURE_CLIENT_ID |
Yes | Application (client) ID of the service principal |
AZURE_CLIENT_SECRET |
Yes | Client secret of the service principal |
These variables are also accepted as execution arguments, so a single run can override them.
Execution Arguments¶
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
AZURE_SUBSCRIPTION_ID |
string | Yes | ID (GUID) of the Azure subscription to import from |
DEFENDER_RESOURCE_GROUP |
string | No | Name of a resource group to limit the import to (default: the whole subscription) |
DEFENDER_MIN_SEVERITY |
string | No | Minimum severity to import: info, low, medium, high or critical (default: info) |
YAML Configuration Example¶
executors:
ms_defender_for_cloud:
repo_executor: ms_defender_for_cloud.py
max_size: 65536
varenvs:
AZURE_TENANT_ID: "<azure_tenant_id>"
AZURE_CLIENT_ID: "<azure_client_id>"
AZURE_CLIENT_SECRET: "<azure_client_secret>"
params:
AZURE_SUBSCRIPTION_ID:
mandatory: true
type: string
base: string
DEFENDER_RESOURCE_GROUP:
mandatory: false
type: string
base: string
DEFENDER_MIN_SEVERITY:
mandatory: false
type: string
base: string
How It Works¶
- Requests an access token from
login.microsoftonline.com/{AZURE_TENANT_ID}/oauth2/v2.0/tokenusing the client credentials flow, with thehttps://management.azure.com/.defaultscope - Reads all pages of
Microsoft.Security/alertsandMicrosoft.Security/assessmentsfrommanagement.azure.comfor the subscription (or the resource group, if set) - Groups the findings by the Azure resource they affect, one host per resource
- Maps each alert or assessment to a Faraday vulnerability:
- Severity: Defender's severity mapped to Faraday's scale, or the CVSS score when available
- Status:
Active/InProgress/Unhealthybecome open,Resolved/Healthy/NotApplicablebecome closed,Dismissedbecomes risk-accepted - References: CVEs found in the finding and related links
- Drops vulnerabilities below
DEFENDER_MIN_SEVERITY
Notes¶
- Each host has IP
0.0.0.0, because Defender findings belong to Azure resources rather than IP addresses. Its hostname is the resource label plus the Azure resource ID, and its description lists the resource type, name, resource group and subscription. - Resources left without vulnerabilities after filtering are not created.
- If the service principal lacks permissions (403) or the subscription is not found (404), the affected query is skipped and logged, and the run may import nothing.
- The shared agent parameters (
AGENT_CONFIG_*tags and severity filters) are not applied by this executor. UseDEFENDER_MIN_SEVERITYto filter by severity.