How the attack works
VM Applications are a feature of Azure Compute Gallery for distributing software to virtual machines and scale sets. Microsoft documents two resources: the application (Microsoft.Compute/galleries/applications) and its versions (Microsoft.Compute/galleries/applications/versions). A version points to a package in a storage account and defines the install, update and remove commands. A version is deployed by referencing it in the applicationProfile of a virtual machine or scale set, after which Azure downloads the package to the machine and executes the install command, with cmd.exe or /bin/bash as the default interpreter. The work on the machine is done by the VM Application extension.
The install command is whatever the publisher writes, so publishing a version is a way to run commands on machines. Microsoft's Azure Threat Research Matrix lists it as an execution technique (AZT301.4) and states that an attacker can pass commands to the virtual machine as SYSTEM this way. There are two shapes. An attacker with rights on a gallery and on a virtual machine publishes an application of their own and assigns it to the machine. Or an attacker with rights on the gallery alone publishes a new version of an application that machines already reference, and waits for it to be taken: a profile can ask for the latest version. Writes to applications and versions are recorded in the Azure Activity log with their caller. The assignment to a machine is an ordinary update of the virtual machine, which the log does not distinguish from any other update, and the log holds neither the package nor the commands.
What an attacker needs
- Rights to write to a Compute Gallery: Owner, Contributor or a custom role with
Microsoft.Compute/galleries/applications/writeandMicrosoft.Compute/galleries/applications/versions/write. A new gallery needsMicrosoft.Compute/galleries/write. - A package location in a storage account that the gallery can read at publishing time.
- To run it on a chosen machine:
Microsoft.Compute/virtualMachines/writeon that machine. To reach machines that already use an application: write access to that application in the gallery is enough.
Impact
Commands run on the virtual machine with system rights, which gives the attacker the data on the machine, the tokens of the managed identities assigned to it and a position inside its network. A version published into an application that many machines or a scale set reference spreads to all of them. The application stays assigned until it is removed from the profile of the machine.
Detection rules
Compute Gallery VM Application or Version Created or Updated
Detects a successful create or update of a VM application in an Azure Compute Gallery or of a version of one (Microsoft.Compute/galleries/applications/write and Microsoft.Compute/galleries/applications/versions/write). A version defines the install, update and remove commands that Azure executes on every virtual machine and scale set the application is assigned to, so publishing one is a way to run commands on machines. The Activity log event names the application and the caller but holds neither the commands nor the package, and the assignment to a machine is an ordinary update of the virtual machine that this rule does not see.
title: Compute Gallery VM Application or Version Created or Updated
id: ea328ccd-16f3-49d6-aff4-c9e0e54e4307
status: experimental
description: >-
Detects a successful create or update of a VM application in an Azure
Compute Gallery or of a version of one
(Microsoft.Compute/galleries/applications/write and
Microsoft.Compute/galleries/applications/versions/write). A version defines
the install, update and remove commands that Azure executes on every
virtual machine and scale set the application is assigned to, so publishing
one is a way to run commands on machines. The Activity log event names the
application and the caller but holds neither the commands nor the package,
and the assignment to a machine is an ordinary update of the virtual
machine that this rule does not see.
references:
- https://attack.mitre.org/techniques/T1651/
- https://learn.microsoft.com/en-us/azure/virtual-machines/vm-applications
- https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/compute
- https://microsoft.github.io/Azure-Threat-Research-Matrix/Execution/AZT301/AZT301-4/
author: Forestall
date: 2026-11-18
tags:
- attack.execution
- attack.t1651
logsource:
product: azure
service: activitylogs
detection:
selection:
OperationNameValue:
- MICROSOFT.COMPUTE/GALLERIES/APPLICATIONS/WRITE
- MICROSOFT.COMPUTE/GALLERIES/APPLICATIONS/VERSIONS/WRITE
ActivityStatusValue:
- Success
- Succeeded
condition: selection
falsepositives:
- Release pipelines and platform teams that publish software to virtual machines through VM applications. Exclude their identities in a filter_ selection by Caller once confirmed, and review publications by anyone else.
level: medium
False positives
- Release pipelines and platform teams that publish software to virtual machines through VM applications. Exclude their identities in a filter_ selection by Caller once confirmed, and review publications by anyone else.
Detection logic
Patterns that need more than one event, a baseline or knowledge of your own environment. Each is a hypothesis to build and tune in your SIEM, not a ready rule.
Application version published and a virtual machine updated by the same caller shortly after
Publishing a version does nothing until a machine references it. A caller that publishes an application or a version and updates a virtual machine or a scale set a few minutes later is likely assigning what it just published, which is the whole technique in two events.
- In the Azure Activity log, an application or a version is written with status Success:
MICROSOFT.COMPUTE/GALLERIES/APPLICATIONS/WRITEorMICROSOFT.COMPUTE/GALLERIES/APPLICATIONS/VERSIONS/WRITE. Keep theCallerand the resource ID. - Within 60 minutes the same
Callerupdates a virtual machine or a scale set:MICROSOFT.COMPUTE/VIRTUALMACHINES/WRITEorMICROSOFT.COMPUTE/VIRTUALMACHINESCALESETS/WRITEwith status Success. - Read the
applicationProfileof that machine or scale set and check whether it references the application of the first step, because the write event does not say which property changed.
EventsMICROSOFT.COMPUTE/GALLERIES/APPLICATIONS/WRITEMICROSOFT.COMPUTE/GALLERIES/APPLICATIONS/VERSIONS/WRITEMICROSOFT.COMPUTE/VIRTUALMACHINES/WRITEMICROSOFT.COMPUTE/VIRTUALMACHINESCALESETS/WRITE
LimitsA release pipeline that publishes a version and rolls it out does exactly this, so its identity has to be excluded by name. Updates of virtual machines are frequent, which makes the second step noisy for busy callers. The 60 minutes are a starting point. A version taken later by machines that ask for the latest one does not match.
Triage
- Identify the Caller, the caller's IP address, the gallery, the application and the version from the resource ID, and whether this identity normally publishes applications.
- Read the version from the gallery and note its install, update and remove commands and the package it was built from.
- Find the virtual machines and scale sets whose
applicationProfilereferences the application, and which of them ask forlatest. - Look for updates of virtual machines by the same caller after the publication, and check the status of the VM Application extension on those machines.
- On machines that installed the version, review what ran and what the managed identities of the machine did afterwards.
Response
Once the attack is confirmed:
- Remove the application from the
applicationProfileof the affected machines and scale sets, and delete the version or the application from the gallery. - Contain the caller. Revoke its sessions, rotate its credentials and remove its rights on the gallery and on the machines until the publication is explained.
- Isolate and investigate the machines that installed the version, and rebuild them from a trusted image if the install command cannot be accounted for.
- Review and undo the activity of the managed identities assigned to those machines from the time of the install, and rotate the secrets stored on them.
- Pin the remaining profiles to version numbers that were reviewed.
Mitigation
- Limit write access to Compute Galleries that hold VM applications, and keep those galleries in a resource group that ordinary contributors cannot write to.
- Publish application versions only from a pipeline with review, and reference fixed version numbers in the
applicationProfileof production machines instead oflatest. - Restrict Owner, Contributor and Virtual Machine Contributor on virtual machines, as for Run Command and extensions.
- Give the managed identities of virtual machines only the roles they need.
- Send the Azure Activity log of every subscription to your SIEM, including the subscriptions that hold shared galleries.
Frequently asked questions
Does the Activity log show the install command of the application?
No. The event names the operation, the caller and the application version in its resource ID. The install, update and remove commands are properties of the version, and the package is a file that the gallery copied from a storage account. Read the version from the gallery while it exists, and keep a copy before you delete it.
How is this different from Run Command and VM extensions?
The result is the same, code that runs on the machine with system rights, but the events differ. Run Command and extensions are operations on the virtual machine. A VM application is published in a gallery, which can be in another resource group or subscription, and reaches the machine through its application profile. Rules that only watch run commands and extension writes do not see the publication.
Can a gallery writer reach machines without rights on them?
Where machines already reference an application, yes in principle. A version defines the commands, and a profile can ask for the latest version of an application, so a newer version published into that application is what such a profile resolves to. Referencing fixed version numbers removes that path.
Is there a public incident report for this technique?
No public incident report describes this at the audit event level as far as this page's sources go. Microsoft's Azure Threat Research Matrix lists Compute Gallery applications as an execution technique and names the two write operations that the rule on this page reads.