Query Details
arg("").securityresources
| where type == "microsoft.security/attackpaths"
| extend AttackPathDisplayName = tostring(properties["displayName"])
| mvexpand (properties.graphComponent.entities)
| extend Entity = parse_json(properties_graphComponent_entities)
| extend ResourceId = tostring(tolower(Entity.entityIdentifiers.azureResourceId))
| project AttackPathDisplayName, AttackPathDescription = parse_json(properties.description), AttackPathStory = parse_json(properties.attackStory), ResourceId
// Existing Security Alert?
| join kind=inner ( SecurityAlert
| where TimeGenerated >ago(90d)
| where ProviderName == "Azure Security Center"
| mv-expand parse_json(Entities)
| where Entities.Type == "azure-resource"
| extend ResourceId = tolower(Entities.ResourceId)
| project AlertName, AlertSeverity, AlertDescription = Description, ResourceId) on ResourceId
// System-assigned Managed Identity to the Resource?
| lookup (
arg("").resources | where identity has 'SystemAssigned' or identity has 'UserAssigned' | project ResourceId = tolower(id), AssociatedWorkloadIdentity = identity
) on ResourceId
| extend PrincipalId = tostring(AssociatedWorkloadIdentity.principalId)
// Permissions assigned to System-assigned Managed Identity of the Resource?
| join hint.remote=left (arg("").authorizationresources
| where type =~ 'microsoft.authorization/roleassignments'
| extend RoleDefinitionId = properties.roleDefinitionId
| extend PrincipalType = properties.principalType
| extend PrincipalId = tostring(properties.principalId)
| extend RoleAssignmentScope = properties.scope
| project PrincipalId, RoleDefinitionId, RoleAssignmentScope
) on PrincipalId
| project-away ResourceId1, PrincipalId1This query retrieves information about attack paths and security alerts in Azure Security Center. It joins the data from different sources to find existing security alerts, system-assigned managed identities, and permissions assigned to those identities. The final result includes the attack path display name, description, story, alert name, severity, description, resource ID, principal ID, role definition ID, and role assignment scope.

Thomas Naunheim
Released: January 7, 2024
Tables
Keywords
Operators