Kubernetes Hardening L4a: Human Identity, RBAC Pitfalls, and the nodes/proxy GET Escalation
TL;DR
Never distribute static client certificates or system:masters kubeconfigs for day-to-day engineering access - Kubernetes has no native certificate revocation list (CRL), and system:masters bypasses the RBAC authorizer completely.
Wire short-lived OIDC tokens into kube-apiserver using AuthenticationConfiguration with CEL claim validation on bare metal (via Keycloak [ CNCF Incubating ] or Dex [ CNCF Sandbox ]), or use native cloud identity mappings (EKS Access Entries, GKE Google Groups for RBAC, AKS Entra ID with --disable-local-accounts ).
Audit your RBAC tree for privilege escalation primitives ( escalate , bind , impersonate , serviceaccounts/token , pods/ephemeralcontainers , list on secrets ), and eliminate nodes/proxy get permissions from monitoring agents by migrating to Fine-Grained Kubelet Authorization (KEP-2862, GA in Kubernetes 1.36).
Why Static Kubeconfigs and Client Certificates Fail
When kubeadm init bootstraps a cluster, it writes /etc/kubernetes/super-admin.conf (introduced in Kubernetes 1.29) containing a client X.509 certificate valid for one year with the subject O = system:masters, CN = kubernetes-super-admin , alongside /etc/kubernetes/admin.conf bound via RBAC to kubeadm:cluster-admins .
In far too many bare-metal and early-stage cloud setups, one of these static files gets copied into a team password manager or CI variable and shared across the engineering org.
This fails three basic security invariants:
- Client certificates cannot be revoked individually. The Kubernetes API server validates client certificates against the CA bundle specified in
--client-ca-file. It does not support OCSP stapling or CRL checking. If an engineer's laptop is compromised or they leave the company, their client certificate remains valid until itsNotAftertimestamp. Your only remediation is rotating the entire cluster client CA and re-issuing certificates to every control-plane component. system:mastersbypasses RBAC. Insidekube-apiserver, requests authenticated with the groupsystem:mastersmatch a built-in superuser authorizer that executes before the RBAC authorizer. You cannot write a ClusterRole restriction or remove permissions fromsystem:masters. Even if you delete every ClusterRoleBinding in the cluster, a client certificate bearingO = system:mastersretains full unrestricted root access.- Zero individual attribution in audit logs. When five engineers share
kubernetes-admin, every destructivekubectl deleteorkubectl execrecords"user": {"username": "kubernetes-admin", "groups": ["system:masters", "system:authenticated"]}in the audit log. Incident response starts blind.
Short-Lived OIDC SSO and Structured Authentication
Human access to kube-apiserver should rely exclusively on OpenID Connect (OIDC) authorization code flows with PKCE (executed on the CLI via kubectl oidc-login / kubelogin ).
Instead of a static credential on disk, the engineer authenticates against your corporate Identity Provider (IdP) with hardware MFA and receives a signed JWT ID token with a 15-to-60-minute TTL.
Self-Hosted Bare Metal: OIDC Group Mapping via Structured Authentication
With Structured Authentication Configuration ( apiserver.config.k8s.io/v1 , Beta in Kubernetes 1.30 as v1beta1 , GA in Kubernetes 1.34 as v1 ) paired with KEP-4633 ( AnonymousAuthConfigurableEndpoints , also GA in Kubernetes 1.34), you replace legacy --oidc-* and --anonymous-auth CLI flags with --authentication-config=/etc/kubernetes/auth/authentication-config.yaml .
Note that leaving any legacy --oidc-* or conflicting --anonymous-auth flag on kube-apiserver causes startup to fail.
In Layer 3 , we covered the complete multi-issuer AuthenticationConfiguration including KEP-4633 health-only anonymous access and CI runners. For Layer 4a human RBAC, focus on the claim validation, oidc: prefixing, and system: anti-spoofing rules for your bare-metal Keycloak or Dex broker:
# Human OIDC RBAC mapping excerpt from /etc/kubernetes/auth/authentication-config.yaml
# (See Layer 3 for the full multi-issuer + KEP-4633 anonymous configuration.)
apiVersion : apiserver.config.k8s.io/v1
kind : AuthenticationConfiguration
jwt :
- issuer :
url : https://sso.bard.sh/realms/platform
audiences :
- k8s-prod-cluster
audienceMatchPolicy : MatchAny
claimValidationRules :
- expression : 'has(claims.email_verified) && claims.email_verified == true'
message : "OIDC email address must be verified by the identity provider."
- expression : 'has(claims.email) && claims.email.endsWith("@bard.sh")'
message : "Only bard.sh corporate domain accounts are permitted."
claimMappings :
username :
expression : '"oidc:" + claims.email'
groups :
# Guard has(claims.groups) so tokens without group memberships do not fail CEL evaluation
expression : 'has(claims.groups) ? claims.groups.map(g, "oidc:" + g) : []'
uid :
claim : sub
userValidationRules :
- expression : '!user.username.startsWith("system:")'
message : "Username cannot spoof reserved system: identities."
- expression : 'user.groups.all(g, !g.startsWith("system:"))'
message : "Mapped groups cannot spoof reserved system: groups."
Prefixing every OIDC username and group with oidc: and rejecting system:* in userValidationRules ensures that even if an attacker modifies group names inside Keycloak, they cannot mint a token that maps to system:masters or system:nodes .
Managed Kubernetes: EKS, GKE, and AKS
On managed clusters, use the provider's native control-plane identity integration rather than maintaining a custom OIDC broker, while also disabling legacy admin backdoors.
AWS EKS: Access Entries Over aws-auth
For years, EKS mapped AWS IAM principals to Kubernetes users via the kube-system/aws-auth ConfigMap . That design was notorious for operational outages: a single YAML syntax error in aws-auth broke node registration and locked administrators out of the cluster.
Modern EKS clusters should set authentication_mode = "API" (eliminating aws-auth entirely) and manage human SSO roles through EKS Access Entries backed by AWS IAM Identity Center (formerly AWS SSO).
Crucially, bind the Access Entry to a Kubernetes group and manage granular permissions via standard Kubernetes RBAC (or scoped EKS Access Policies), and set bootstrap_cluster_creator_admin_permissions = false so the IAM role that ran terraform apply does not retain hidden permanent cluster-admin privileges:
resource "aws_eks_cluster" "prod" {
name = "prod-eu-central-1"
role_arn = aws_iam_role . cluster_control_plane . arn
version = "1.36"
access_config {
authentication_mode = "API"
bootstrap_cluster_creator_admin_permissions = false
}
vpc_config {
endpoint_private_access = true
endpoint_public_access = false
subnet_ids = var . private_cp_subnet_ids
}
}
resource "aws_eks_access_entry" "platform_oncall" {
cluster_name = aws_eks_cluster . prod . name
principal_arn = var . aws_sso_platform_engineer_role_arn
kubernetes_groups = [ "oidc:platform-engineers" ]
type = "STANDARD"
}
GCP GKE: Google Groups for RBAC
On GKE, configure authenticator_groups_config on the cluster pointing to a dedicated umbrella Google Group (for example, gke-***************@bard.sh ).
Any nested group inside that umbrella group is automatically populated in the authenticated user's token claims, allowing you to bind Kubernetes RoleBindings directly to group: pay**********@bard.sh without touching cluster configuration when engineers join or leave a team.
Azure AKS: Entra ID with Local Accounts Disabled
By default, AKS maintains a static local cluster administrator account accessible via az aks get-credentials --admin . Any Azure principal with the Microsoft.ContainerService/managedClusters/listClusterAdminCredential/action permission can download a static system:masters kubeconfig that bypasses Entra ID conditional access and MFA.
Always disable local accounts in production:
az aks update \
--resource-group rg-prod-aks \
--name aks-prod-weu \
--enable-aad \
--enable-azure-rbac \
--disable-local-accounts
Managed vs Bare Metal Comparison
Control Dimension AWS EKS GCP GKE Azure AKS Self-Hosted Bare Metal Primary Human AuthN EKS Access Entries + IAM Identity Center (or OIDC federation) Google Cloud Identity + Google Groups for RBAC Microsoft Entra ID + Azure RBAC for Kubernetes AuthenticationConfiguration + Keycloak or Dex Static Admin Backdoor Cluster creator admin ( bootstrap_cluster_creator_admin_permissions ) - set to false Legacy client certificate auth - disabled by default on modern GKE Local admin account ( --admin ) - disable via --disable-local-accounts /etc/kubernetes/super-admin.conf ( system:masters ) - restrict to root on CP nodes only Multi-Issuer & CEL Rules Native OIDC Identity Provider associations support standard claims GKE Identity Service (Anthos/Fleet) or native IAM Entra ID Conditional Access + Managed Identity Full apiserver.config.k8s.io/v1 CEL claimValidationRules and hot reload Anonymous Auth Restriction Managed by AWS (restricted on recent versions) Managed by Google Managed by Microsoft You : Configure KEP-4633 ( anonymous.conditions limited to /healthz , /livez , /readyz ) Break-Glass Mechanism Dedicated IAM role + Access Entry gated by AWS IAM Identity Center approval PAM (Privileged Access Manager) temporary IAM grant Entra ID Privileged Identity Management (PIM) JIT activation Offline hardware-backed cert or dedicated OIDC emergency client + immediate SIEM alert
Eliminating system:masters and Designing Break-Glass Access
On bare-metal clusters bootstrapped with kubeadm (since Kubernetes 1.29), kubeadm init automatically generates two separate kubeconfigs: /etc/kubernetes/super-admin.conf (carrying O = system:masters strictly for local emergency recovery when the external OIDC IdP is unreachable) and /etc/kubernetes/admin.conf (carrying O = kubeadm:cluster-admins , which is governed by standard RBAC and can be revoked by deleting its ClusterRoleBinding ).
Never copy either file off the control-plane hosts into shared password managers; keep super-admin.conf 0600 root-only on control-plane disks (or sealed offline in a physical safe / HSM-backed break-glass store).
Your break-glass architecture should follow three rules:
- Just-In-Time (JIT) elevation. On managed clouds, use AWS IAM Identity Center temporary elevation, GCP Privileged Access Manager (PAM), or Azure Entra PIM with mandatory ticket justification and peer approval. On bare metal, use Teleport or a dedicated Keycloak emergency client that requires hardware FIDO2 WebAuthn authentication and issues a 15-minute token mapped to
oidc:break-glass-admin. - Dedicated OIDC break-glass subject. Bind the break-glass ClusterRoleBinding strictly to
oidc:break-glass-admin(never asystem:prefix, which youruserValidationRulesexplicitly reject) so it never fires during normal operations. - High-priority paging on use. Configure your audit log pipeline ( Fluent Bit [ CNCF Graduated ] or OpenTelemetry Collector [ CNCF Graduated ]) to page the security on-call rotation immediately whenever any request carries
"groups": ["system:masters"]or"oidc:break-glass-admin".
Dangerous RBAC Permissions: The Silent Escalation Paths
You do not need cluster-admin to own a Kubernetes cluster. Several standard RBAC verbs act as direct privilege escalation primitives. When reviewing third-party Helm charts or tenant roles, treat all seven of the following permissions as equivalent to root:
Resource Verb(s) Escalation Mechanics Remediation clusterroles , roles escalate , bind escalate lets a principal create or modify roles with permissions they do not possess themselves. bind lets them bind existing high-privilege roles (including cluster-admin ) to their own account. Never grant escalate or bind to humans or non-controller workloads. Enforce via ValidatingAdmissionPolicy . users , groups , serviceaccounts impersonate Allows setting Impersonate-User or Impersonate-Group HTTP headers on any API call, immediately assuming the target identity's full RBAC permissions. Restrict strictly to identity-aware proxies (such as Pomerium or Teleport) and scope resourceNames to non-system identities. secrets list , watch Kubernetes API trap: In Kubernetes RBAC, resourceNames does not restrict list or watch requests. Any rule granting list or watch on secrets returns the complete .data payload of every Secret in the namespace (or cluster). Never grant cluster-wide list or watch on secrets to human roles or CI runners. Grant get with explicit resourceNames where possible. serviceaccounts/token create Calls the TokenRequest subresource to mint a valid, signed projected JWT for any ServiceAccount in the namespace, allowing lateral movement into privileged operator SAs. Block serviceaccounts/token create for human users; reserve only for identity controllers. pods/exec , pods/attach create , get Executes arbitrary commands or attaches to streams inside a running pod, allowing theft of mounted projected tokens, memory inspection, or database credential extraction. Disable pods/exec and pods/attach in production namespaces; rely on structured logs and metrics. Require break-glass elevation for live debugging. pods/ephemeralcontainers update , patch Lets kubectl debug attach a new debug container (with arbitrary image and shared process namespace) into a running pod to inspect its filesystem, memory, and mounted credentials. Deny update and patch on pods/ephemeralcontainers in production namespaces outside audited break-glass roles. certificatesigningrequests/approval update Combined with create on certificatesigningrequests , allows an attacker to submit and self-approve a CSR for any username or group supported by the signer. Restrict CSR approval exclusively to automated controllers (such as cert-manager [ CNCF Graduated ] or kubelet-csr-approver ).
Deep Dive: The nodes/proxy GET to Container RCE Escalation
Even teams that carefully strip pods/exec and secrets from their RBAC roles frequently leave
Comments
No comments yet. Start the discussion.