CI/CD Security: Beyond the Basics
A practical CI/CD security checklist: identity, secrets, provenance, approvals, and hardening to reduce software supply chain risk.
Modern incidents increasingly start in build and deployment systems: stolen CI tokens, malicious dependency updates, compromised runners, or unauthorized workflow edits. “Secure CI/CD” isn’t a single tool—it’s control over how code becomes production, with strong identity, minimal privileges, and verifiable artifacts.
This guide lays out a pragmatic approach you can implement iteratively (without turning your pipeline into a bureaucracy).
What “secure CI/CD” actually means
Secure CI/CD is less about adding scanners and more about controlling how code becomes production:
- Strong identity for humans and machines
- Least-privileged credentials and short-lived tokens
- Provenance and artifact integrity
- Controlled promotions and rollbacks
- Auditability: who changed what, who approved, and what shipped
Start with a threat model (30 minutes)
Before changing tooling, align on the most common pipeline threats:
- Credential theft: a token leaked in logs, PR comments, artifacts, or runner filesystem
- Workflow manipulation: a PR modifies the pipeline to exfiltrate secrets
- Compromised runner: shared runners with persistent state or unpatched dependencies
- Dependency supply chain: malicious package versions or typosquatting
- Artifact tampering: “what got built” differs from “what got deployed”
Your goal is to reduce blast radius and increase trustworthiness of releases.
High-impact quick wins (most teams can do these this week)
1) Lock down secrets: eliminate long-lived keys in CI
Long-lived cloud keys (or shared tokens) are one of the highest-risk patterns.
- Prefer OIDC + short-lived role/session tokens over static keys
- Scope credentials to one environment (staging vs production)
- Rotate secrets and log access; audit who can read them
- Ensure forks and untrusted PRs cannot access secrets
2) Require reviews for workflow changes
Your pipeline is production code. Treat it that way:
- Require CODEOWNERS / reviews for
.github/workflows/*(or equivalent) - Restrict who can approve workflow modifications
- Disallow “self-approval” on sensitive repos
3) Pin and verify third-party actions and dependencies
If you use GitHub Actions (or similar):
- Pin actions by commit SHA, not floating tags
- Audit high-privilege steps (cloud auth, deploy, signing)
- Prefer official actions with clear maintenance signals
4) Harden the runner
Runners are a common blind spot:
- Use ephemeral runners where possible (new instance per job)
- Minimize installed tools and keep images patched
- Prevent “secret sprawl” in workspace directories
- Don’t mount broad credentials into the runner filesystem
5) Add environment protections and promotion rules
Make it hard to accidentally ship the wrong thing:
- Separate build from deploy
- Add approvals for production deployments where appropriate
- Require checks before deploy (tests, scans, policy)
- Use rollbacks that are routine, not “break-glass improvisation”
The deeper layer: integrity and provenance (why scanners aren’t enough)
Scanning is useful, but scanners don’t guarantee what ran in CI is what got deployed.
Provenance
Provenance answers: “What source produced this artifact, and how?”
- Record commit SHA, build inputs, dependency lockfiles, builder identity
- Store provenance with the artifact (or in an attestation system)
Artifact integrity
Integrity answers: “Has the artifact been tampered with?”
- Sign container images and verify signatures at deploy time
- Ensure promotion uses the same artifact across environments (no rebuilds)
If you’re pursuing enterprise readiness, these controls also support auditability and compliance expectations.
A practical CI/CD security checklist (use this as your roadmap)
Identity & access
- Enforce SSO and MFA for source control
- Separate human vs machine identities
- Restrict who can create/modify secrets
- Use least-privilege roles per environment
Secrets management
- No static cloud keys in CI (prefer OIDC)
- Secret access requires review and is audited
- Secrets are never printed in logs or exposed to forks
Supply chain hygiene
- Dependency lockfiles are required and reviewed
- Actions/dependencies are pinned and periodically reviewed
- Automated dependency updates have guardrails (tests + approvals)
Build and release integrity
- Build produces a single immutable artifact
- Artifact is promoted between environments (no rebuild)
- Sign and verify artifacts (or equivalent integrity gates)
Change control
- Workflow and infra changes require reviews
- Production deploys require explicit approvals and checks
- Rollback path is tested and documented
Common failure modes (what to watch for)
- “We added scanners, we’re secure.” Scanners are inputs; security is an operating system.
- Wide CI tokens that can write to repos, create releases, or mint cloud roles broadly.
- Shared, long-lived runners with persistent state across jobs.
- Manual deployment steps that bypass checks during “urgent” moments.
If you want a hardened pipeline end-to-end
If you want a hardened pipeline with reliable promotions and rollbacks, see CI/CD Setup & Hardening. We typically start with threat modeling and quick wins, then implement integrity/provenance controls that match your stage and compliance needs.
Need help with this?
We help engineering teams implement these practices in production—without unnecessary complexity.
No prep required. We'll share a plan within 48 hours.
Book a 20-minute discovery call