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.
| Defence layer | Tool | What 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 Scanner | Rejects 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 alerts | AWS, Stripe, Slack, OpenAI, Anthropic, Twilio post tokens to GitHub Secret Scanning Partner Program | Auto-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.
| Product | Vendor | Hosting | Standout features |
|---|---|---|---|
| HashiCorp Vault | HashiCorp (IBM, 2025) | Self-host (OSS / Enterprise) or HCP Vault SaaS | Dynamic secrets, PKI engine, transit (encryption-as-a-service), 30+ auth methods. BUSL-licensed since Aug 2023; OpenBao is the LF fork. |
| AWS Secrets Manager | AWS | SaaS | Native rotation lambdas for RDS / Redshift / DocumentDB. ~$0.40 / secret / month. |
| AWS SSM Parameter Store | AWS | SaaS | Free standard tier; KMS-encrypted SecureString; cheap for thousands of params. |
| GCP Secret Manager | Google Cloud | SaaS | Versioned, IAM-scoped, region-replicated; integrates with Workload Identity. |
| Azure Key Vault | Microsoft | SaaS | Secrets + keys + certificates in one. HSM-backed Premium tier (FIPS 140-2 L3). |
| Akeyless | Akeyless | SaaS (DFC patent — no master key) | Multi-cloud, K8s, just-in-time; popular Vault alternative since the relicense. |
| 1Password Secrets Automation | 1Password | SaaS | Loved by smaller teams already on 1Password; op CLI integrates with K8s, GH Actions. |
| Doppler | Doppler | SaaS | Developer-first UX; environment promotion (dev → stg → prod) as a primary concept. |
| Infisical | Infisical (OSS) | Self-host or SaaS | Open-source contender; e2e-encrypted; great K8s operator. |
| Bitwarden Secrets Manager | Bitwarden | Self-host or SaaS | Same vault as the password manager; cheap per-user pricing. |
| CyberArk Conjur | CyberArk | Self-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.
| Tool | Origin | Pattern |
|---|---|---|
| SOPS | Mozilla (2017), now CNCF Sandbox | Encrypts only values in YAML/JSON/ENV, leaves keys readable. Backends: AWS KMS, GCP KMS, Azure KV, age, PGP, HashiCorp Vault. |
| age | Filippo Valsorda (2019) | Simple, modern PGP replacement. Tiny binary, single-line key. |
| Sealed Secrets | Bitnami → Argo Project | Cluster-side controller decrypts SealedSecret CRDs into native Secrets. Keys are cluster-scoped. |
| KSOPS | Viaduct (kustomize plugin) | SOPS-aware kustomize generator; powers SOPS-in-Argo workflows. |
| git-crypt | AGWA (2013) | Transparent encryption on Git push/pull via .gitattributes. Simple, but no per-file ACL. |
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.
| Pattern | How it works | Best for |
|---|---|---|
| Native Secret + etcd KMS | Turn 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 Secrets | Encrypt at desk → commit ciphertext → cluster controller decrypts. | Pure-GitOps teams without a central vault. |
| Secrets Store CSI Driver | Mounts 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 / Injector | Mutating 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).
- 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/readonlyand 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 / source | OIDC issuer | Trusted by |
|---|---|---|
| GitHub Actions | token.actions.githubusercontent.com | AWS IAM Role, GCP WIF Pool, Azure Federated Credentials, HashiCorp Vault, Vercel, Cloudflare. |
| GitLab CI | gitlab.com (or self-host) | Same set as above; ID tokens (id_tokens: block). |
| Buildkite | agent.buildkite.com | AWS, GCP, Vault. |
| CircleCI | oidc.circleci.com/org/<org-id> | AWS, GCP, Vault. |
| Argo Workflows / Tekton | K8s ServiceAccount projected JWT | AWS IRSA, GCP Workload Identity, Azure AD WI. |
| Sigstore / Fulcio | Per-job OIDC from CI | Keyless container/artifact signing (cosign). |
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 class | Rotation mechanism |
|---|---|
| RDS / Cloud SQL passwords | AWS Secrets Manager rotation lambdas; GCP Secret Manager + Cloud Functions; Vault DB engine (dynamic). |
| OAuth refresh tokens | App-managed refresh; revoke + reissue on suspicion. |
| TLS certificates | cert-manager + ACME (Let's Encrypt / ZeroSSL), private CA (Vault PKI, AWS Private CA, Smallstep step-ca), or commercial (Venafi, DigiCert). |
| SSH host keys | Vault SSH CA — sign short-lived host certs at boot. |
| Code-signing keys | HSM-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.
| Source | Audit destination |
|---|---|
| HashiCorp Vault | Audit devices (file, syslog, socket) → SIEM (Splunk, Datadog, Elastic, Chronicle). |
| AWS Secrets Manager / KMS | CloudTrail data events. |
| GCP Secret Manager | Cloud Audit Logs (Data Access). |
| Azure Key Vault | Azure Monitor / Log Analytics. |
| Kubernetes Secret access | API 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.
17.12 · Self-check
Secret object that workloads consume transparently?Secret objects are…