Skip to content

Service account tokens of synced pods are stored in host pod annotations by default #4276

Open

Description

@blacksoxx

What happened?

With the default sync.toHost.pods.useSecretsForSATokens: false, the token that vCluster requests for a synced pod's service account is written verbatim into an annotation on the host pod (vcluster.loft.sh/token-<random>) and mounted through the downward API. The token is pod bound but requested with a ten year lifetime. Everyone who can read pods in the host namespace, which on most clusters is far more identities than can read Secrets (monitoring agents, cluster-wide pod viewers, kubectl describe pod in a support ticket), gets a token that authenticates as that tenant's service account against the virtual cluster.

The secrets mode already exists and is what the project's own e2e configurations and test/commonValues.yaml run with, and the security docs recommend turning it on. The shipped default still puts the token into the annotation.

What did you expect to happen?

Tokens stored where Kubernetes expects credentials, in a Secret scoped by Secret RBAC, by default. Users who rely on the annotation behaviour can keep it with useSecretsForSATokens: false.

How can we reproduce it (as minimally and precisely as possible)?

Create a vCluster with the default vcluster.yaml, start any pod inside it that mounts the default service account token, then on the host:

kubectl get pod -n <vcluster-namespace> <translated-pod-name> -o jsonpath='{.metadata.annotations}' | tr ',' '\n' | grep vcluster.loft.sh/token-

The value is a JWT for the virtual cluster's service account.

Anything else we need to know?

This is a documented tradeoff (security guide and shared nodes hardening guide both recommend the secrets option), so the ask is only about the default. Existing host pods keep their annotation tokens until they are recreated; new pods get a Secret owned by the pod.

Host cluster Kubernetes version

Not version specific; read on main at c5e9027, same in v0.37.6.

vcluster version

main at c5e9027, v0.37.6.

VCluster Config

Defaults.

PR: #4277

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions