All Articles

CI/CD Credential Security Best Practices: Protect Pipeline Secrets

Secure CI/CD credentials with least privilege, OIDC, secret scoping, rotation, and incident response checklists for GitHub, GitLab, and cloud pipelines.

9 min read
2024-11-29
CI/CDDevSecOpsPipeline Security

Why CI/CD Secrets Are High Risk

Pipelines can deploy code, modify infrastructure, and access production data. A leaked token in CI/CD often has broad blast radius and can be exploited quickly.

Most Common Secret Types

  • Cloud access credentials and role tokens
  • Container registry credentials
  • Database migration users
  • Third-party API keys and webhooks

Secure-by-Default Design

  1. Prefer short-lived credentials over static keys
  2. Use OIDC/workload identity for cloud auth when possible
  3. Scope secrets by environment (dev/stage/prod)
  4. Restrict secret access to required jobs only
  5. Mask and redact logs

Platform Controls You Should Enable

GitHub Actions

  • Environment protection rules for production
  • Required reviewers before deploy jobs
  • Secret scanning and push protection

GitLab CI/CD

  • Protected + masked variables
  • Environment-scoped variables
  • Protected branches/tags for release pipelines

Rotation Workflow (Low Downtime)

  1. Create new key/token
  2. Add to CI/CD platform and validate in staging
  3. Deploy with new credential in production
  4. Monitor failures and rollback path
  5. Revoke old credential

Leak Prevention Checklist

  • Pre-commit secret scanning
  • Repository-level secret scanning
  • No plaintext secrets in build artifacts
  • No secret echo in logs/debug output

Incident Response (If a Secret Leaks)

  1. Revoke compromised secret immediately
  2. Issue replacement with least privilege
  3. Re-run affected deployments safely
  4. Audit access logs and scope impact
  5. Add prevention control for recurrence

Minimum Secure Baseline (Start Here)

  1. Enable secret scanning and push protection
  2. Use environment-scoped secrets (dev/stage/prod)
  3. Prefer OIDC/short-lived cloud credentials
  4. Restrict deploy jobs with approvals
  5. Rotate high-risk secrets every 60–90 days

Where LockPulse Fits

If your team uses LockPulse, keep a structured inventory of pipeline secrets, ownership, and rotation history there, then sync scoped values into your CI/CD provider.

Related: developer credential workflows and GitHub token security.

Secure Your Team's Credentials with LockPulse

Organize credentials by project, share securely with your team, and maintain complete control with zero-knowledge encryption.