Compromising ByteDance’s Rspack using GitHub Actions Vulnerabilities
Two GitHub Actions workflows in the Rspack repository would check out and run code from an attacker-controlled pull request branch when a specific keyword was commented. An attacker could exploit this to steal an NPM deployment token and a privileged GitHub token, and by compromising a self-hosted runner, obtain a GitHub PAT with administrative access.
Published on praetorian.com
Recently, we identified several critical Pwn Request vulnerabilities within GitHub Actions used by the Rspack repository. These vulnerabilities could allow an external attacker to submit a malicious pull request, without the requirement of being a prior contributor to the repository, and compromise the following…
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 write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the workflows were triggered by issue comments and checked out and executed code from the pull request branch without validating the author, while also passing privileged secrets to that code.
Impact
An attacker could steal the NPM deployment token to publish malicious Rspack packages and obtain a GitHub PAT with administrative control over the Rspack repository and related organizations, potentially enabling a supply chain attack.
What the attacker needed
Ability to open a pull request; Comment with specific keyword; No prior contribution needed
The fix
The vulnerable workflows were removed from the Rspack repository, but self-hosted runners remain, which could heighten the impact of future vulnerabilities.
How it was found
- Fork the Rspack repository and create a branch with a modified script named 'x' that exfiltrates environment variables.
- Open a pull request from that branch and comment '!canary' to trigger the Release Canary workflow.
- Receive the exfiltrated NPM deployment token and GITHUB_TOKEN on a remote server.
- For the Diff Assets workflow, exploit a similar Pwn Request to install persistence on the self-hosted runner using the Runner-on-Runner technique.
- Trigger the Diff Assets workflow and use 'docker exec' on the compromised runner to read the container's environment variables, obtaining the Rspack_REPORT_ACCESS_TOKEN.
- Use the stolen PAT to enumerate permissions with Gato, revealing administrative access to the Rspack repository and related organizations.
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 write-up 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 comment on a pull request. If such a task runs code from an untrusted pull request and has access to secret passwords (tokens), an attacker can change that code to send the secrets to themselves. Here, the attackers did exactly that and also took over a self-hosted runner (a server that runs these tasks) to steal more secrets.