LOOP · The DevOps Codex
Ch 17 · Secrets Management
Chapter 17 · Identity, Keys & Tokens

Secrets Management — the credentials that move the cloud

Every breach post-mortem of the last decade ends the same way: a leaked credential. This chapter is the full taxonomy of secrets, the stores that hold them, the patterns that distribute them safely to Kubernetes and CI, the OIDC federation that lets you delete long-lived keys altogether, and the rotation discipline that keeps a small mistake from becoming a front-page incident.

17.1 · The secret-leak problem

Definition. A secret is any piece of data whose disclosure grants an attacker capability — an API key, a database password, a private key, a session token. The Verizon DBIR has placed stolen or leaked credentials as the #1 initial-access vector for several consecutive years, ahead of phishing and software vulnerabilities. GitHub's own scanning identifies millions of exposed secrets per year in public repositories.

The blast radius
A single AWS root access key in a public commit can be discovered, used to spin Bitcoin miners, and burn a six-figure bill in under five minutes. Once a secret hits Git history, treat it as compromised forever — rotate, do not just delete.
Defence layerToolWhat it catches
Pre-commit (local)gitleaks, trufflehog, detect-secrets (Yelp)Stops the commit on the developer laptop.
Push-time (server)GitHub push-protection (free since 2024), GitLab Secret Detection, Bitbucket Secret ScannerRejects the push if a known secret pattern is detected.
Repo scan (continuous)GitHub Advanced Security, GitLab Ultimate, Snyk Code, Spectral (Check Point)Sweeps full history, including forks.
Partner alertsAWS, Stripe, Slack, OpenAI, Anthropic, Twilio post tokens to GitHub Secret Scanning Partner ProgramAuto-revokes leaked tokens within minutes.

17.2 · Secret types — the full taxonomy

API keys

Long-lived bearer tokens for SaaS APIs (Stripe, SendGrid, OpenAI). Should be scoped, named, and rotatable.

Database passwords

Postgres, MySQL, Mongo, Redis. Prefer dynamic (Vault) or IAM auth (RDS IAM, Cloud SQL IAM).

OAuth tokens

Refresh + access pairs for Google, Microsoft, GitHub apps. Refresh tokens are the crown jewel.

Signing keys

GPG (commits, packages), SSH host keys, JWT signing keys, container signing (Sigstore).

Cloud credentials

AWS access keys, GCP service-account JSONs, Azure SP secrets. The single biggest leak source — replace with OIDC federation (§17.7).

Encryption keys

KEKs and DEKs (envelope encryption). Stored in KMS (AWS KMS, GCP KMS, Azure Key Vault, HSM-backed).

X.509 certificates

