Azure VM Extension Deployment by User
Description
Identifies the successful deployment of a high-risk Azure Virtual Machine extension by an interactive user principal. Attackers with privileged Azure RBAC roles can abuse VM extensions such as VMAccess, CustomScriptExtension, and RunCommand to execute arbitrary code, create backdoor accounts, harvest credentials, and establish persistence on Azure-hosted virtual machines without requiring direct network access to the VM.
Query · kuery
data_stream.dataset:azure.activitylogs and
azure.activitylogs.operation_name:"MICROSOFT.COMPUTE/VIRTUALMACHINES/EXTENSIONS/WRITE" and
azure.activitylogs.identity.authorization.evidence.principal_type:User and
event.outcome:(success or Success) and
azure.resource.id:(
*VMACCESSAGENT* or
*CUSTOMSCRIPTEXTENSION* or
*RUNCOMMANDWINDOWS* or
*RUNCOMMANDLINUX* or
*/DSC/* or
*MICROSOFTMONITORINGAGENT*
)
Investigation fields
Pivot points the source recommends for triage.
@timestampevent.outcomeazure.activitylogs.operation_nameazure.activitylogs.identity.authorization.evidence.principal_idazure.activitylogs.identity.authorization.evidence.principal_typeazure.activitylogs.identity.claims_initiated_by_user.nameazure.resource.idazure.resource.namesource.ipsource.geo.country_namesource.as.organization.nameazure.subscription_idazure.activitylogs.tenant_id
Known false positives
- Legitimate administrators and automation may deploy Custom Script, Run Command, DSC, or monitoring extensions during provisioning, patching, or guest configuration. Baseline expected principals, VMs, and extension types before tuning exclusions.
Analyst notes
Investigating Azure VM Extension Deployment by User
This rule flags successful MICROSOFT.COMPUTE/VIRTUALMACHINES/EXTENSIONS/WRITE operations performed by a user principal
where the extension resource ID matches high-risk extension families (VMAccess, Custom Script, Run Command, DSC,
Microsoft Monitoring Agent).
Triage checklist
- Is the caller UPN a known admin or automation account?
- Is the source IP or ASN consistent with corporate infrastructure or a known VPN?
- Was this extension deployment preceded by a Run Command invocation on the same VM?
- Did the extension deployment coincide with new local account creation on the endpoint?
- Check
azure.activitylogs.identity.claims.authnmethodsreferences— was MFA present? - Correlate with endpoint telemetry: process events parented by
WaAppAgent.exeorwalinuxagentwithin 120 seconds of the extension write timestamp on the same host.
Possible investigation steps
- Review
azure.activitylogs.identity.authorization.evidence.principal_idand Entra sign-in logs for the caller. - Examine
azure.resource.idandazure.resource.nameto identify the VM and extension type deployed. - Pivot on the VM for
MICROSOFT.COMPUTE/VIRTUALMACHINES/RUNCOMMAND/ACTIONand endpoint Run Command orwaagentactivity. - Review role assignments for the principal on the subscription or resource group.
Response and remediation
- If unauthorized, remove the extension, rotate credentials, and review RBAC on the affected VM and scope.
- Isolate the VM and collect endpoint and activity log artifacts per incident procedures.