GHSL-2021-007: Arbitrary code execution and shell command injection in dmlc/gluon-nlp workflows
Two GitHub Actions workflows in the dmlc/gluon-nlp repository used pull_request_target and checked out and ran code from a fork, and also interpolated the pull request branch name into shell commands. An attacker could open a pull request from a fork to run arbitrary code with write access to the base repository and access to secrets, or inject shell commands via a crafted branch name.
The buildwebsite.yml and unittests-gpu.yml GitHub workflows are vulnerable to unauthorized modification of the base repository or secrets exfiltration from a Pull Request.
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
The workflows used the pull_request_target trigger, which grants write permissions and secrets, but then checked out and executed code from the pull request's fork, and also inserted the untrusted branch name directly into shell commands.
What the attacker needed
Ability to open a pull request from a fork
The fix
The issue was resolved, but the text does not describe the fix.
How it was found
- Create a pull request from a fork to the base repository.
- The workflow triggered by pull_request_target checks out the fork's code and runs it.
- The fork's code executes with write access to the base repository and access to secrets.
- Alternatively, name the branch with shell metacharacters to inject commands into the workflow's run steps.
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.
GitHub Actions are automated tasks that run when something happens in a repository, like a pull request. Some triggers give the workflow powerful permissions, such as the ability to write to the repository or read secret values. If such a workflow runs code from an untrusted pull request, the author of that pull request can take over the repository or steal the secrets.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.