← Blog

Poisoned pipeline execution: direct, indirect and public

· 7 min read

Poisoned pipeline execution (PPE) is the attack where you never touch the build server. You change something the pipeline runs, and the pipeline runs it for you, with its own secrets and permissions. It is CICD-SEC-4 in the OWASP Top 10 CI/CD Security Risks, and one of the ten risks covered in our guide to CI/CD pipeline security.

OWASP splits it into three forms: direct, indirect and public. Each needs a different fix, so it is worth being precise about which one you have.

What poisoned pipeline execution means

OWASP describes PPE as the ability of an attacker with access to source control, but without access to the build environment, to manipulate the build process by injecting commands into the pipeline. Those commands then run with the pipeline's identity.

The attacker's foothold is small: push access to one branch, or the right to open a pull request. What they gain is whatever the job holds. That is often a cloud key, a registry token, a deploy key or a source control token with write access.

Direct PPE: editing the workflow file

In direct PPE the attacker edits the CI configuration itself. OWASP's example is a GitHub Actions workflow that runs on every push: the attacker creates a branch, edits the workflow to read the repository's cloud credentials and send them out, and pushes. The push triggers the edited workflow.

The vulnerable shape is a workflow that runs on any branch and hands secrets to every job:

on: push                    # every branch, including the attacker's

jobs:
  build:
    runs-on: ubuntu-latest
    env:
      AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
    steps:
      - uses: actions/checkout@v4
      - run: make build

Branch protection on main does not help here. The workflow that runs is the one on the attacker's branch, and nobody reviewed it.

Fix: keep secrets out of any job that runs on unprotected branches. Put them in a job gated to protected branches or to a protected environment, and give every branch that can trigger a sensitive pipeline a matching protection rule.

Lab: Direct: change the workflow file in a pull request.

Indirect PPE: poisoning the files the pipeline calls

Sometimes the workflow file cannot be changed: it is loaded from a protected branch, kept in a separate repository, or defined in the CI server. OWASP calls this indirect PPE. The attacker leaves the configuration alone and changes a file it runs. OWASP lists Makefiles, scripts referenced by the pipeline, test code, and the configuration files of linters and scanners.

OWASP's example is a Jenkins pipeline whose Jenkinsfile comes from the protected main branch. It loads cloud credentials and runs make build. The attacker opens a pull request that adds one command to the Makefile, and the trusted Jenkinsfile runs it with the credentials loaded.

This is the version teams miss most often, because the review rule on .github/workflows/ or the Jenkinsfile looks like it covers the pipeline. It covers the entry point, not what the entry point executes. Package manager hooks count too: GitHub Security Lab notes that an npm install will run preinstall and postinstall scripts from the pull request's package.json.

Fix: treat every file a privileged job executes as part of the pipeline. If a job holds secrets, it must not run code from an unreviewed branch at all.

Lab: Indirect: leave the workflow alone and poison the Makefile it calls.

Public PPE (3PE): anyone with a fork

Public PPE, which OWASP abbreviates as 3PE, is direct or indirect PPE carried out by an anonymous user against a public repository. Open source projects accept pull requests from anyone, and many build them automatically. OWASP adds a less obvious risk: if the same CI instance also builds private projects, a public pull request can reach their secrets too.

GitHub's defaults for the pull_request trigger are built for this case. Per the documentation, "with the exception of GITHUB_TOKEN, secrets are not passed to the runner when a workflow is triggered from a forked repository," and the token "has read-only permissions in pull requests from forked repositories." Maintainers can also require approval before workflows from fork pull requests run.

Those defaults stop holding when a workflow uses a privileged trigger, or runs on a self-hosted runner. GitHub's guidance is that self-hosted runners "should almost never be used for public repositories", because any user can open a pull request and compromise the environment.

Why pull_request_target is the GitHub Actions trigger to audit first

