Poisoned Pipeline Execution
The workflow was correct. A lint config ran the attacker's code.
What Is Poisoned Pipeline Execution?
The pipeline definition is reviewed and pinned, and it still runs attacker code, because it executes files the repository controls: a lint config, a test bootstrap, a build script. You'll watch a pull request that touches no workflow file add one line to a lint config, run in a job that holds the pipeline's secrets, and send them out, then fix it by giving untrusted pull-request jobs no credentials at all.
What You'll Learn in Poisoned Pipeline Execution
- A pipeline executes files the repository controls, so a pull request can change what a job runs without touching the reviewed workflow.
- The danger of a one-line config reference is invisible from the diff; it only matters because the job that loads it holds the pipeline's secrets.
- Give any job that runs untrusted pull-request code no secrets at all, so executing a planted file gains nothing.
- Treat every file a job executes, such as a lint config or build script, as pipeline code under required review.
Poisoned Pipeline Execution — Training Steps
-
A pull request with no workflow change
Castwyn's pipeline runs lint, tests and a build on every pull request. The workflow that defines those jobs is reviewed and protected, and Bob cannot change it without someone reading the diff. So he does not change it. He opens a pull request that adds one line to a lint config, and lets the pipeline run the rest.
-
Not a single .yml file
The pull request changes two files, and neither is the workflow. A reviewer who guards the pipeline by watching for workflow changes sees nothing to look at here.
-
One line in a lint config
The whole change to the config is one line: it adds a local lint plugin. Read on its own it is a routine lint tweak. Its danger is only that the lint job will load and run the file it points at.
-
The lint job runs his code
The pipeline runs lint on the pull request. Lint loads the config, the config loads his file, and his file runs inside a job that holds the pipeline's secrets. Bob opens that job's log.
-
Why reviewing the workflow missed it
-
Secrets left a lint job
Castwyn's monitoring flagged the pipeline's deploy and registry tokens leaving the network from a lint job, on a pull request that changed no workflow file.
-
Read the job that leaked
Alice opens the lint job the alert pointed at, to see exactly what ran and what it took.
-
Secrets in a job that runs PR code
The job's environment carried the deploy and registry tokens, and the lint step loaded a file the pull request introduced. The two together are the whole incident.
-
The file the lint job ran
Alice opens the file the lint config pointed at. It presents itself as a lint plugin, and alongside its rules it reads the environment and sends it out. This is the file the pipeline executed.
-
The workflow is correct
The workflow itself is fine: it runs lint on pull requests, as it should. The flaw is that this lint job, which runs code from the pull request, carries the pipeline's secrets.
Security Framework Coverage
OWASP CI/CD Top 10
- CICD-SEC-4 Poisoned Pipeline Execution (PPE)
CWE
- CWE-94 Improper Control of Generation of Code ('Code Injection')
- CWE-829 Inclusion of Functionality from Untrusted Control Sphere
MITRE ATT&CK
- T1195.002 Supply Chain Compromise: Compromise Software Supply Chain
- T1552 Unsecured Credentials
CIS Controls
- CIS 16 Application Software Security
NIST CSF
- PR.AT-02 Individuals in specialized roles are provided with awareness and training so that they possess the knowledge and skills to perform relevant tasks with cybersecurity risks in mind
- PR.PS Platform Security
NICE Framework
- DD-WRL-004 Secure Systems Development
- IO-WRL-005 Systems Administration