Securing your CI/CD pipeline: the supply-chain risks small teams overlook

A CI/CD pipeline is the most privileged system most small companies have and the least protected. It can read the source code, holds credentials for the cloud account, the container registry and the production servers, and runs code from dozens of third-party actions and packages on every push. An attacker who controls the pipeline does not need to break into production: the pipeline deploys for them.
How pipelines get compromised
- A compromised third-party action or plugin. In March 2025 the popular GitHub Action
tj-actions/changed-fileswas modified so that it printed CI secrets into build logs, and every repository referencing it by a moving tag ran the malicious version. - Malicious pull requests. Workflows triggered by
pull_request_targetthat check out and run code from a fork give that code access to repository secrets. - Over-privileged tokens. A job that only runs tests but has write access to the repository and packages turns any compromised step into a push to
main. - Long-lived cloud keys stored as CI secrets, valid for years and shared by every workflow.
- Poisoned dependencies: typosquatted packages, hijacked maintainer accounts, or install scripts that run during
npm install. - Shared or persistent runners where one job can leave something behind for the next.
Ten controls that matter most
1. Pin third-party actions to a full commit SHA
Tags like @v4 can be moved by whoever controls the action. A commit SHA cannot.
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Dependabot and Renovate understand this format and will propose updates with the version in the comment.
2. Default the token to read-only
permissions:
contents: read
jobs:
deploy:
permissions:
contents: read
id-token: write # only for the job that needs OIDC
Set the organisation default for GITHUB_TOKEN to read-only and grant write permissions per job.
3. Replace stored cloud keys with OIDC
GitHub Actions and GitLab CI can exchange a signed identity token for short-lived cloud credentials in AWS, Azure and Google Cloud. Restrict the trust policy to a specific repository and branch or environment, for example only refs/heads/main of one repository may assume the production deploy role. A leaked log then contains nothing reusable.
4. Separate build from deploy
Jobs that run on every pull request should have no production secrets at all. Put production credentials in a protected environment that only the main branch can use, with required reviewers if you deploy manually.
5. Treat untrusted code as untrusted
Never check out and run a fork’s code in pull_request_target or similar privileged triggers. Do not interpolate PR titles, branch names or issue text directly into shell commands (run: echo "${{ github.event.pull_request.title }}" is a command injection); pass them through environment variables instead.
6. Protect the branches and the pipeline definition
Require pull requests and at least one review for main, block force pushes, and use CODEOWNERS so that changes to .github/workflows/ or .gitlab-ci.yml need approval from someone responsible for security. Changing the pipeline is changing who can deploy.
7. Isolate runners
Prefer ephemeral, hosted runners. Self-hosted runners should be single-use or at least dedicated per trust level, never attached to public repositories, and never on the same machine as production. A runner with the Docker socket mounted is effectively root on its host.
8. Control dependencies
- Commit lock files and install with
npm ci,pip install --require-hashesor equivalent, so builds use exactly the reviewed versions. - Automate dependency updates and review them like any other change.
- Scan dependencies and images for known vulnerabilities in the pipeline, and fail the build on critical findings that have a fix.
9. Scan for secrets on every push
A secret scanner in CI and push protection on the platform stop the most common leak before it spreads. See our guide to secrets management.
10. Sign and trace what you deploy
Generate build provenance (GitHub artifact attestations, SLSA provenance) and sign container images with Sigstore cosign. Deploy only images built by your pipeline, referenced by digest. This makes it possible to prove what is running in production and where it came from.
Monitor the pipeline itself
Review the audit log for new deploy keys, new secrets, changed branch protection and new self-hosted runners. These events are rare in a small team, so any unexpected one deserves a question.
Our take
If you do only three things this month: pin actions by SHA, set token permissions to read-only by default, and replace stored cloud keys with OIDC. Together they close the paths used in most real pipeline compromises we have read about, and none of them requires a new tool or budget. The deeper controls (provenance, signing, isolated runners) become important once you deploy often or serve customers who ask about supply-chain security, as NIS2 suppliers increasingly are.
Want your pipeline reviewed?
Pipeline hardening is part of our DevOps plans. See pricing or ask for the free IT audit.


