Making Vault + Kubernetes CSI safer after the CSI service-account token changes

Kubernetes’ handling of secrets and service account tokens has continued to evolve, and that evolution matters if you use HashiCorp Vault to deliver secrets into pods. This article walks through why the recent CSI-related changes matter, what they mean for Vault deployments, and a practical set of best practices to keep secrets short‑lived, least‑privileged, and hard to exfiltrate when using the Vault CSI or Secrets Store integration.

Why this matters right now

What changed in Kubernetes (short version)

Why that matters for Vault deployments

Recommended high‑level architecture

Concrete checklist before you deploy or upgrade

  1. Audit how your CSI driver authenticates
    • Does it use projected service account tokens, a node-level credential, or an in-cluster static secret? If it’s not using short-lived, bound tokens, plan to change that.
    • If you run your own CSI driver for Vault, prepare to set serviceAccountTokenInSecrets and update to a driver version that supports the new flow. (kubernetes.io)
  2. Map Vault roles to Kubernetes service accounts (workload identity)
    • Create Vault roles with policies that grant the minimum capabilities (read specific paths, create ephemeral DB creds, or sign certs).
    • Bind each role to a specific Kubernetes service account name and namespace so tokens from other pods can’t impersonate the role. (developer.hashicorp.com)
  3. Prefer dynamic secrets and enforce short TTLs
    • For databases, use Vault’s database secrets engine to generate credentials on demand with automatic revocation.
    • For cloud APIs, prefer generated IAM tokens/keys with tight TTLs instead of long-lived keys in pods. (developer.hashicorp.com)
  4. Use CSI mounts instead of Kubernetes Secrets where secrecy matters
    • CSI mounts avoid placing secrets in the Kubernetes API server as Secret objects, which are accessible to anyone with API read permissions in the namespace.
    • Ensure your CSI driver is upgraded to support the serviceAccountTokenInSecrets flow so nodal exposure is minimized. (developer.hashicorp.com)
  5. Enforce granular Vault policies and audit logging
    • Implement policies that only allow the required operations for each role.
    • Enable audit logging on Vault and collect those logs centrally to detect anomalous access patterns quickly. (developer.hashicorp.com)
  6. Consider Pod Security and Node hardening
    • Limit hostPath mounts and other privileges that could let a compromised container read node-level files.
    • Keep node images patched and minimize the set of system tools available to containers.

Example: what an operator change looks like (conceptual)

apiVersion: storage.k8s.io/v1
kind: CSIDriver
metadata:
  name: vault.csi.hashicorp.com
spec:
  attachRequired: true
  podInfoOnMount: true
  serviceAccountTokenInSecrets: true

Operational notes and gotchas

Why short‑lived credentials remain the single best mitigation Short TTLs and dynamic generation change the economics for attackers. A leaked database credential that auto-expires reduces the window for exploitation; a certificate signed for minutes is far less useful than a static key. Vault was built to enable this pattern and the Vault team’s guidance emphasizes dynamic credentials as a priority to prevent leaked secrets. Pair that with the safer CSI token handling in Kubernetes and you significantly reduce both how and how long credentials can be used if compromised. (hashicorp.com)

Summary (practical takeaways)

Adopting the above patterns aligns platform and application teams: Kubernetes gives a safer mechanism to hand credentials to node components, and Vault focuses on delivering least‑privilege, short‑lived secrets. The combination reduces both the surface area and the lifetime of exposed secrets—two of the most effective controls in real‑world incident containment.