HashiCorp Vault Agent creates a sidecar that talks to the Vault server and injects secrets as files into containers, where the files are located under /vault/secrets/.
"render all defined templates to the ephemeral in-memory mount at /vault/secrets/ available to other containers in the pod"
We simulated a "root takeover" attack on the kubernetes host itself, and we were saddened to see this:
root@k8s-host-24:~# cat /srv/kubelet/pods/0f407b88-1512-4612-9aa9-62189b12d5ed/volumes/kubernetes.io~empty-dir/vault-secrets/secrets.properties auth.password=glc_eyJvI[...] It seems in this case, the "weakest link" is the file stored under /vault/secrets/.
While I understand the argument "facing root takeover, all bets are off" and "you should control root access instead"
Even if we tried to remove direct access to the pod itself:
kubectl -n thenamespace exec -it the-pod-5786b55b6f-z77jp -- bash Defaulted container "the-pod" out of: the-pod, vault-agent-init (init) error: Internal error occurred: error executing command in container: failed to exec in container: failed to start exec "e7224d07630c58882024052a5aa50d4c808507b79436294a04": OCI runtime exec failed: exec failed: unable to start container process: exec: "bash": executable file not found in $PATH: unknown Q1. Is there a way for Vault to inject the secrets as environment variables directly into the business pods, without relying on this /vault/secrets/file which is more like a sitting duck at this point
Q2. Can the combination of a) source the file as an environment variable + b) discard the file to mitigate this issue?
Q3. Is there a way to resolve this?