GHSL-2024-294: Environment variable injection leading to potential secret exfiltration and privilege escalation in Azure/cli
The AddPRComment.yml workflow in Azure/azure-cli was vulnerable to environment variable injection because a pull request title could contain multiple bracketed segments that were concatenated into a multi-line message variable, allowing an attacker to inject new environment variables. An attacker could then set HTTPS_PROXY and NODE_TLS_REJECT_UNAUTHORIZED to redirect the workflow's HTTP requests through a malicious proxy and steal the CLI_BOT secret.
Originally disclosed on GitHub Security Lab
Azure/azure-cli is vulnerable to Environment Variable Injection which may allow a malicious actor to exfiltrate the CLIBOT secret.
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 report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The workflow extracted text from the pull request title using grep and sed, which could produce multiple lines, and then wrote that multi-line value directly into GITHUB_ENV without sanitising newlines, allowing injection of arbitrary environment variables.
Impact
The CLI_BOT token could be exfiltrated, and depending on its permissions it may have organization access and be used to escalate to other workflows or repositories or steal org-level secrets.
What the attacker needed
Ability to open a pull request; workflow triggered on pull_request_target
The fix
The workflow should avoid writing unsanitised multi-line values to GITHUB_ENV, for example by sanitising newlines or using a safer method to pass the message.
How it was found
- Submit a pull request with a title containing multiple bracketed segments, including a binary operator flag to handle the injected lines.
- The workflow runs and extracts the bracketed text into the message variable, which becomes multi-line.
- The multi-line message is written to GITHUB_ENV, defining new environment variables such as HTTPS_PROXY and NODE_TLS_REJECT_UNAUTHORIZED.
- The subsequent composite action uses the injected proxy settings, causing its HTTP requests to go through the attacker's proxy.
- The CLI_BOT token is attached to those requests and could be captured by the attacker.
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 report has not been written yet. The Original tab links to the source.
A GitHub Actions workflow automatically ran when someone opened a pull request. It took the pull request title and used it to build a message, but it did not properly handle titles with multiple bracketed parts. By crafting a special title, an attacker could add their own environment variables to the workflow, which are settings that control how programs run. They then used those settings to send the workflow's network traffic through a server they controlled, hoping to capture a secret token.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.