GHSL-2024-205_GHSL-2024-206: Code Injection in Stirling PDF
The check_properties workflow ran on the privileged pull_request_target event with write permissions and inserted the list of changed file names into a shell command. An attacker could craft a pull request whose file name contained shell syntax, causing arbitrary commands to run in the workflow and allowing modification of any repository file.
Originally disclosed on GitHub Security Lab
Multiple Code Injection vulnerabilities exist in the checkproperties.yml workflow, allowing an external user to gain write permissions to the repository.
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 workflow interpolated attacker-controlled data (the changed file names) directly into a run script instead of passing it through an environment variable, so shell metacharacters in a file name were executed.
Impact
This may allow a malicious actor to modify any files in the repository, with the workflow running with contents and pull request write permissions.
What the attacker needed
Ability to open a pull request; pull request changes a properties file
The fix
The issue was fixed in a commit; the workflow should avoid interpolating untrusted values into scripts and pass them via environment variables instead.
How it was found
- Open a pull request that changes a properties file.
- Name the changed file so it contains shell syntax.
- The workflow checks out the pull request branch.
- The workflow collects the changed file names into an environment variable.
- The workflow interpolates that variable into a bash script, executing the injected commands.
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 Actions workflow is an automated script that runs when something happens on a repository, such as a pull request. This one ran with permission to write to the repository and pasted the names of changed files straight into a shell command, so a file name containing shell instructions would be executed as code. That let an outsider run their own commands with the repository's write access.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.