How CI/CD Pipelines Become Part of Your Attack Surface
AIThis post was created with the assistance of artificial intelligence (AI).

TL;DR

Prime Big Deal Days · Oct 6–7Offer from Amazon

Get privacy and security gear delivered free — and shop member deals

  • Fast, free delivery on millions of items
  • Access to Prime Big Deal Days deals on October 6–7
  • Prime Video, Amazon Music and more included
Start your free Prime trial Free trial for eligible customers · Cancel anytime
As an affiliate, we earn on qualifying purchases.

CI/CD pipelines are part of your production infrastructure: they hold credentials, fetch code and dependencies, and can publish or deploy software. A compromise anywhere in that chain — a dependency, a third-party action, a runner, or a workflow file — can reach source code, cloud accounts, and end users. The core defenses are least-privilege permissions, short-lived credentials, runner isolation, and verified artifact provenance.

Your build server probably has more power than any single developer on your team. It can read every repository, publish packages, sign artifacts, and deploy to production — often with long-lived credentials that nobody has rotated in a year. That’s why attackers love it.

CI/CD pipelines are part of your production infrastructure, whether you think of them that way or not. They hold credentials, fetch code and dependencies, run scripts, and build the artifacts your users ultimately run. If someone compromises a step along that path, they don’t need to breach your production servers at all — your pipeline will happily deploy their malicious code for them, using your own trusted credentials.

In this guide, you’ll learn the main ways pipelines get attacked, why secrets and runners are such high-value targets, and the practical defenses that actually reduce risk. No fear-mongering, no jargon walls — just a clear picture of the weak links and how to shore them up.

At a glance
How CI/CD Pipelines Become Part of Your Attack Surface
Key insight
A single stolen CI runner token can carry more destructive reach than a compromised developer workstation, because build agents routinely hold access to source repositories, package registries, signi…
Key takeaways
1

CI/CD pipelines are privileged production infrastructure — build agents often hold broader access (source, registries, signing keys, cloud accounts) than any i…

2

Secret masking hides values in logs but does not protect secrets from malicious code running in the same job; never expose secrets to untrusted pull request bu…

3

Pin third-party actions and images to immutable revisions and require review for workflow file changes — poisoned pipeline configuration is the persistence mec…

4

Provenance and attestations (per SLSA and NIST SSDF guidance as of 2024) provide evidence of how an artifact was built, but are only trustworthy if the build a…

5

Prefer short-lived, workload-based credentials over static keys, isolate runners between trust levels, and rehearse revoking CI credentials before an incident…

How CI/CD Pipelines Become Part of Your Attack Surface
Supply Chain Security · Field Guide

How CI/CD Pipelines Become Part of Your Attack Surface

Pipelines hold credentials, fetch code and dependencies, and can publish or deploy software. A compromise anywhere in that chain — a dependency, a third-party action, a runner, or a workflow file — can reach source code, cloud accounts, and end users. And your pipeline will happily deploy the attacker’s code for them, using your own trusted credentials.

Key Insight
“A single stolen CI runner token can carry more destructive reach than a compromised developer workstation.”
8
Well-worn attack paths
0
Zero-days required
Source: vultrade.com analysis
1×
Compromised link reaches code, registries & cloud
∞
Rebuilds don’t cure a poisoned workflow file
2–3
Repos a typical developer can touch
100%
Of masking bypassed by one curl to an endpoint
01 · Privilege Gap

Why Your Build Server Is More Powerful Than Your Laptop

Whatever your pipeline can do, an attacker who compromises your pipeline can do too. A build agent aggregates privileges that no single human should ever hold at once — and often with long-lived credentials nobody has rotated in a year.

Typical Developer Workstation

Narrow, Human-Scale Access

  • Access to 2–3 repositories
  • One scoped API token
  • No package publishing rights
  • No signing keys on the machine
vs.
CI Build Agent

Aggregated Super-User

  • Read access to every repository
  • Entire cloud-account credentials
  • Public package publish rights
  • Signing keys + production deploy
  • Long-lived, unrotated tokens
Relative blast radius — resources reachable per identity (illustrative)
CI Build Agent
96
Dev Workstation
28
02 · Threat Model

The 8 Attack Paths That Turn Builds Into Breaches

Almost none of these involve breaking a cipher or exploiting a zero-day. They involve trust and configuration — code you allowed to run, permissions granted too broadly, state you didn’t clean up. You almost certainly have at least two.

1
Supply Chain

Malicious Dependencies

A package or build tool executes code during install and steals secrets or alters build output — install scripts run with the same environment as your build.

2
Workflow Config

Untrusted Contribution Workflows

Pull request code runs with permissions or secrets it should never receive, because the workflow treats untrusted code as trusted.

3
Third-Party

Compromised CI Components

An action, plugin, or container image is compromised — or referenced by a mutable tag that lets upstream changes flow silently into builds.

4
Persistence

Poisoned Pipeline Configuration

Edited workflow files make future runs exfiltrate credentials or tamper with artifacts. The infection survives every rebuild.

5
Runner State

Exposed or Persistent Runners

A self-hosted runner retains files, credentials, or state between jobs — one job steals what another job left behind.

6
Integrity

Artifact Substitution

A build output gets replaced or modified between creation, storage, approval, and deployment.

7
Identity

Overprivileged Credentials

A token intended for one repository can publish packages or modify infrastructure across many projects.

8
Isolation

Build Cache Abuse

Shared or poorly isolated caches let one job read sensitive data or quietly influence another job’s build.

03 · Crown Jewels

Why Secrets Are the Crown Jewels — And Why Masking Isn’t Enough

Secrets are the bridge between your build system and everything else you own: long-lived tokens, cloud keys, signing credentials, and environment variables all sit in the build environment, waiting to be used — or misused.

What Teams Believe

Masking = Protection

CI platforms replace secret values with asterisks in build logs. That’s useful accident prevention — it stops display.

But a compromised third-party action can add one innocent-looking line that collects environment variables and posts them to an external endpoint. Every secret available to that job walks out the door, neatly logged nowhere.

What Actually Works

Don’t Expose Secrets at All

Never expose secrets to untrusted pull request builds. Outside contributors get restricted workflows with no sensitive credentials.

Prefer short-lived credentials — workload identity federation and scoped, temporary tokens mean a leaked credential expires before it’s useful.

Masking prevents display. It does not prevent access. A secret exposed to untrusted code is a secret you should already treat as compromised.

04 · Runner Risk

Hosted vs. Self-Hosted Runners: Which Risk Can You Manage?

There is no universal answer — the risk profile is different, not better. Compare the trade-offs against what your team can actually monitor and harden.

Dimension Hosted Runners (GitHub / GitLab) Self-Hosted Runners
Lifecycle ✓ Ephemeral — fresh machine per job, destroyed after ✗ Persistent — state survives between jobs
Cross-job leakage ✓ Largely eliminated by design ✗ Files & credentials left behind by prior jobs
Hardware / network control ~ None — you share platform assumptions ✓ Full control over hardware, network, tooling
Isolation between trust levels ✓ Managed by platform defaults ~ Possible, but your responsibility to enforce
Untrusted PR exposure ✓ Sandbox + ephemerality reduce impact ✗ Classic entry point — one malicious PR owns the runner
💻 Dev Workstation
→
🔀 Pull Request
→
⚙️ Self-Hosted Runner
→
🔑 Publish Token
→
📦 Registry
→
👥 Every Downstream User
Indirect compromise path: the attacker doesn’t want your code — they want your runner’s reach.
05 · Defense Playbook

The Four Defenses That Actually Reduce Risk

Core defenses in order of leverage — aligned with SLSA and NIST SSDF guidance as of 2024.

1

Least-Privilege Permissions

Scope every token, workflow, and environment to one job. Repository permissions alone don’t cover runner admin, approvals, and publishing rights.

2

Short-Lived Credentials

Workload identity federation over static keys. A leaked credential should expire before it’s useful — and rehearse revocation before an incident.

3

Runner Isolation

Separate runners by trust level. Untrusted PR builds get ephemeral, credential-free environments — never a shared persistent machine.

4

Verified Provenance

Sign attestations of what source, dependencies, and workflow built each artifact — trustworthy only if the build and signing processes are protected.

Why Your Build Server Is More Powerful Than Your Laptop

CI/CD pipelines are part of your production infrastructure, and that framing changes everything about how you should treat them. A pipeline is the automated process that tests, builds, packages, and deploys your software. Along the way, it touches nearly every valuable thing your organization owns: source code, package registries, signing keys, cloud accounts, and deployment environments.

Now compare that to a typical developer workstation. A developer might have access to two or three repositories and a scoped API token. A build agent, on the other hand, might hold credentials for the entire cloud account, the ability to publish packages publicly, and write access to dozens of repositories. According to vultrade.com, a stolen or misused runner can therefore have broader impact than a typical developer workstation — because it aggregates privileges that no single human should ever hold at once.

Here’s a scenario that plays out regularly: an open-source maintainer’s self-hosted CI runner gets compromised through a malicious pull request. The attacker doesn’t care about the project’s code itself. They care that the runner’s environment contains a token with publish rights to a package registry — and suddenly, every downstream user of that package is exposed.

The lesson is simple but uncomfortable: whatever your pipeline can do, an attacker who compromises your pipeline can do too. Keep that in mind as we look at where things actually break.

