CI Secret Exposure via `pull_request_target`
A workflow that checks out untrusted pull-request code in a privileged context hands repository secrets to any fork.
pull_request_target runs in the context of the base repository, with access to secrets. The vulnerable workflow also checks out the pull request's head commit and runs npm install — executing attacker-controlled install scripts with a deploy token in scope.
criticalXV-DEMO-16 · Verified by testUntrusted code executed with repository secrets
Untrusted code executed with repository secrets
Description
The workflow checks out github.event.pull_request.head.sha and runs package install scripts under pull_request_target.
Impact
Any fork could exfiltrate the deploy token.
Recommendation
Build untrusted code under pull_request with no secrets; perform privileged steps in a separate workflow that never executes PR code.
mediumXV-DEMO-17 · Verified by testNo permissions: block for GITHUB_TOKEN
No permissions: block for GITHUB_TOKEN
Description
Token permissions fall back to repository defaults.
Impact
A compromised step may be able to push code or modify releases.
Recommendation
Set permissions: read-all and grant writes per job only where needed.
lowXV-DEMO-18 · Verified by testActions referenced by mutable tag
Actions referenced by mutable tag
Description
actions/checkout@v4 can change underneath you.
Impact
A compromised upstream tag changes what runs in the pipeline.
Recommendation
Pin actions to full commit SHAs and update them deliberately.
Measured in the lab: a static checker flags all three issues in vulnerable.yml and none in fixed.yml. The commit SHAs pinned in the fixed workflow were checked against the upstream release tags (actions/checkout v4.2.2, actions/upload-artifact v4.6.2).
These workflows were analysed statically; they were not executed on GitHub, and no secret exfiltration was performed.
The lab code and tests for this case study live in labs/web2 of the Xevry website repository.
cd labs/web2npm installnode --test test/workflow.test.jsFiles: labs/web2/workflows/vulnerable.yml · labs/web2/workflows/fixed.yml · labs/web2/src/workflowCheck.js
Let's discuss your security needs.
Tell us what you're building. We'll respond with clear questions, an honest view of whether we're the right fit, and a scoped proposal if we are.