Skip to content
RCE Write-up Intermediate

Azure Devops CICD Pipelines - Command Injection With Parameters, Variables And A Discussion On Runner Hijacking

User-controlled runtime parameters and variable group values used inside script or Azure CLI tasks are substituted into the script without validation or encoding, so an attacker who can only run pipelines or edit variable groups can inject shell commands. This lets them execute code on the build runner and steal deployment secrets and Azure service principal credentials.

Sana Oshika Follow

Published on pulsesecurity.co.nz

This article discusses a vulnerability with Azure DevOps that can be exploited by users able to run pipelines with user-controlled variables. The vulnerability allows malicious users with access to edit runtime parameter values to inject shell commands that execute on the pipeline runner.

Sana Oshika (@bigshika), on pulsesecurity.co.nz

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Variables and parameters are substituted directly into the script text without any filtering or encoding of shell metacharacters, by both the server and the runner.

Impact

An attacker could compromise the runner and obtain all secrets and credentials used by its pipeline tasks, including Azure service principal credentials, and then act in Azure with the runner's privileges; log scrubbing masked raw secrets but base64 encoding bypassed it, and testing covered only Linux runners with bash.

What the attacker needed

Ability to run the pipeline; or edit access to a variable group; no pipeline template edit needed; newline injection needs API access

The fix

Microsoft declined to remediate, saying users should not be allowed to modify variables used inside scripts; the safer design is to pass untrusted values as environment variables rather than substituting them into script text.

How it was found

  1. Set up a pipeline whose script or Azure CLI task uses a runtime parameter or a variable group variable.
  2. Start a pipeline run and supply a parameter value containing shell metacharacters, or edit or add a variable group variable with the same name as one used in the script.
  3. Send the run request through the API if newline injection is needed, since the web UI escapes input.
  4. Observe the injected command executing on the runner, for example printing environment variables.
  5. In the Azure CLI task, read the temporary service principal credentials file and encode it to bypass log scrubbing.
  6. Use the extracted credentials to log in to Azure from the attacker's own machine.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A pipeline is a set of automated build and deploy steps that run on a machine called a runner. The pipeline lets people fill in values, such as a parameter typed in when starting a run, and those values are pasted straight into a shell script. Because special characters are not neutralised, someone can type extra shell commands that then run on the runner with its powerful credentials.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by Sana Oshika

View all

2 more disclosed reports, best first.

More from Microsoft (Azure DevOps Pipelines)

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.