The 8 Attack Paths That Turn Builds Into Breaches

Most pipeline compromises follow one of a small number of well-worn paths. Understanding them helps you spot which ones apply to your setup — because you almost certainly have at least two.

  1. Compromised or malicious dependencies. A package or build tool executes code during installation and tries to steal secrets or alter the build output. Install scripts run with the same environment as your build.
  2. Untrusted contribution workflows. Pull request code runs with permissions or secrets it should never receive, because a workflow configuration treats untrusted code as trusted.
  3. Third-party CI components. An action, plugin, or container image is compromised — or referenced by a mutable tag that lets upstream changes flow silently into your builds.
  4. Poisoned pipeline configuration. An attacker edits workflow files so future runs exfiltrate credentials or tamper with artifacts. This is persistence: the infection survives every rebuild.
  5. Exposed or persistent runners. A self-hosted runner retains files, credentials, or state between jobs, letting one job steal what another job left behind.
  6. Artifact substitution. A build output gets replaced or modified between creation, storage, approval, and deployment.
  7. Overprivileged credentials. A token intended for one repository can publish packages or modify infrastructure across many projects.
  8. Build cache abuse. Shared or poorly isolated caches let one job read sensitive data or quietly influence another job’s build.

Notice the pattern: almost none of these involve breaking a cipher or exploiting a zero-day. They involve trust and configuration — code you allowed to run, permissions you granted too broadly, state you didn’t clean up.

Worth knowing through mid-2024, too: CI/CD incidents have increasingly shown indirect compromise, where a trusted service, package, or maintainer becomes a route into many downstream projects at once. Popularity is not a security property.

Why Secrets Are the Crown Jewels (And Why Masking Isn’t Enough)

Secrets are the highest-value target in any pipeline, because they’re the bridge between your build system and everything else you own. Long-lived tokens, cloud API keys, signing credentials, and environment variables all sit in the build environment waiting to be used — or misused.

Here’s the part many teams get wrong: most CI platforms offer secret masking, which replaces a secret’s value with asterisks in build logs. That’s a useful accident-prevention feature. It does nothing to stop malicious code from simply reading the environment variable and sending it somewhere else. Masking prevents display; it does not prevent access.

Imagine a compromised third-party action that adds one innocent-looking line to a build script — something that collects environment variables and posts them to an external endpoint. Every secret available to that job walks out the door, neatly logged nowhere.

The fix has two parts. First, don’t expose secrets to untrusted code at all — pull request builds from outside contributors should run without sensitive credentials, with separate restricted workflows for trusted maintainers. Second, prefer short-lived credentials over static ones. Workload identity federation and scoped, temporary tokens, which gained real traction through 2024, mean that even a leaked credential expires before it’s useful.

A secret exposed to untrusted code is a secret you should treat as compromised — masking only hides it from the logs, not from the attacker.

Hosted vs. Self-Hosted Runners: Which Risk Can You Actually Manage?

There is no universal answer to whether hosted or self-hosted runners are safer — the risk profile is different, not better. Hosted runners, provided by platforms like GitHub or GitLab, are typically ephemeral: each job gets a fresh machine that’s destroyed afterward. Self-hosted runners give you control over hardware, network, and tooling, but that control comes with maintenance obligations.

The dangerous middle ground is a persistent self-hosted runner that runs jobs from untrusted sources. It retains files, credentials, and state between jobs, and if it’s reachable from an untrusted network, you’ve combined the worst properties of both models.

PropertyHosted RunnersSelf-Hosted Runners
Isolation between jobsFresh machine per job (usually)Your responsibility; often persistent
Patching and maintenanceHandled by platformYour responsibility
Network exposureManaged by providerYou control — and you can get it wrong
Access to internal systemsLimited by designOften broad, on your internal network
Best fitPublic projects, untrusted PRsTrusted internal builds with isolation

Whatever you choose, the practical rules are the same: isolate runners between trust levels, use ephemeral runners where practical, avoid carrying state between jobs, and never run untrusted contribution code on a runner that also handles trusted releases. Neither model is automatically secure — security depends on isolation, permissions, and cleanup discipline.

How to Know What Your Artifact Really Contains

Your pipeline produces an artifact, and someone deploys it. Can you answer three questions about it: what source and dependencies produced it, which workflow and runner built it, and whether it was altered before deployment? If you can’t, you’re deploying on trust rather than evidence.

That evidence is called software provenance — a machine-readable record describing how an artifact was built and what inputs went into it. Through 2024, provenance and attestations became much more practical, driven by frameworks like NIST’s Secure Software Development Framework and SLSA, which push organizations to strengthen build integrity, provenance, and release controls.

