skip to content
Back to GitHub.com
Home Bounties Research Advisories CodeQL Wall of Fame Get Involved Events
March 23, 2023

GHSL-2023-027: Command Injection in Cocos - CVE-2023-26493

Jorge Rosillo

Coordinated Disclosure Timeline

Summary

Cocos Engine is vulnerable to a Command Injection in web-interface-check.yml.

Product

Engine for Cocos Creator

Tested Version

3.7.0

Details

Issue: Actions Command Injection in web-interface-check.yml (GHSL-2023-027)

The web-interface-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.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) and altering the repository.

- name: merge HEAD branch
  working-directory: ./engine
  run: |
    git remote add HEAD_REPO https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git
    git fetch HEAD_REPO ${{ github.head_ref }}
    git merge remotes/HEAD_REPO/${{ github.head_ref }}

This issue was found with CodeQL using javascript’s Expression injection in Actions query.

Proof of Concept

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

Impact

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

Resources

CVE

Credit

This issue was discovered and reported by GHSL team member @jorgectf (Jorge Rosillo).

Contact

You can contact the GHSL team at securitylab@github.com, please include a reference to GHSL-2023-027 in any communication regarding this issue.