Coordinated Disclosure Timeline
- 2023-05-04: Report sent to security@z.cash
- 2023-05-04: Fix commit is pushed
Summary
The zcash/zcash repository is vulnerable to a command injection in Actions, allowing an attacker to take over the contents of the repository and leak secrets.
Product
Zcash
Tested Version
Details
Actions command injection in checks.yml (GHSL-2023-101)
The checks.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 a Pull Request originates from a fork.
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.
- name: Ensure branch contains necessary commits for Tekton CI
id: tekton
# https://github.com/zcash/zcash/pull/6358
run: git merge-base --is-ancestor 267ddf8efe36cc799c4c31772a8883ea332ef55b ${{ github.head_ref }}
This issue was found by the Expression injection in Actions CodeQL query.
Proof of Concept
- Fork the zcash/zcash repository, whose name we will refer as
username/zcash-fork. - Create a branch in
username/zcash-forkwith the namemaster;echo${IFS}"hello";#. - Push any change to the former branch.
- Create a pull request from
username/zcash-fork:master;echo${IFS}"hello";#tozcash/zcash:master. - 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
- Keeping your GitHub Actions and workflows secure Part 2: Untrusted input
- Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests
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-101 in any communication regarding this issue.