Vaults and Secret Stores

Centralized systems (HashiCorp Vault/OpenBao, AWS Secrets Manager, cloud KMS-backed stores, Kubernetes integrations, SOPS-encrypted files) that hold secrets encrypted, gate access by identity, audit every read and ideally mint short-lived dynamic credentials.

How it works

A store moves the problem from “where is the value?” to “who may decrypt it?” Encryption at rest is table stakes; the real perimeter is the set of identities allowed to read or decrypt, and the moment a secret leaves the store to be used. Core properties (OWASP Secrets Management Cheat Sheet):

  • Centralize and standardize, with HA and a break-glass/backup path.
  • Least-privilege access per secret or version, not account-wide.
  • Audit every access; feed it to detection.
  • Lifecycle: creation, rotation, revocation, expiration — see Credential Rotation and Revocation.
  • Dynamic over static: lease-bound credentials created per consumer, revoked on lease expiry.

Dynamic secrets (Vault AWS engine)

vault secrets enable aws
vault write aws/config/root access_key=... secret_key=... region=us-east-1
vault write -f aws/config/rotate-root           # Vault rotates its own root key
vault write aws/roles/deploy credential_type=iam_user \
  policy_arns=arn:aws:iam::aws:policy/AmazonEC2ReadOnlyAccess
vault read aws/creds/deploy                      # new IAM user + key per lease

credential_type can also be assumed_role or federation tokens (STS, short-lived). Note that a static root credential still bootstraps the engine — OWASP flags that dynamic secrets usually require long-term static secrets to create them.

Getting secrets into workloads

MethodNotes
Mounted file / tmpfs volumePreferred; orchestrator mounts at runtime, never baked into image
Sidecar / init fetch (Vault Agent Injector: vault.hashicorp.com/agent-inject: "true", agent-inject-secret-<name>: "secret/login")App never talks to the store directly
Secrets Store CSI DriverMounts external secrets; --enable-secret-rotation=true + --rotation-poll-interval re-syncs; apps must re-read or restart
Vault Secrets OperatorSyncs Vault KV v1/v2, PKI and dynamic secrets into native K8s Secrets
Environment variablesLast resort: readable via /proc/<pid>/environ, inherited by children, dumped in crash logs; docker ENV/ARG bakes them into image metadata

Kubernetes Secret objects are base64-encoded, not encrypted — committing one (e.g. in a Helm chart) commits a working credential. For GitOps, encrypt in the repo instead:

# .sops.yaml
creation_rules:
  - path_regex: k8s/.*\.yaml
    encrypted_regex: ^(data|stringData)$
    kms: arn:aws:kms:...      # or age / PGP / GCP KMS / Azure KV / Vault transit

SOPS uses envelope encryption plus a MAC to detect tampering; decrypt at build or reconcile time (sops -d … > "$RUNNER_TEMP/secrets.yaml", Flux). Sealed Secrets (kubeseal) is the cluster-public-key alternative.

Hardening the store itself (Vault)

  • Run as an unprivileged user; disable swap and core dumps; no SSH/RDP to Vault hosts — API only.
  • Disable shell history for the vault CLI; short TTLs for tokens and certs; avoid long-lived root tokens.
  • Single tenancy, firewall traffic, restrict storage-backend access, enable audit device logs, immutable upgrades, configure user lockout.

Notable cases

  • Railway (Oct 2026) — envelope-encrypted customer env vars; an attacker escalated in the multi-tenant build system, stole CI credentials that could decrypt, and decrypted variables for up to ~100,000 workspaces hunting AI keys. Railway couldn’t tell from the DB query which keys were decrypted, so it rotated everything and pushed keys to vendors for revocation.
  • AWS AgentCore Identity — Unit 42 showed the harness’s default-on shell tool (root) can read credentials after they are resolved to plaintext in memory; prompt injection then exfiltrates them. AWS closed it as shared-responsibility: scope allowedTools, least-privilege identity-vault accounts, egress monitoring. See MCP Security.
  • Vault CVEs — CVE-2026-5807 (HCSEC-2026-08): unauthenticated sys/generate-root / sys/rekey start-cancel loop locks the single operation slot (fixed in 2.0.0). CVE-2026-3605 (HCSEC-2026-05): KVv2 metadata glob-policy bypass lets authenticated users delete secrets outside their scope. Vault integrated-storage SSRF (GHSA-wfcg-cjg6-q966).
  • OpenBao — authentication bypass fixed in 2.6.5 / 2.7.2 (GHSA-j3xj-r26p-rh3h).
  • Azure API Management Classic (Nov 2026) — APIM is a de facto secret store (Named Values, IdP and OpenID Connect client secrets, subscription keys, management-API tokens). Instances not configured per Microsoft’s guidance exposed a management-plane path to an unauthorized party; one admin reported a zero-day auth bypass in a deprecated legacy API that produced no customer-visible logs, followed by Key Vault access with a valid admin token. Developer/Basic/Standard/Premium Classic tiers were affected; Consumption and v2 were not. NSM linked it to Equinor and Skagerak Energi and advised replacing every secret and Named Value (BleepingComputer, SecurityWeek). NSM also advised identifying all data reachable through the service, i.e. inventory gateways as secret stores, not just the vault.

Defenses / review checklist

  • Can any CI identity or build runner decrypt production secrets? (Railway path.)
  • Are secrets resolved into env vars or agent tool contexts where another process or a prompt-injected tool can read them?
  • Vault coverage: what fraction of discovered credentials actually live in the vault vs copies in code, CI variables and tickets? A vault entry does not mean the hardcoded copy is gone.
  • Prefer Workload Identity Federation so there is no static secret to store.

Sources