1. Resources
  2. Detection rules
  3. Code Execution Through a Compute Gallery VM Application

Code Execution Through a Compute Gallery VM Application detection rules

Someone publishes a VM application or a new version of one in an Azure Compute Gallery. Its install command runs on every virtual machine the application is assigned to, a third way to run code next to Run Command and extensions.

Platform
Azure
Severity
High
Log source
Azure Activity log
Last updated
MITRE ATT&CK technique
T1651Cloud Administration Command
Tactic
Execution
Rule formats
Sigmaand queries for: SplunkMicrosoft SentinelIBM QRadar
What an attacker needs
Write access to a Compute Gallery to publish an application version, and either write access to a virtual machine or machines that already reference the application.
Impact
Commands run with system rights on every machine the application is assigned to, with access to the managed identities of those machines.
Response
Remove the application from the affected machine profiles, delete the version from the gallery, contain the caller and investigate the machines.
Mitigation
Limit write access to galleries that hold VM applications and reference fixed version numbers instead of latest in machine profiles.
Operations
MICROSOFT.COMPUTE/GALLERIES/APPLICATIONS/WRITEMICROSOFT.COMPUTE/GALLERIES/APPLICATIONS/VERSIONS/WRITE
Threat groups
APT29VOID MANTICORE

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/write and Microsoft.Compute/galleries/applications/versions/write. A new gallery needs Microsoft.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/write on 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.

LevelMediumStatusExperimentalLog sourceAzure Activity log
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

Detection hypothesisSequence of events

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.

  1. In the Azure Activity log, an application or a version is written with status Success: MICROSOFT.COMPUTE/GALLERIES/APPLICATIONS/WRITE or MICROSOFT.COMPUTE/GALLERIES/APPLICATIONS/VERSIONS/WRITE. Keep the Caller and the resource ID.
  2. Within 60 minutes the same Caller updates a virtual machine or a scale set: MICROSOFT.COMPUTE/VIRTUALMACHINES/WRITE or MICROSOFT.COMPUTE/VIRTUALMACHINESCALESETS/WRITE with status Success.
  3. Read the applicationProfile of 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 applicationProfile references the application, and which of them ask for latest.
  • 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:

  1. Remove the application from the applicationProfile of the affected machines and scale sets, and delete the version or the application from the gallery.
  2. 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.
  3. Isolate and investigate the machines that installed the version, and rebuild them from a trusted image if the install command cannot be accounted for.
  4. 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.
  5. 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 applicationProfile of production machines instead of latest.
  • 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.

References

We respect your privacy

We use cookies to keep this site secure and working properly. With your permission, we also use optional cookies to understand usage and improve the experience. Cookie Policy

You can change your choice at any time.