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.
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.
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
- Fork the apache/cloudstack repository.
- Create a branch in the fork with a name containing shell metacharacters.
- Push any change to that branch.
- Create a pull request from the fork's branch to apache/cloudstack:main.
- 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.