But there’s an honest caveat: provenance is evidence, not proof of safety. A signed attestation that says “this artifact was built by workflow X from commit Y” is only as trustworthy as the systems that created and signed it. If your build process itself is compromised, the provenance record will faithfully document a malicious build. Reproducible builds and signed provenance improve confidence only when the build and signing processes are themselves protected.

The other half of the equation is protecting artifacts in transit and storage. Use access controls, integrity checks, signatures, and provenance records so that substitution between build, approval, and deployment gets caught rather than silently succeeding. Scan dependencies and build images too — while recognizing that scanning tells you about known vulnerabilities, not whether code is actually harmless.

Your First Weekend of Fixes: 6 Steps in Priority Order

You don’t need to fix everything at once. These six steps, roughly in order of impact-per-effort, will close the most common pipeline attack paths for a small or mid-sized team.

  1. Reduce token permissions. Cut the default permissions your workflows receive to read-only or none, then grant specific permissions per job. Separate build, publish, and deploy identities so one compromised step can’t do everything.
  2. Remove long-lived secrets. Audit what’s stored in your CI system and delete anything unused. Replace static cloud keys with short-lived, workload-based credentials where your platform supports it.
  3. Protect workflow changes. Require review for changes to pipeline definitions and release workflows. A poisoned workflow file is persistence — this is your chance to block it.
  4. Pin third-party components. Reference actions, plugins, and images by immutable revision (a full commit hash or digest), not a mutable tag, and update them through a controlled process.
  5. Lock down untrusted PR builds. Make sure pull requests from outside contributors run without secrets, in restricted workflows, on isolated runners.
  6. Log and alert. Monitor credential use, workflow changes, unusual runner behavior, and unexpected publishing or deployment activity.

Then — and this is the step teams skip — rehearse your response. Know how to revoke CI credentials, disable a compromised runner, invalidate artifacts, and trace a release back to its inputs before you need to do it at 2 a.m. during an incident.

Frequently Asked Questions

Can a pipeline compromise production without touching the production server?

Yes. If an attacker can alter a trusted build or deployment process, the pipeline publishes or deploys malicious output using your own legitimate credentials. The production server never needs to be breached directly — it receives the attacker’s code through the normal, trusted channel.

Should CI secrets be available to pull request builds?

Usually not. Builds that execute untrusted contributions should run without sensitive credentials, using separate workflows or restricted permissions. Grant credentials only after the code and workflow have passed the required trust checks — for example, after maintainer review and approval.

Does pinning an action or dependency make it safe?

No — pinning to an immutable revision makes unexpected upstream changes less likely to affect your build, but it doesn’t prove the pinned code is benign or vulnerability-free. You still need review when you pin it and a controlled process for updating it later.

Are hosted runners safer than self-hosted runners?

There’s no universal answer. Hosted runners reduce your maintenance burden and typically offer fresh machines per job; self-hosted runners give more control but demand strong isolation, patching, network restrictions, and cleanup. Security depends on practices, not the hosting model.

What are the first steps for a small team?

Start with reducing token permissions, removing unnecessary long-lived secrets, protecting workflow changes, isolating runners, and ensuring untrusted pull requests can’t access credentials. Then add artifact traceability and monitoring once the basics are covered.

How should a team respond to a suspected CI compromise?

Restrict or disable affected workflows and runners first, then revoke exposed credentials. Identify impacted artifacts and deployments, and determine which source, dependencies, and workflow runs were involved. Rebuild from a trusted state and rotate any credentials the compromised process could have reached.

Conclusion

If you remember one thing, make it this: whatever your pipeline can do, an attacker who compromises it can do too. Treat your CI system like the production system it is — least-privilege credentials, isolated runners, protected workflow definitions, and artifacts you can actually trace back to their source.

You don’t need to rebuild everything this week. Reduce token scopes, pull unused secrets, and protect workflow changes this weekend. That’s the security equivalent of locking the front door before worrying about the alarm system — and it stops the majority of real-world pipeline attacks before they start.

FALL

Fall Picks

As an affiliate, we earn on qualifying purchases.

You May Also Like

Cloud Security Basics for Teams Moving Too Fast

Learn practical cloud security basics for busy teams: safer access, private defaults, protected secrets, useful alerts, tested backups, and a first-week plan.

Scholarship application organizer for school counselors

A new scholarship application organizer for high school counselors is being tested to streamline tracking student applications, deadlines, and requirements.

What Misconfiguration Means in Cloud Security

Learn what cloud misconfiguration means, how common settings create risk, and how teams can spot and fix exposures safely.

Dependency Risk Explained for Product Teams

Learn how to identify, map, and reduce dependency risk before it derails your roadmap — a calm, practical guide for product teams.