Cacheract: The Monster in your Build Cache
A proof-of-concept tool called Cacheract exploits GitHub Actions cache poisoning to achieve persistence and arbitrary code execution in CI/CD pipelines. It can steal secrets and overwrite files in subsequent builds that consume the poisoned cache.
Published on adnanthekhan.com
In May of 2024, I released an in-depth blog post covering GitHub Actions Cache Poisoning along with a rough proof-of-concept.
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 cache key and version are client-controlled, and the cache extraction uses tar with the -P flag, allowing arbitrary file overwrite on the runner.
What the attacker needed
Workflow misconfiguration allowing untrusted code execution; cache write token available to all workflows; attacker can create a pull request
The fix
Software maintainers should not consume the cache in release builds; integrity is more important than saving build time.
How it was found
- Create a pull request that modifies package.json to run a curl | base payload.
- The payload downloads and runs Cacheract, which steals tokens and poisons cache entries.
- Merge the pull request so the poisoned cache entry is used in the main branch.
- Cacheract runs during the post-checkout step, extracts secrets, and poisons more caches.
- Create a release to trigger a workflow that uses the poisoned cache, leading to code execution and secret theft.
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 is a service that runs automated build and test jobs. These jobs can save and reuse files in a cache to speed things up. If an attacker can write a malicious file into that cache, later jobs that use the cache will run the attacker's code, letting them steal secrets or change the build.