TLS server certs, mTLS client certs, code-signing certs. Issued by ACME (Let's Encrypt), private CA, or Venafi.

SSH host & user keys

Per-host keypairs and per-user keys; SSH certificates (Vault SSH, Teleport, Smallstep) replace static authorized_keys.

17.3 · Vault stores — the full comparison

A secrets manager is a hardened, API-driven store that holds secrets at rest (always encrypted), authenticates clients, and emits an audit trail. Pick one as the central authority; everything else (K8s, CI) federates to it.

ProductVendorHostingStandout features
HashiCorp VaultHashiCorp (IBM, 2025)Self-host (OSS / Enterprise) or HCP Vault SaaSDynamic secrets, PKI engine, transit (encryption-as-a-service), 30+ auth methods. BUSL-licensed since Aug 2023; OpenBao is the LF fork.
AWS Secrets ManagerAWSSaaSNative rotation lambdas for RDS / Redshift / DocumentDB. ~$0.40 / secret / month.
AWS SSM Parameter StoreAWSSaaSFree standard tier; KMS-encrypted SecureString; cheap for thousands of params.
GCP Secret ManagerGoogle CloudSaaSVersioned, IAM-scoped, region-replicated; integrates with Workload Identity.
Azure Key VaultMicrosoftSaaSSecrets + keys + certificates in one. HSM-backed Premium tier (FIPS 140-2 L3).
AkeylessAkeylessSaaS (DFC patent — no master key)Multi-cloud, K8s, just-in-time; popular Vault alternative since the relicense.
1Password Secrets Automation1PasswordSaaSLoved by smaller teams already on 1Password; op CLI integrates with K8s, GH Actions.
DopplerDopplerSaaSDeveloper-first UX; environment promotion (dev → stg → prod) as a primary concept.
InfisicalInfisical (OSS)Self-host or SaaSOpen-source contender; e2e-encrypted; great K8s operator.
Bitwarden Secrets ManagerBitwardenSelf-host or SaaSSame vault as the password manager; cheap per-user pricing.
CyberArk ConjurCyberArkSelf-host (OSS + Enterprise)Enterprise PAM heritage; strong RBAC; common in finance & gov.

17.4 · Encryption-at-rest helpers (for Git)

Some teams want secrets to live alongside code in Git — versioned, code-reviewed, GitOps-friendly — without being readable. These tools encrypt files in place with keys held in KMS or PGP.

ToolOriginPattern
SOPSMozilla (2017), now CNCF SandboxEncrypts only values in YAML/JSON/ENV, leaves keys readable. Backends: AWS KMS, GCP KMS, Azure KV, age, PGP, HashiCorp Vault.
ageFilippo Valsorda (2019)Simple, modern PGP replacement. Tiny binary, single-line key.
Sealed SecretsBitnami → Argo ProjectCluster-side controller decrypts SealedSecret CRDs into native Secrets. Keys are cluster-scoped.
KSOPSViaduct (kustomize plugin)SOPS-aware kustomize generator; powers SOPS-in-Argo workflows.
git-cryptAGWA (2013)Transparent encryption on Git push/pull via .gitattributes. Simple, but no per-file ACL.
Rule of thumb
SOPS + KMS for GitOps repos. External Secrets Operator (next section) for runtime. Never roll your own encryption.

17.5 · Kubernetes secret patterns

The native Secret object is base64-encoded, not encrypted, by default. Worse, it lives plaintext in etcd unless you enable EncryptionConfiguration with a KMS provider. Five mainstream patterns close this gap.

central vault HashiCorp Vault AWS Secrets Mgr GCP / Azure KV sync layer External Secrets Operator Secrets Store CSI Vault Agent Injector workload native Secret volume mount env vars (avoid)
PatternHow it worksBest for
Native Secret + etcd KMSTurn on EncryptionConfiguration with cloud KMS provider so etcd ciphertexts are wrapped.Baseline — always do this. Insufficient alone.
External Secrets Operator (ESO)Operator reads from Vault / AWS SM / GCP SM / Azure KV / Akeyless / 1Password and materialises native Secrets. Most popular pattern in 2026.Multi-cloud, GitOps-friendly.
Sealed SecretsEncrypt at desk → commit ciphertext → cluster controller decrypts.Pure-GitOps teams without a central vault.
Secrets Store CSI DriverMounts secrets as files via CSI; provider plugins for AWS, GCP, Azure, Vault.Workloads that need fresh-on-pod-start material; cert/file material.
Vault Agent Sidecar / InjectorMutating webhook injects sidecar; sidecar logs into Vault with K8s ServiceAccount JWT, writes templated files to a shared volume.Vault-centric shops; dynamic creds; on-the-fly templating.

17.6 · Dynamic secrets — Vault's flagship

Definition. A dynamic secret is generated on demand, scoped to a single consumer, and automatically revoked after a TTL. There is no long-lived shared password to leak. Vault pioneered this for databases (Postgres, MySQL, Mongo), cloud (AWS STS, GCP, Azure), SSH (OTP / signed certs), and PKI (short-lived TLS certs).

app requests creds
→
Vault DB engine
→
CREATE USER tmp_ab12…
→
15-min lease
  • Lease — every dynamic secret carries a TTL and a max-TTL. The app renews until done; Vault revokes (DROP USER, delete IAM key) on expiry.
  • Just-in-time — humans can vault read database/creds/readonly and get a 1-hour Postgres login; no shared root password ever leaves the vault.
  • STS short-circuit — AWS auth backend exchanges Vault auth for an STS AssumeRole, returning a 15-min IAM session.
  • Revoke-all blast button — vault lease revoke -prefix database/ kills every active credential during incident response.

17.7 · OIDC federation — kill long-lived CI keys

The single highest-leverage move of the last five years: stop storing static cloud credentials in CI. Modern CI platforms mint a short-lived JWT per job, and cloud IAM trusts the issuer. No key, nothing to leak.

CI / sourceOIDC issuerTrusted by
GitHub Actionstoken.actions.githubusercontent.comAWS IAM Role, GCP WIF Pool, Azure Federated Credentials, HashiCorp Vault, Vercel, Cloudflare.
GitLab CIgitlab.com (or self-host)Same set as above; ID tokens (id_tokens: block).
Buildkiteagent.buildkite.comAWS, GCP, Vault.
CircleCIoidc.circleci.com/org/<org-id>AWS, GCP, Vault.
Argo Workflows / TektonK8s ServiceAccount projected JWTAWS IRSA, GCP Workload Identity, Azure AD WI.
Sigstore / FulcioPer-job OIDC from CIKeyless container/artifact signing (cosign).
Migration order
(1) Add OIDC trust policies. (2) Switch one pipeline. (3) Audit usage of the old access keys for 30 days. (4) Delete the IAM user. Repeat per cloud account.

17.8 · Rotation — making the worst case survivable

Rotation is the periodic replacement of a secret. Frequency is risk-driven: 90 days for human passwords, 24 hours for database service accounts, 15 minutes for dynamic creds, ~hours-to-days for TLS via cert-manager. The goal is not perfection — it is to shorten the window of exploitability.

Secret classRotation mechanism
RDS / Cloud SQL passwordsAWS Secrets Manager rotation lambdas; GCP Secret Manager + Cloud Functions; Vault DB engine (dynamic).
OAuth refresh tokensApp-managed refresh; revoke + reissue on suspicion.
TLS certificatescert-manager + ACME (Let's Encrypt / ZeroSSL), private CA (Vault PKI, AWS Private CA, Smallstep step-ca), or commercial (Venafi, DigiCert).
SSH host keysVault SSH CA — sign short-lived host certs at boot.
Code-signing keysHSM-bound (AWS CloudHSM, Azure Managed HSM, YubiHSM); rotate via key versioning, never re-export.
Encryption keys (KMS)Automatic key version rotation (yearly by default in AWS KMS, GCP KMS, Azure Key Vault).

17.9 · mTLS & workload identity

SPIFFE (Secure Production Identity Framework For Everyone) and its reference implementation SPIRE (CNCF graduated Sept 2022) give every workload a cryptographic identity (a SPIFFE ID, e.g. spiffe://prod/svc/payments) as a short-lived X.509 SVID or JWT-SVID. Service meshes (Istio, Linkerd) use SPIFFE under the hood to issue mTLS certs without static credentials.

  • istio-csr — Jetstack adapter that lets Istio fetch workload certs from cert-manager + an internal CA, replacing Citadel.
  • Workload Identity Federation — cloud-side equivalent: AWS IAM Roles for Service Accounts (IRSA), GCP Workload Identity, Azure AD Workload Identity. The K8s ServiceAccount JWT is exchanged for cloud creds with zero secrets stored.
  • Teleport / Boundary / StrongDM — identity-aware proxies for human and machine access to DBs, K8s, SSH — replacing static bastions and shared admin passwords.

17.10 · Auditing — who, what, when

Every read of a secret must be logged. This is non-negotiable for SOC 2, ISO 27001, PCI DSS, HIPAA. The audit log is also the single most useful artefact during incident response.

SourceAudit destination
HashiCorp VaultAudit devices (file, syslog, socket) → SIEM (Splunk, Datadog, Elastic, Chronicle).
AWS Secrets Manager / KMSCloudTrail data events.
GCP Secret ManagerCloud Audit Logs (Data Access).
Azure Key VaultAzure Monitor / Log Analytics.
Kubernetes Secret accessAPI audit log (level Request for secrets); ship to SIEM.

17.11 · Anti-patterns

.env in Git

Even private repos leak via forks, backups, and ex-employees. Use a vault.

Slack & email

"Hey can you DM me the prod API key?" is a forever-leak. Use 1Password share links or a vault role.

Secrets in env vars logged

Web framework error pages, APM, OpenTelemetry attributes happily print full env. Mark sensitive keys.

No rotation

"It still works" — yes, and so do the leaked copies. Rotate on a schedule plus on leaver events.

Root access keys

An AKIA… with AdministratorAccess in CI is one accidental cat $AWS_SECRET away from disaster. OIDC federate.

Shared admin DB user

Five engineers, one password, no log of who ran the DROP TABLE. Use Vault dynamic creds or Teleport.

Sigstore is your friend
Signing artifacts with Sigstore cosign using OIDC keyless mode means no signing key to store, rotate, or leak. The signature is bound to the build identity (e.g. this GitHub Actions workflow on tag v1.4.2).

17.12 · Self-check

Q1 · Which K8s pattern lets a Vault-stored secret appear as a native Secret object that workloads consume transparently?
git-crypt
External Secrets Operator
kustomize
cert-manager
Q2 · The single highest-leverage move to eliminate long-lived CI cloud keys is…
Rotating the keys every 30 days
Storing them in 1Password
OIDC federation (e.g. GitHub Actions → AWS IAM Role)
Base64-encoding them in env vars
Q3 · Native Kubernetes Secret objects are…
Encrypted at rest by default
base64-encoded; encrypt at rest only if you turn on KMS in EncryptionConfiguration
Always RSA-encrypted
Stored in Vault by default