CI Secret Injection

Secrets in CI. The patterns.

The secret injection problem

CI needs secrets and mishandled secrets leak in predictable ways: build logs, environment dumps, build artifacts. The discipline is injecting at runtime from a vault and never storing plaintext in the repo or CI config.

Vault-backed secrets

Vault-backed secrets are the standard. OIDC for cloud-issued tokens removes long-lived credentials from CI; secrets managers cover stored credentials that cannot be issued on demand.

Scope and rotation

Scope and rotation limit blast radius. Minimum permissions per pipeline rather than a shared mega-token, quarterly rotation cadence, access audit so leak investigation is possible.

Avoid leaking in logs

Logs are the most common leak path. Mask known patterns, avoid set -x in shell scripts that handle secrets, run pre-commit scanners to catch secrets before they reach CI.

How to migrate

Migration is staged. Inventory current secrets, roll out OIDC plus secrets manager pipeline-by-pipeline, track retirement of static secrets against a deadline.