skip to content
Back to
Home Bounties Research Advisories CodeQL Wall of Fame Get Involved Events
June 2, 2023

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

Jaroslav Lobacevski

Coordinated Disclosure Timeline


Apache Cloudstack is vulnerable to a Command Injection in sonar-check.yml.


Apache Cloudstack

Tested Version


Issue: Command Injection in Actions sonar-check.yml workflow (GHSL-2023-022)

The sonar-check.yml workflow is triggered on pull_request_target (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.

Taking the above into account, this workflow runs the following step with data controlled by said fork (${{ github.event.pull_request.head.ref }} – the name of the fork’s branch), allowing an attacker to take over the GitHub Runner and run custom commands (potentially stealing secrets such as GITHUB_TOKEN, SONAR_TOKEN) and altering the repository.

- name: Run Build and Tests with Coverage
   id: coverage
     GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
     SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
     PR_ID: ${{ github.event.pull_request.number }}
   run: |
     git clone nonoss
     cd nonoss && bash -x && cd ..
     mvn -P quality -Dsimulator -Dnoredist clean install org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=apache_cloudstack -Dsonar.pullrequest.key=$PR_ID -Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }} -Dsonar.pullrequest.github.repository=apache/cloudstack -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.github.summary_comment=true

Proof of Concept

  1. Fork the apache/cloudstack repository, whose name we will refer as username/cloudstack-fork.
  2. Create a branch in username/cloudstack-fork with the name main;echo${IFS}"hello";#.
  3. Push any change to the former branch.
  4. Create a pull request from username/cloudstack-fork:main;echo${IFS}"hello";# to apache/cloudstack:main.
  5. Check the workflow runs for the new Actions run that will execute the command echo "hello".


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



This issue was discovered and reported by GHSL team members @jorgectf (Jorge Rosillo) and @JarLob (Jaroslav Lobačevski).


You can contact the GHSL team at, please include a reference to GHSL-2023-022 in any communication regarding this issue.