Threat model your delivery path
Think of CI/CD as a supply chain. If one step is weak, attackers can inject compromised code.
- Source control and branch protections.
- Build runner hardening.
- Dependency and container image trust.
- Artifact signing and provenance.
- Deployment approvals and environment controls.
Minimum secure pipeline controls
- No direct push to main branch.
- Mandatory code review and status checks.
- Secret scanning, SAST, and dependency scanning in CI.
- Infrastructure policy checks before apply.
- Immutable versioned artifacts promoted across environments.
- Short-lived credentials with OIDC/workload identity.
- Production deployment approvals for high-risk changes.
Practical release flow
- Developer opens PR with small change set.
- CI runs tests, lint, security, policy checks.
- Build generates signed artifact.
- Artifact promoted from dev to staging to prod.
- Post-deploy checks validate health and rollback readiness.
Common anti-patterns
- Long-lived static cloud keys in pipeline settings.
- Using mutable tags like latest in production deploys.
- Skipping staging parity with production.
- No audit trail for who approved critical releases.
- Manual hotfixes outside pipeline controls.
Metrics to track
- Change failure rate by service.
- Mean time to rollback.
- Pipeline failure reasons by category.
- Security gate pass/fail trend.
- Time from commit to production.
FAQ
Will security gates slow us down?
Initially slightly, but they prevent expensive failures and rework later.
Do we need release approvals for every service?
Use risk-based controls. Critical services should have tighter checks.
Should infra and app pipelines be separate?
They can be separate but should share policy and audit standards.
What is the first upgrade to make?
Replace long-lived credentials with workload identity and enforce branch protection.
Next action
Run a CI/CD security baseline assessment and close the top three control gaps first.