Secrets — database passwords, API keys, TLS certificates, encryption keys, OAuth client secrets — are the “keys to the kingdom.” When secrets are scattered across config files, CI/CD pipelines, and source repositories (secret sprawl), they are impossible to inventory, rotate, or revoke. A single leaked credential can escalate into a full breach.
Secret management centralizes the entire credential lifecycle — creation, storage, distribution, rotation, and revocation — in a hardened vault. Services obtain credentials at runtime through authenticated, audited calls rather than reading static config. The vault enforces Least Privilege by ensuring each service identity receives only the secrets it needs, scoped to its role, with a short time-to-live. It also provides the master keys that Encryption at Rest + in Transit depends on for envelope encryption, and uses Strong Authentication mechanisms (OIDC, IAM) to solve the vault’s own bootstrap problem.
How It Works
- Centralized Vaulting: Store all secrets in a dedicated vault (HashiCorp Vault, AWS Secrets Manager, etc.) with an encrypted-at-rest backend.
- Identity-Based Bootstrapping: Solve the “secret zero” problem (authenticating to the vault) by using trusted platform identities—such as Kubernetes ServiceAccounts, AWS IAM Roles, or OIDC tokens—rather than static, hardcoded vault tokens.
- Access Policies: Define fine-grained paths (e.g.,
secret/data/payment-service/*) and map them to specific service identities, ensuring strict isolation between components. - Runtime Injection: Deliver secrets at runtime via vault APIs, sidecar proxies (e.g., vault-agent), or CSI drivers. Avoid environment variables where possible, as they are often logged by monitoring agents or visible in process listings (
/proc). - Dynamic Secrets & Short TTLs: Prefer dynamic secrets generated on-the-fly (e.g., a database user created for 4 hours) over long-lived static passwords.
- Automated Rotation: Configure the vault to automatically rotate credentials on a schedule, updating the target system (e.g., changing the DB password) and notifying or restarting the consuming application if necessary.
- Master Key Management: Secure the vault’s “root of trust” using Shamir’s Secret Sharing or hardware/cloud-based auto-unseal (KMS/HSM) to prevent a single administrator from compromising or losing the entire secret store.
Failure Modes
- The Unseal Trap: The vault is locked (sealed) after a restart and the unseal keys are missing or held by unavailable personnel, leading to prolonged downtime.
- The Bootstrap Trap: A service uses a hardcoded “initial” token to talk to the vault, which is then committed to git, defeating the purpose of the vault.
- Insecure Backups: The vault itself is secure, but its database backups are stored unencrypted or with weak access controls in an external bucket.
- Environment Variable Leakage: Secrets injected as environment variables leak through diagnostic logs, crash dumps, child processes, or
/proc/self/environ. - Renewal Failure: An application fails to renew its vault token or dynamic secret lease, resulting in a sudden “Unauthorized” error after hours of successful operation.
- Circular Dependencies: The logging or monitoring system requires secrets from the vault to function, but the vault cannot start or log its errors because the logging system is down.
Verification
- Secret-Sprawl Scan: Use automated tools (truffleHog, gitleaks) to verify zero plaintext secrets exist in repositories, container images, or CI/CD logs.
- Identity Validation: Audit vault policies to ensure service A cannot, under any circumstances, read secrets belonging to service B.
- Rotation Validity: Trigger a manual rotation and verify that (1) the new secret works, and (2) the old secret is immediately revoked and no longer functions.
- Bootstrap Audit: Verify that services authenticate to the vault using platform-provided identities (K8s, IAM) rather than static files or environment variables.
- Availability Simulation: Test the “Tier-0 failure”: stop the vault and verify which services fail immediately (cold start) vs. which can continue temporarily with cached/leased secrets.
- Backup Integrity: Perform a “fire drill” restore from a vault backup to verify that the root-of-trust (unseal/master keys) can correctly decrypt the data.
Variants and Related Tactics
- Dynamic Secrets: On-demand credential generation that eliminates the need to “store” a password at all.
- Kubernetes External Secrets: Operators that sync vault secrets into native K8s Secrets for legacy applications.
- Encryption at Rest + in Transit depends on secret management for the “master keys” used in envelope encryption.
- Least Privilege is applied here at the credential layer via path-based scoping.
- Strong Authentication (MFA / OIDC) provides the identity foundation used to solve the vault’s own bootstrap problem.
- Hardware Security Modules (HSM): Providing a physical “root of trust” for the vault’s master keys.
References
- NIST SP 800-53: Security and Privacy Controls — IA-5 (Authenticator Management), SC-12 (Cryptographic Key Establishment and Management)
- OWASP Application Security Verification Standard (ASVS) — V6 (Cryptography) and V2.10 (Service Authentication)
- OWASP Secrets Management Cheat Sheet
- Software Architecture in Practice — Bass, Clements & Kazman (full citation)