GHSL-2023-271: Arbitrary command execution in changed-files
The changed-files GitHub Action did not properly escape special characters in filenames, allowing an attacker to inject commands via a crafted filename. If the output was used in a run block, this could lead to arbitrary command execution on the GitHub Runner and potential secret theft.
Originally disclosed on GitHub Security Lab
The tj-actions/changed-files workflow allows for command injection in changed filenames, allowing an attacker to execute arbitrary code and potentially 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
Impact
This issue may lead to arbitrary command execution in the GitHub Runner, and an attacker could steal secrets such as GITHUB_TOKEN if triggered on events other than pull_request, for example on push.
What the attacker needed
A GitHub repository using the action; attacker can submit a pull request; workflow approval required; output used in a run block
The fix
The issue was fixed in commit 0102c07.
How it was found
- Submit a pull request with a new file whose name contains a command injection payload.
- Approve the workflow triggered by the pull request.
- The action runs and the malicious filename flows into a step that uses the output in a run block, executing the injected command.
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 tool that runs automatically when code changes. This action lists changed files, but it didn't clean up special characters in filenames. An attacker could name a file something like `$(whoami).txt`, and if the action's output was used in a script, the command inside the filename would run on the server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.