RoguePuppet – A Critical Puppet Forge Supply Chain Vulnerability
A GitHub Actions misconfiguration in Puppet Labs repositories allowed anyone with a GitHub account to obtain the API key used to publish official Puppet Forge modules. An attacker could then backdoor any official module, potentially compromising thousands of organisations that use Puppet.
Published on adnanthekhan.com
What if there was a supply chain attack that could provide an attacker with direct access to core infrastructure within thousands of companies worldwide. What if that attack required no social engineering and could be executed within a few hours?
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
The workflow used the pull_request_target trigger, which gives access to secrets and a write-capable token, and then checked out and executed code from the pull request (via bundle lock), allowing arbitrary code execution and secret exfiltration.
Impact
An attacker could backdoor any official Puppet Forge module, potentially compromising the infrastructure of thousands of companies that use Puppet, though the text notes that Puppet revoked the token and removed the malicious release, mitigating the vulnerability.
What the attacker needed
A GitHub account; ability to create a pull request
The fix
Puppet Labs fixed the vulnerability by revoking the API token and updating the workflows in dozens of repositories to remove the vulnerable pull_request_target trigger and restrict token permissions.
How it was found
- Create a pull request that modifies the Gemfile to include a system command that exfiltrates secrets.
- The workflow runs bundle lock, which executes the system command, capturing the GITHUB_TOKEN.
- Use the captured token to push a feature branch with a modified metadata.json containing a command injection payload.
- Trigger the release workflow via workflow_dispatch on the feature branch, which executes the payload and exfiltrates the FORGE_API_KEY.
- Use the FORGE_API_KEY to publish a backdoored module to Puppet Forge.
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.
Puppet is a tool that companies use to manage their servers automatically. Puppet Forge is like an app store for Puppet modules, which are scripts that tell servers what to do. A mistake in how Puppet Labs set up their automated build system let anyone who could create a GitHub pull request steal the key that publishes official modules, meaning they could add malicious code to those modules and it would be downloaded by many companies.