Insecure CI/CD System Configuration
Job two inherits whatever job one left on the runner's disk.
What Is Insecure CI/CD System Configuration?
A self-hosted runner that is not destroyed after each job is a shared machine that strangers' code runs on, where the next job inherits whatever the last one left on disk. You'll watch a pull-request job leave a file in a shared runner's tool cache that an unrelated release job then runs with production credentials, then fix it by making runners ephemeral and keeping fork pull requests off them.
What You'll Learn in Insecure CI/CD System Configuration
- A self-hosted runner that is not destroyed after each job is a shared machine over time, where one job's leftovers are the next job's starting state.
- A fork pull-request job and a release job that run back to back on the same runner share a disk, which is enough for one to reach the other's credentials.
- Make runners ephemeral so each job starts from a clean image, and keep fork pull requests off self-hosted runners entirely.
- Isolate runners on their own network segment and rotate any credential a shared runner exposed.
Insecure CI/CD System Configuration — Training Steps
-
A runner that is never wiped
Dravale runs its pipeline on self-hosted runners. They are not ephemeral: a runner finishes one job and picks up the next without being wiped, so its disk, its caches and anything left in them carry over. Bob's fork pull request runs a job on one of these runners. He does not need to break out of it. He just needs to leave something behind.
-
Shared and reused
The runner is reused across jobs rather than destroyed after each one, and it accepts jobs from forked pull requests. So a stranger's job and a release job run on the same machine, one after another.
-
Leave something in the cache
From his pull-request job, Bob looks at the shared tool cache. It already holds tools other teams' jobs left there, which is all the proof he needs that it survives between jobs. He drops a wrapper beside them.
-
The next job runs it
Bob reopens the runner. Right after his pull-request job, a release build for a different team ran on the same machine, used node18, and so ran his wrapper, with that job's production credentials in reach.
-
What the two jobs shared
-
Credentials from a clean release
Dravale's monitoring caught a release build's credentials being used from outside the pipeline. The release job itself was clean; what it ran was not.
-
Two jobs, one machine
Alice opens the runner. Its recent jobs tell the story: a forked pull request, then a release build, back to back on the same machine.
-
Reused, and open to forks
The cause is in the runner's settings: it is reused rather than destroyed after each job, and it accepts jobs from forked pull requests on the same machine the release jobs use.
-
How the runner is configured
Alice opens the runner configuration, where the two settings that made this possible are written down.
-
Wipe between jobs, keep forks off
Alice makes the runners ephemeral, so each one is destroyed and rebuilt from a clean image after every job, and moves forked pull requests onto disposable cloud runners instead of these.
Security Framework Coverage
OWASP CI/CD Top 10
- CICD-SEC-7 Insecure System Configuration
CWE
- CWE-459 Incomplete Cleanup
- CWE-668 Exposure of Resource to Wrong Sphere
MITRE ATT&CK
- T1195.002 Supply Chain Compromise: Compromise Software Supply Chain
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