Lesson 3 of 13 · 12m
Service Accounts Are Workload Identity
Projected service account tokens, the never-expiring legacy Secrets, automountServiceAccountToken: false, and exchanging Kubernetes identity for cloud identity.
The pod's passport is mounted as a file
Every pod runs as an identity. Set spec.serviceAccountName and Kubernetes mounts the service account's credentials into the container at /var/run/secrets/kubernetes.io/serviceaccount/ — three files: token, ca.crt, and namespace. Any process in the container that reads token can call the API server as that service account.
Since Kubernetes 1.20+ the mounted token is a bound service account token (BoundServiceAccountTokenVolume, GA in 1.22): a JWT signed by the API server's serviceaccount key, scoped to the api audience, with roughly a one-hour expiry that the kubelet rotates before it dies — the kubelet watches the projected volume and requests a replacement from the TokenRequest API, so a long-running pod's token file is always current. Beside it sit ca.crt, which is how in-cluster clients verify the API server's TLS, and namespace, which is how code learns where it lives. Short-lived, audience-bound, ephemeral. That is the design.
The legacy mechanism is the one that still bites. Before 1.24, every service account automatically got a companion Secret of type kubernetes.io/service-account-token containing a JWT that never expires. KEP-2799 ended auto-creation in 1.24, but clusters upgraded across that boundary still carry those tokens, and they appear in kubectl get secrets output, etcd snapshots, and old backups. They are valid until the Secret object is deleted — no expiry, no rotation. If you find them:
kubectl get secrets -A --field-selector type=kubernetes.io/service-account-tokendelete them or explicitly migrate the workload to bound tokens.
The one-line fix most workloads need
Here is the wrong mental model: "service accounts exist so pods can call the API." Reality: most workloads never call the Kubernetes API at all, and still get a token mounted by default — a live credential delivered to whatever ends up executing inside the container, including an attacker's webshell.
spec:
automountServiceAccountToken: falseSet it on the pod spec or the ServiceAccount itself. Workloads that legitimately call the API get their own dedicated service account with a dedicated, narrow Role. The default service account in a namespace should bind nothing at all.
Need a token anyway? Mint one on demand instead of leaving one lying around:
kubectl create token ci-bot --audience api --duration 10m -n paymentsThat calls the TokenRequest API (serviceaccounts/token verb) — short TTL, chosen audience, nothing persisted to etcd. The --audience flag is the detail that matters for cloud exchange: the audience claim is what AWS STS or GCP validates, so the same mechanism that vends API-bound tokens also vends sts.amazonaws.com-bound ones.
When the workload needs cloud power
The harder case is AWS/GCP/Azure APIs. The pre-workload-identity answer was "put the AWS keys in a Secret" — a static credential exfiltratable by anyone who can read that namespace's secrets. The current answer exchanges the Kubernetes identity for a cloud identity:
- EKS IRSA (IAM Roles for Service Accounts): the
pod-identity-webhookmutates pods to injectAWS_ROLE_ARNandAWS_WEB_IDENTITY_TOKEN_FILE, and AWS STS swaps the projected SA token for temporary AWS creds viaAssumeRoleWithWebIdentityagainst the cluster's OIDC issuer. - GKE Workload Identity: bind the Kubernetes SA to a Google SA with
roles/iam.workloadIdentityUser; the metadata server vends Google creds.
Either way, no cloud key ever touches etcd. The blast radius shrinks from "anyone who can read this Secret owns our AWS account" to "whoever controls this one workload's identity."
Credential-harvesting campaigns — TeamTNT's Kubernetes variants are the documented case — enumerate mounted SA tokens and instance metadata first, precisely because that's where the pivotable identity lives. Take the token off the filesystem for workloads that don't need it, keep the grants narrow for those that do, and exchange rather than store for cloud access.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
A 257-Byte Password Is the Key: Inside the OpenSSH musl Bypass
CVE-2026-123158 lets an attacker log into a locked account on musl-based systems like Alpine by sending a password nobody set. The trigger is one number, 257, and the reason is a C library returning a single asterisk. I reproduced the exact boundary against musl 1.2.4 and read the fix.
Immich Had Fourteen Advisories and One Bug It Fixed Three Times
Immich's 2026 security record runs to fourteen advisories, and they cluster hard: the sharing features, the OAuth plumbing, and one login redirect parameter that took three separate fixes across eighty-three days. Plus the 3.0 migration traps still waiting for anyone who hasn't jumped yet.
Jellyfin's Threat Model Is Your Brother-in-Law
Four Jellyfin CVEs landed in 2026 and not one of them needs an admin account. One needs only the ability to name a file. Meanwhile Jellyfin 12 shipped in September, the version numbers stopped starting with 10, and every "am I patched" check you wrote is now wrong.
Node.js Fixed 16 Flaws in One Release. Most of Them Live in HTTP/2 and TLS.
The November 11 Node.js security releases fix 16 CVEs across the 26, 24 and 22 lines, seven of them rated high. Nearly all sit in HTTP/2 and TLS, where a remote client can crash a server, leak memory, or get past per-host client-certificate checks.