Skip to content
RCE Advisory Intermediate

GHSL-2023-022: Command Injection in an Apache Cloudstack CI workflow

The Apache CloudStack CI workflow sonar-check.yml used the fork's branch name in a shell command without sanitisation, allowing an attacker to inject arbitrary commands. An attacker could take over the GitHub Runner, steal secrets such as GITHUB_TOKEN and SONAR_TOKEN, and modify the repository.

jarlob Follow

Originally disclosed on GitHub Security Lab

The sonar-check.yml workflow is triggered on pullrequesttarget (i.e., when a Pull Request against the base repository is created or updated), which also covers the case when the Pull Request is originated from a fork. The workflow starts with full write GitHub repository token since the defaults aren’t altered.

jarlob, on GitHub Security Lab

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

Impact

This issue may lead to stealing workflow secrets and modification of the repository.

What the attacker needed

GitHub account; Ability to fork the repository; Ability to create a pull request

The fix

The issue was resolved by the Apache CloudStack team.

How it was found

  1. Fork the apache/cloudstack repository.
  2. Create a branch in the fork with a name containing shell metacharacters.
  3. Push any change to that branch.
  4. Create a pull request from the fork's branch to apache/cloudstack:main.
  5. Check the workflow runs to see the injected command executed.

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 is an automated script that runs when something happens, like a pull request. This workflow took the name of the branch from the pull request and put it directly into a command line without cleaning it. Because the branch name could contain special characters, an attacker could make the command line run extra commands of their choosing.

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 jarlob

View all

192 more disclosed reports, best first.

More from GitHub Security Lab

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.