GHSL-2023-275: Arbitrary command execution in verify-changed-files
The verify-changed-files GitHub Action did not sanitise filenames before writing them to the GITHUB_OUTPUT, allowing an attacker to include shell metacharacters in a filename. If a workflow used that output directly in a run block, the attacker could execute arbitrary commands on the runner and potentially steal secrets.
The tj-actions/verify-changed-files workflow allows for command injection in changed filenames, potentially allowing an attacker to leak secrets.
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
Root cause
Likely the action failed to sanitise filenames before appending them to $GITHUB_OUTPUT, so shell metacharacters in filenames were passed unsafely to later run steps.
Impact
This issue may lead to arbitrary command execution in the GitHub Runner, and an attacker may be able to steal secrets such as GITHUB_TOKEN if triggered on events other than pull_request, for example on push.
What the attacker needed
Workflow uses the action's output in a run block; attacker can submit a pull request; workflow approval required
The fix
The issue was fixed in commit 498d3f3.
How it was found
- Submit a pull request to the repository with a new file whose name contains a command injection payload.
- Approve the workflow triggered by the pull request.
- The action executes and the malicious filename flows into the step that lists changed files.
- The injected command runs on the runner.
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 Action is a reusable script that runs during a workflow. This action lists changed files and saves their names as output. Because it did not clean the filenames, a file named with special characters like $(whoami) could be interpreted as a command when the output was later used in a shell script, letting an attacker run their own commands on the runner.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.