Skip to content

Lesson 12 of 13 · 12m

Secrets Are Base64, Not Encrypted

etcd plaintext by default, kms v2 encryption config, why resourceNames can't narrow list/watch, and env versus volume versus CSI driver.

The name is lying to you

kubectl create secret generic db --from-literal=password=hunter2 writes a Secret object into etcd where the value is base64. Not encrypted — base64. (stringData is the write-side convenience field that merges into data on create and is never stored.) kubectl get secret db -o yaml prints it; | base64 -d prints plaintext. The object named Secret is a labeled map of credentials in the cluster's datastore, and its entire protection model is the list of who may get, list, and watch secrets in that namespace.

That RBAC boundary is coarser than people assume. resourceNames narrows get/update/delete to named secrets — but list and watch ignore resourceNames entirely. There is no way to grant "list only the app secret." Anyone who can list secrets in a namespace can read all of them. The practical consequence: secrets that must be separated go in separate namespaces, not separate objects.

Encryption at rest is opt-in

Out of the box, etcd holds plaintext. --encryption-provider-config points at an EncryptionConfiguration with an ordered provider list:

resources:
  - resources: [secrets]
    providers:
      - kms:
          name: aws-kms
          endpoint: unix:///var/run/kmsplugin.sock
      - identity: {}

The first provider encrypts new writes; the list's order also governs reads during migration, and identity literally means plaintext passthrough — listing it first means you configured nothing. aescbc encrypts with a local key file (a key on the same disk as etcd — a marginal gain); secretbox symmetric; kms v2 (stable since 1.29) envelopes to AWS KMS, GCP KMS, or Vault transit — the key never lives on the etcd host. After changing providers, rewrite existing secrets (kubectl get secrets --all-namespaces -o json | kubectl replace -f -) or the old plaintext copies persist until each secret is touched.

And encryption at rest is etcd-disk protection. It does nothing about kubectl get with read rights, etcd snapshots shipped to backups, or client certs in /etc/kubernetes/pki/etcd — etcd access remains total access, which is why etcd's client TLS and firewall placement matter more than any provider choice.

Delivery is a security decision

How the secret reaches the workload changes the leak profile:

  • Environment variables: injected at container start, frozen until restart (rotate the secret, pods keep the old value), visible in the pod spec and in kubectl describe, and copied into crash dumps and kubectl exec env output.
  • Mounted volumes: projected into tmpfs as files; the kubelet refreshes them on rotation without a restart; not visible in the spec.
  • Secrets Store CSI driver: mounts directly from AWS Secrets Manager, Vault, etc. — the value never lands in etcd at all.
  • External Secrets Operator: syncs external stores into Secret objects — convenient for GitOps-shaped workflows, but the copy still lands in etcd under the same RBAC rules.
  • Sealed Secrets (Bitnami kubeseal): encrypts secrets against the cluster's public key so the ciphertext can live safely in git; the controller decrypts in-cluster.

And rotation is on you: Kubernetes never rotates secrets. Mounted volumes pick up a rotated value on the kubelet's sync cadence (about a minute); env-var secrets hold the old value until restart — plan rollout accordingly.

The consistent answer across every Kubernetes breach writeup: post-foothold, the attacker's next command is kubectl get secrets -A. That single read is the escalation to the cloud account. The countermeasures are exactly the unglamorous set above — kms v2 in the encryption config, namespace-scoped separation, no list/watch on secrets except for the controllers that need it, volume mounts over env vars, and audit-log Metadata coverage on secrets reads so the 03:14 dump is an alert, not a surprise.

What to actually do

Enable kms v2, scope secret reads to the smallest namespaces, treat mounted-over-env as the default, and use the CSI driver when the secret doesn't need to exist in etcd at all. The object is called Secret; the security is configuration.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.