tadata
Back to home

Secrets Management: Protecting the Keys to Your Kingdom

#security#devops#secrets#cloud#infrastructure

Every system has secrets: API keys, database credentials, TLS certificates, encryption keys, OAuth tokens. How you manage them determines whether a single compromise cascades into a full breach. Secrets management is not a tool choice -- it is an architectural discipline.

Secret Types Taxonomy

Secrets
├── Credentials
│   ├── Database passwords
│   ├── Service account keys
│   ├── SSH keys
│   └── API keys / tokens
├── Certificates
│   ├── TLS/SSL certificates
│   ├── mTLS client certificates
│   ├── Code signing certificates
│   └── CA private keys
├── Encryption Keys
│   ├── Data encryption keys (DEK)
│   ├── Key encryption keys (KEK)
│   ├── KMS master keys
│   └── Application-level encryption keys
├── Tokens
│   ├── OAuth access/refresh tokens
│   ├── JWT signing keys
│   ├── Webhook secrets
│   └── Session secrets
└── Configuration Secrets
    ├── Connection strings
    ├── SMTP credentials
    ├── Third-party API secrets
    └── License keys

Tool Comparison

CapabilityHashiCorp VaultAWS Secrets ManagerGCP Secret ManagerSOPS (Mozilla)Sealed Secrets
TypeFull platformManaged serviceManaged serviceFile encryptionKubernetes-native
Dynamic secretsYes (DB, AWS, PKI)NoNoNoNo
Auto-rotationYes (built-in)Yes (Lambda-based)Yes (Cloud Functions)N/AN/A
Access controlACL policies + SentinelIAM policiesIAM policiesGPG/KMS keysCluster-scoped
Audit loggingBuilt-inCloudTrailCloud Audit LogsGit historyK8s audit
Multi-cloudYesAWS onlyGCP onlyYes (any KMS)Kubernetes only
GitOps compatibleExternal Secrets OperatorExternal Secrets OperatorExternal Secrets OperatorNative (encrypted in repo)Native
ComplexityHigh (operate cluster)LowLowLowLow
CostSelf-hosted or HCP$0.40/secret/month$0.06/secret/versionFreeFree
Best forMulti-cloud, dynamic secretsAWS-native workloadsGCP-native workloadsGitOps, small teamsK8s-only environments

Architecture: Secrets Delivery Patterns

┌─────────────────────────────────────────────────────┐
│              Secrets Management Platform             │
│        (Vault / AWS SM / GCP SM / Azure KV)         │
└───────────────┬──────────────┬──────────────────────┘
                │              │
    ┌───────────▼───────┐  ┌──▼──────────────────┐
    │  CI/CD Pipeline   │  │  Runtime Injection   │
    │                   │  │                      │
    │  - Build-time     │  │  - Sidecar (Vault    │
    │    injection      │  │    Agent Injector)   │
    │  - OIDC auth to   │  │  - Init container    │
    │    vault          │  │  - CSI Secret Store  │
    │  - Short-lived    │  │  - Env var injection │
    │    tokens         │  │  - Mounted volumes   │
    └───────────────────┘  └──────────────────────┘

    ┌──────────────────────────────────────────────┐
    │  GitOps Path (encrypted at rest in repo)     │
    │                                              │
    │  SOPS / Sealed Secrets / External Secrets    │
    │  Operator reconciles from source of truth    │
    └──────────────────────────────────────────────┘

Rotation Patterns

PatternDescriptionFrequencyComplexityDowntime Risk
Manual rotationHuman changes secret, updates consumersAd-hocLowHigh (missed consumers)
Scheduled rotationAutomated job rotates on a cadence30-90 daysMediumLow (if tested)
Dynamic secretsSecret generated per-session, auto-expiresPer requestHigh (initial setup)None
Dual-secret rotationTwo active versions, rotate one at a timeContinuousMediumNone
Zero-standing-secretsNo persistent secrets, JIT generation via OIDC/IRSAPer requestHighNone

Anti-Pattern Catalog

Anti-PatternWhy It Is DangerousWhat To Do Instead
Secrets in source codeLeaked via git history, forks, logsUse a secrets manager, scan with truffleHog/gitleaks
Secrets in environment variablesVisible in process listings, crash dumpsMount as files, use CSI driver, or sidecar injection
Shared service accountsNo attribution, impossible to rotatePer-service identity, short-lived credentials
Long-lived API keysLarge blast radius if compromisedDynamic secrets, OIDC federation, auto-rotation
Secrets in CI/CD config filesAccessible to anyone with repo accessOIDC auth to vault, no static secrets in pipelines
Copy-pasting secrets via Slack/emailNo audit trail, persisted in chat historyUse a secrets manager with UI, 1Password for teams
No rotation policyCompromised secrets remain valid indefinitelyEnforce rotation via policy, automate with Lambda/CronJob

Strategic Recommendations

Start with a scan. Before choosing a tool, understand your current exposure. Run truffleHog or gitleaks against your entire git history. The results will be sobering and will justify investment.

Embrace OIDC federation. Modern CI/CD platforms (GitHub Actions, GitLab CI) support OIDC tokens that can authenticate directly to cloud providers and Vault -- eliminating static CI/CD secrets entirely.

Dynamic secrets are the endgame. Vault's dynamic secrets (database credentials generated per pod, expired after TTL) eliminate the rotation problem entirely. This is the architecture to aim for.

Encrypt secrets in git for GitOps. SOPS with age or cloud KMS lets you store encrypted secrets alongside application code. Combined with External Secrets Operator, this is the cleanest GitOps pattern.

Resources

:::