Skip to content
RCE Advisory Intermediate

GHSL-2020-244: Arbitrary code execution and shell command injection in nonebot/nonebot2 workflow

The GitHub Actions workflow used pull_request_target and checked out and ran code from a fork, giving untrusted code access to secrets and write permissions. An attacker could modify the base repository and exfiltrate secrets, and also inject shell commands via the branch name.

jarlob Follow

Originally disclosed on GitHub Security Lab

The ‘apidocs.yml’ GitHub workflow is vulnerable to arbitrary code execution and shell command injection.

jarlob, on GitHub Security Lab

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 workflow used pull_request_target and explicitly checked out and executed code from a fork, and also interpolated the attacker-controlled branch name directly into a shell command.

Impact

The vulnerability allows for unauthorized modification of the base repository and secrets exfiltration, and the injection allows exfiltration of secrets and the temporary GitHub token; the token is not valid after the workflow finishes, but the attacker can delay the workflow to give the malicious server time to modify the repository.

What the attacker needed

Ability to create a pull request from a fork

The fix

The issue was resolved, but the text does not describe the fix.

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, like a pull request. The pull_request_target trigger gives the workflow powerful permissions, but if it then runs code from an untrusted fork, that code can misuse those permissions. Here, the workflow ran code from a fork and also inserted the branch name into a shell command, allowing an attacker to run their own commands.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by jarlob

View all

192 more disclosed reports, best first.

More from GitHub Security Lab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.