Hardening CI/CD Pipelines: A Practical Checklist
Your build system holds the keys to production. A field-tested checklist for locking down CI/CD: secrets, runners, dependencies, permissions and the logs that show when someone gets in.
Attackers have noticed what defenders sometimes forget: a CI/CD system is a privileged automation platform with credentials for source code, cloud accounts, package registries and production. Compromise the pipeline and you don't need to break into production. The pipeline deploys for you.
This checklist is ordered by impact. Work top-down.
1. Credentials: short-lived and scoped
- Replace long-lived cloud keys with OIDC federation. GitHub Actions, GitLab and most CI platforms can exchange a signed job token for short-lived cloud credentials. No static secret to steal.
- Scope every credential to one job and one environment. The test job should never hold production deploy rights.
- Restrict who can trigger privileged workflows. Production deploys should require protected branches and environment approvals.
# GitHub Actions: least-privilege token + OIDC for cloud access
permissions:
contents: read
id-token: write # only for the job that exchanges OIDC for cloud credentials
jobs:
deploy:
environment: production # requires approval, holds production-only secrets
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::123456789012:role/deploy-prod
aws-region: ap-south-12. Untrusted code must not reach secrets
- Never run code from forks with access to secrets. Avoid
pull_request_targetworkflows that check out the PR's code. - Treat PR titles, branch names and issue text as untrusted input. Don't interpolate them directly into shell commands. Pass them through environment variables instead.
- Separate build from release. Build untrusted code in an unprivileged job, and release only signed artifacts from a protected one.
3. Dependencies and third-party actions
- Pin third-party actions to a full commit SHA, not a tag that can be moved.
- Use lockfiles and verify integrity (
npm ci,pip install --require-hashes). - Run dependency and secret scanning on every PR, and block merges on critical findings.
- Review new dependencies like you review code: who maintains it, how widely is it used, does it run install scripts?
4. Runners
- Prefer ephemeral runners that are destroyed after each job, so nothing persists between builds.
- Self-hosted runners must not serve public repositories. A malicious PR becomes code execution on your network.
- Isolate runners by trust level, and restrict their network egress to what builds actually need.
5. Artifacts and provenance
- Sign build artifacts and container images (for example with Sigstore cosign) and verify signatures before deploy.
- Generate an SBOM for each release, so you can answer "are we affected?" in minutes when the next big library vulnerability lands.
- Produce build provenance (SLSA) so you can prove an artifact came from your pipeline and your source.
6. Logging and detection
Forward CI platform audit logs to your SIEM and alert on:
- changes to workflow files on protected branches
- new or modified repository and organisation secrets
- new self-hosted runners or runner group changes
- disabled branch protection or required reviews
- deploy jobs triggered outside normal patterns (unusual time, user or branch)
Quick audit
| Check | Good looks like |
|---|---|
| Cloud credentials | OIDC, no static keys in secrets |
| Default token permissions | Read-only, elevated per job |
| Third-party actions | Pinned to commit SHA |
| Fork PRs | No access to secrets |
| Runners | Ephemeral, no self-hosted for public repos |
| Artifacts | Signed, with SBOM and provenance |
| Audit logs | In the SIEM, with alerts on the events above |
Further reading
Related research
A Stranger Can Reinstall Your Drupal Site: CVE-2026-132165 and the install.php Takeover
A critical flaw in Drupal's core installer lets an anonymous attacker re-trigger the setup flow on a live site and seize control, no login required. It was found by Anthropic's AI scanner, affects every supported branch, and Drupal warns exploits could come fast. Here's the risk and the fix.
Java4Shell (CVE-2026-114938): A Base64 Bug in the JVM That Reaches Jira, Jenkins and Keycloak
A memory-corruption bug in the JVM's accelerated Base64 decoder means any Java application that decodes attacker-controlled Base64 (which is nearly all of them) could be exploitable, with researchers demonstrating pre-auth RCE against Jira, Jenkins, Keycloak and others. Here's the blast radius and how to triage it.
OptimJack: How One Compromised A/B-Testing Platform Served Malware From CNN, BBC and HSBC
For about a day, visitors to some of the world's biggest websites were served crypto-stealing, card-skimming malware, loaded from Optimizely's own trusted CDN. One flaw in an A/B-testing vendor put 178 organisations at risk at once. A full analysis of the attack, why it is so hard to spot, and the controls that stop it.