CI/CD pipeline security: 10 risks, with an attack for each
A build pipeline can read your source, holds your deploy credentials, and produces the thing production trusts. That is why CI/CD pipeline security is its own problem. The application code can be clean and the pipeline can still ship a backdoor, leak a cloud key, or deploy a commit nobody reviewed.
The best map of this attack surface is the OWASP Top 10 CI/CD Security Risks. This guide takes each risk in turn: what it is, an attack that exploits it, how to detect it and how to fix it, with real incidents linked to their primary sources.
The examples use GitHub Actions syntax. Our labs run on Gitea Actions, which is designed to be compatible with it.
The OWASP Top 10 CI/CD security risks at a glance
| ID | Risk | The attack in one line |
|---|---|---|
| CICD-SEC-1 | Insufficient flow control mechanisms | Push code to production without a second person seeing it |
| CICD-SEC-2 | Inadequate identity and access management | Use a stale or over-scoped token nobody remembers issuing |
| CICD-SEC-3 | Dependency chain abuse | Get the build to install your package instead of the real one |
| CICD-SEC-4 | Poisoned pipeline execution | Change what the pipeline runs, and let it run with its secrets |
| CICD-SEC-5 | Insufficient pipeline-based access controls | Turn one compromised step into access to everything the job can reach |
| CICD-SEC-6 | Insufficient credential hygiene | Find secrets in git history, build logs and image layers |
| CICD-SEC-7 | Insecure system configuration | Go from a low-privilege CI login to code execution on the server |
| CICD-SEC-8 | Ungoverned usage of third-party services | Compromise an action or integration that many pipelines trust |
| CICD-SEC-9 | Improper artifact integrity validation | Swap the artifact between build and deploy |
| CICD-SEC-10 | Insufficient logging and visibility | Do all of the above without an alert firing |
CICD-SEC-1: Insufficient flow control mechanisms
What it is. OWASP describes this as an attacker with access to source control, CI or an artifact repository being able to push code or artifacts all the way to production, because no step in the flow forces an independent review or approval.
The attack. The main branch is protected and needs a review. But a release/* branch also triggers the deploy workflow, and it has no protection rule. An attacker with an ordinary developer token pushes there and the pipeline deploys it. Auto-merge rules with weak criteria and users exempt from protection open the same path.
A real case: on 28 March 2021, two malicious commits were pushed to php-src on PHP's self-hosted git server, under the names of two core developers. They went straight onto the main branch with no review step in between. The project shut the server down and made its GitHub repositories canonical.
How to detect it. List every branch and tag pattern that can trigger a deploy and compare it with your protection rules. Alert on direct pushes to protected branches, on admin bypasses, and on any change to the protection rules themselves. Compare what runs in production with what the pipeline last deployed.
How to fix it. Protect every branch that feeds production, with no exempt users. Require a reviewer other than the author. Allow only artifacts built by the CI service identity to move toward production.
Lab: Bypass branch protection and merge unreviewed code.
CICD-SEC-2: Inadequate identity and access management
What it is. A pipeline spans many systems, each with its own human accounts, service accounts, bots, deploy keys and tokens. OWASP groups the failures into identities that are overly permissive, stale, local to one system, external, self-registered or shared.
The attack. A contractor left a year ago. Their personal access token still works and can write to every repository in the organisation. Whoever finds it in an old backup or a leaked dotfile can push a tag that starts a release. Bots follow the same pattern: an integration that only comments on pull requests but holds a write token.
How to detect it. Inventory every identity and token across source control, CI and registries, with scopes and last-used date. Flag tokens with no expiry, idle accounts, open self-registration and outside email domains.
How to fix it. Put every system behind your identity provider and remove local accounts. Issue fine-grained tokens with an expiry. Replace shared accounts with one identity per purpose. Remove access when the work ends, not at the next audit.
Lab: Over-privileged tokens and deploy keys: from read access to release.
CICD-SEC-3: Dependency chain abuse
What it is. In OWASP's words, this is "an attacker's ability to abuse flaws relating to how engineering workstations and build environments fetch code dependencies." The main techniques are dependency confusion, hijacked maintainer accounts, typosquatting and brandjacking.
The attack. In February 2021 Alex Birsan published Dependency Confusion: How I Hacked Into Apple, Microsoft and Dozens of Other Companies: he registered internal package names on public registries, and builds pulled his versions instead of the private ones.
The same thing hit PyTorch. Between 25 and 30 December 2022, PyTorch-nightly installs on Linux pulled a malicious torchtriton from PyPI instead of from PyTorch's own index, because the PyPI index took precedence. Its binary collected environment variables, files from ~/.ssh and other data, and sent them out over DNS.
CVE-2024-3094 is the compromised-upstream case: malicious code in the official xz tarballs from version 5.6.0, extracted from a disguised test file during the liblzma build.
How to detect it. Review lockfile changes in every pull request. For each internal package name, check whether the same name exists on the public registry. Watch for install scripts that make network calls during the build.
How to fix it. Route all package downloads through an internal proxy. Use scoped names for private packages and bind each scope to your registry. Commit lockfiles and pin versions with hashes. Run install steps in a job that holds no secrets.
Lab: Dependency confusion against a private package index.
CICD-SEC-4: Poisoned pipeline execution (PPE)
What it is. OWASP defines PPE as the ability of an attacker with access to source control, but not to the build environment, to inject commands that the pipeline then runs with its own identity. It comes in three forms: direct (edit the CI configuration), indirect (edit a file the configuration runs, such as a Makefile) and public (the same thing, from an anonymous fork of a public repository).
The attack. The most common shape in GitHub Actions is a privileged trigger running untrusted code:
on: pull_request_target # runs with the base repository's secrets
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }} # the PR author's code
- run: make test # the PR author's Makefile
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
Whoever opens the pull request controls the Makefile, and the Makefile runs with the deploy key in its environment. GitHub Security Lab described this pattern in 2021 as a "pwn request".
In December 2024 the Ultralytics Python package was compromised through its GitHub Actions workflows. PyPI's analysis lists versions 8.3.41, 8.3.42, 8.3.45 and 8.3.46 as affected and says the attack targeted the GitHub Actions cache used during the build. William Woodruff's write-up traces the entry point to a pull_request_target workflow and a shell step that expanded the branch name unquoted.
How to detect it. Search your workflows for pull_request_target and workflow_run, for checkouts of the pull request head, and for ${{ github.event... }} expressions inside run: blocks. Check which workflows can see secrets when the trigger comes from a branch or a fork.
How to fix it. Build untrusted code with the plain pull_request trigger, with no secrets. Keep anything that needs credentials in a separate job that only runs after merge. Pass untrusted values through environment variables, never straight into a script. GitHub is also tightening the default: from 2 December 2026, pull_request_target is blocked by default in public repositories unless an Actions event policy allows it. For the full breakdown, read poisoned pipeline execution: direct, indirect and public.
Lab: Steal a deploy secret from a pull request, in 30 minutes. It is free.
CICD-SEC-5: Insufficient pipeline-based access controls (PBAC)
What it is. A pipeline job can reach the source, the secrets, the network and often the cloud. OWASP's point is that each pipeline, and each step inside it, should get only the access it needs. When it gets more, one compromised step becomes a path to everything the job can touch.
The attack. Between 31 January and 1 April 2021, Codecov's Bash Uploader was modified. The altered script sent git remote information and environment variables from customers' CI runs to an external server. A coverage upload needs none of a pipeline's deploy credentials, but the script ran wherever the pipeline called it, with that job's full environment.
How to detect it. For every job, compare the secrets and permissions it can access with what it uses. Look for runners shared across trust levels and build jobs with open outbound access.
How to fix it. Scope secrets to the job that uses them, give the job token the least permission, and keep deploy credentials behind a protected environment:
permissions:
contents: read # default for every job in this workflow
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: make test # no secrets here
deploy:
needs: test
if: github.ref == 'refs/heads/main'
environment: production # deploy secrets live here, behind its protection rules
runs-on: ubuntu-latest
steps:
- run: ./deploy.sh
Gitea Actions ignores jobs.<job_id>.environment, so there the separation comes from separate repositories, runners or secret scopes.
Lab: Pipeline-based access control: a build job that should never reach production.
CICD-SEC-6: Insufficient credential hygiene
What it is. OWASP describes this as "an attacker's ability to obtain and use various secrets and tokens" spread through the pipeline, because of weak access control around them, insecure storage, or credentials that are too broad and live too long.
The attack. A key was committed and then deleted, but it is still in the git history. A build argument carried a token into a container image, and it is still in a layer. A step printed a secret in a transformed form, so log masking missed it. Codecov says its attacker got in "because of an error in Codecov's Docker image creation process that allowed the actor to extract the credential" needed to modify the script.
How to detect it. Scan the full git history, not just the current tree. Scan image layers and old build logs. Keep an inventory of long-lived keys with their age and owner.
How to fix it. Stop storing long-lived cloud keys in CI. GitHub's guidance is that OpenID Connect lets a workflow "create short-lived, well-scoped access tokens" instead. Where a static secret is unavoidable, rotate it on a schedule and restrict where it can be used. Block secrets at commit and push time, and use build secrets rather than build arguments in container builds.
Lab: Dig secrets out of git history, build logs and image layers.
CICD-SEC-7: Insecure system configuration
What it is. Source control servers, CI servers, runners and registries each have their own security settings. OWASP covers outdated components, default configurations, over-broad network access and systems running with admin rights on the host.
The attack. Jenkins is the classic case. Its own documentation calls the script console "a web-based Groovy shell into the Jenkins runtime" that "can disable security, reconfigure security, even open a backdoor on the host operating system." Access needs the Administer permission, so any authorisation gap that grants it means code execution on the controller and every credential it stores.
Self-hosted runners are the other common gap. GitHub says they "should almost never be used for public repositories". A runner that is not reset between jobs lets one job leave something behind for the next.
How to detect it. Inventory each system with its version and owner, and check it against vendor advisories. Review who holds admin-level permissions. Check whether runners persist between jobs and what they can reach on the network.
How to fix it. Patch, and manage configuration as code so it can be reviewed. Run builds on agents, not on the controller. Use ephemeral runners, restrict their network access, and never run the CI service as root.
Lab: From a login to code execution through the script console.
CICD-SEC-8: Ungoverned usage of third-party services
What it is. Third parties connect through apps, OAuth grants, tokens, SSH keys, webhooks, and actions or plugins added with one line of configuration. OWASP's concern is that this takes seconds, often needs no approval, and runs with the pipeline's access.
The attack. In March 2025 the tj-actions/changed-files action was compromised. Per CVE-2025-30066, tags v1 through v45.0.7 were modified on 14 and 15 March to point at a malicious commit. The GitHub advisory says the code scanned the runner's memory for secrets, base64-encoded them and wrote them to build logs. Workflows that referenced those tags ran it. A related compromise of reviewdog/action-setup@v1 on 11 March is tracked as CVE-2025-30154.
How to detect it. List every third-party action, plugin, app and webhook, with its permissions. Flag actions referenced by tag or branch instead of by commit.
How to fix it. GitHub's guidance is to "pin references to actions to a commit SHA", because "a tag can be moved or deleted" by whoever gains access to the action's repository:
# a tag can be moved
- uses: some-org/some-action@v4
# a full commit SHA cannot
- uses: some-org/some-action@<full-40-character-commit-sha> # v4.2.1
Keep an allow-list of approved actions, review app permissions, remove integrations nobody uses, and verify signatures on incoming webhooks.
Lab: Webhooks and integrations: forge an event, then validate signatures.
CICD-SEC-9: Improper artifact integrity validation
What it is. OWASP describes an attacker with access to any one system in the pipeline being able to push "malicious (although seemingly benign) code or artifacts down the pipeline" because nothing validates code and artifacts along the way.
The attack. SolarWinds is the reference case. CrowdStrike's analysis of the SUNSPOT implant shows it watched for Orion builds and replaced one source file with a version containing the SUNBURST backdoor, then restored the original after the build. The source repository stayed clean, and the product that shipped contained the backdoor.
Codecov's compromise was found the other way round: a customer's checksum of the downloaded uploader did not match the one published on GitHub.
How to detect it. At deploy time, check that the artifact's digest matches what CI produced and that it carries a valid signature from your pipeline's identity. Verify the hash of every script or binary a build downloads.
How to fix it. Sign artifacts when they are built and verify the signature before every later step uses them. Generate provenance that records which pipeline built what, following SLSA. Stop piping downloaded scripts straight into a shell without checking a published hash.
Lab: Sign images and verify before deploy with cosign.
CICD-SEC-10: Insufficient logging and visibility
What it is. OWASP describes an adversary carrying out malicious activity in the CI/CD environment "without being detected during any phase of the attack kill chain." Much of that activity uses programmatic access, which is often the least monitored.
The attack. Every attack above can run through APIs with a token: change a protection rule, add a deploy key, upload an artifact. If the Git server's audit log was never enabled, or never leaves the server, none of it is seen.
The tj-actions compromise is the counter-example. The GitHub advisory says it "was detected by StepSecurity when anomaly detection flagged an unauthorized outbound network call." A baseline of where your runners normally connect is enough to catch a build that phones home.
How to detect it. Inventory every CI/CD system, including registries and CD tools. Turn on audit and application logs, which are often off by default, and send them to one place.
How to fix it. Alert on changes to branch protection, new tokens and deploy keys, new third-party apps, edits to workflow files, and outbound connections from runners to hosts they have never contacted.
Lab: Audit logs for the Git server and CI: what to keep and what to alert on.
CI/CD security best practices that cover several risks at once
Most of the fixes above reduce to a short list:
- Protect every branch that can deploy, with no exemptions (SEC-1).
- Give each identity and token an owner, a scope and an expiry (SEC-2).
- Pin dependencies and actions to hashes or commits, through a proxy you control (SEC-3, SEC-8).
- Never run code from a pull request in a job that holds secrets (SEC-4, SEC-5).
- Replace long-lived cloud keys with short-lived credentials from the job's identity (SEC-6).
- Use ephemeral runners with restricted network access (SEC-5, SEC-7).
- Sign what you build and verify it before you deploy (SEC-9).
- Send audit logs from every pipeline system to one place, and alert on changes to trust (SEC-10).
A one-page version, with a check per risk, is in our CI/CD pipeline hardening checklist.
Practise each attack on a real pipeline
Every risk above maps to a lab in DevSecOps: CI/CD Pipeline Security. You attack a working Git server and CI runner in your browser, then rebuild the pipeline so the same attack fails. The first labs are free to start.
Learn it by breaking it
Hands-on DevSecOps labs launch 12 January 2027, with the first two modules free.