Most real PPE in GitHub Actions goes through pull_request_target. GitHub's documentation says it "runs in the context of the default branch of the base repository" and warns that running untrusted code on it can lead to "cache poisoning and granting unintended access to write privileges or secrets."

The trigger is safe as long as the workflow never runs code from the pull request, for example when it only labels or comments. It becomes PPE the moment it checks out the pull request's head and builds it:

on: pull_request_target

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha }}   # untrusted code
      - run: npm install && npm test                        # runs it with secrets in reach

GitHub Security Lab named this a "pwn request" in 2021. It also notes that actions/checkout persists the token to disk by default, so code that runs later in the job can read it.

The Ultralytics compromise in December 2024 is a recent example. PyPI's analysis says the attack started with "a compromise of the projects' GitHub Actions workflows" and targeted the GitHub Actions cache used during the build. Four malicious versions reached PyPI. William Woodruff's analysis points to a pull_request_target workflow and a composite action that ran git pull origin ${{ github.head_ref || github.ref }}, putting the branch name straight into a shell.

GitHub has been narrowing this trigger. From 8 December 2025, the workflow file and checkout commit for pull_request_target always come from the default branch. From 2 December 2026, pull_request_target is blocked by default in public repositories unless an Actions event policy allows it. Private and internal repositories are not affected. Neither change covers workflow_run, which GitHub says "is able to access secrets and write tokens", or script injection, or indirect PPE through a branch that runs with secrets.

Script injection: PPE without changing a file

A workflow does not need to run the attacker's code to run the attacker's commands. If it puts an attacker-controlled value into a shell step, the value becomes code. GitHub Security Lab lists the untrusted fields, including github.event.issue.title, github.event.pull_request.body, github.event.comment.body and github.head_ref.

The fix GitHub recommends is to pass the value through an environment variable, so the shell treats it as data:

- name: print title
  env:
    TITLE: ${{ github.event.issue.title }}
  run: echo "$TITLE"

The vulnerable version is the same step with ${{ github.event.issue.title }} written directly inside run:.

Lab: Script injection through a branch name and an issue title.

How to find poisoned pipeline execution in your workflows

Go through each repository's workflows and answer these questions:

[ ] Which workflows use pull_request_target or workflow_run?
[ ] Do any of them check out the pull request head, or download its artifacts?
[ ] Which jobs can read secrets, and on which branches do they run?
[ ] Does every branch that triggers a job with secrets have a protection rule?
[ ] Which files does each privileged job execute (Makefile, scripts, tests, package hooks)?
[ ] Is any ${{ github.event.* }} or github.head_ref expression inside a run: block?
[ ] Does the default GITHUB_TOKEN permission set say contents: read?
[ ] Do public repositories run on self-hosted runners?

How to fix it: split trusted and untrusted work

The structural fix is to separate the two kinds of job. Code from pull requests runs in an untrusted job: the pull_request trigger, no secrets, a read-only token, an ephemeral runner. Anything that needs credentials runs in a trusted job that only starts after merge, or behind an environment with required reviewers.

If you need to report results back to a pull request, GitHub Security Lab's pattern is an unprivileged pull_request workflow that uploads its results as an artifact, and a separate workflow_run workflow that reads them and comments. Treat that artifact as untrusted input in the second workflow.

Then lower the token: set permissions: contents: read at the top of every workflow and raise it only in the job that needs more. OWASP adds the last layer: give each pipeline only the credentials it needs, and remove repository permissions from users who do not need them.

Lab: Fix it: split trusted and untrusted workflows, least-privilege job tokens. You rebuild the workflows, then replay the direct, indirect and script injection attacks and watch each one fail.

To see the whole attack end to end, try the free lab (open from 12 January 2027) Steal a deploy secret from a pull request, in 30 minutes. It runs a real Git server and CI runner in your browser.

Learn it by breaking it

Hands-on DevSecOps labs launch 12 January 2027, with the first two modules free.

See the course