Kubernetes API Server Allows Anonymous Access

The Kubernetes API server accepts unauthenticated requests and authorises them to reach more than basic health and version information.

SeverityHigh
CVSS 3.17.5 CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N Open in the calculator
CVSS 4.08.7 CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N Open in the calculator
CWECWE-306: Missing Authentication for Critical Function
OWASP Top 10A07:2025 Authentication Failures
MITRE ATT&CKT1133 External Remote Services, T1613 Container and Resource Discovery, T1552.007 Container API
CategoryBroken Access Control

Description

The Kubernetes API server treats requests that carry no credentials, and are not rejected by another authentication method, as coming from the user system:anonymous in the group system:unauthenticated. Anonymous authentication is enabled by default, and in a default cluster these identities may only read a few discovery and health endpoints, such as /version, /healthz, /livez and /readyz.

The weakness arises when authorisation rules grant them more: a RoleBinding or ClusterRoleBinding to system:anonymous or system:unauthenticated, often added while troubleshooting, or the AlwaysAllow authorisation mode, which permits every request. An unauthenticated attacker who can reach the API server can then read whatever the anonymous bindings allow, and the risk is greatest when the API server is reachable from the internet.

Listing namespaces, pods and other resources, and reading pods, ConfigMaps and other objects, reveals the cluster's structure, images and environment variables, which often contain credentials. In the worst cases the bindings let the attacker read Secrets, which yields service account tokens and application credentials that can lead to full compromise of the cluster, or create or change workloads and so run code in the cluster directly.

The weakness can be confirmed by sending requests without an Authorization header to the API server, usually on port 6443 or 443, for example for /api/v1/namespaces or /api/v1/pods, and by reviewing role bindings for those subjects with kubectl get clusterrolebindings,rolebindings -A -o wide. A 403 Forbidden response naming system:anonymous shows that anonymous authentication is enabled but not authorised for that resource.

Remediation

  • Remove every RoleBinding and ClusterRoleBinding whose subjects include system:anonymous or system:unauthenticated, apart from the default system:public-info-viewer binding and, on kubeadm clusters, kubeadm:bootstrap-signer-clusterinfo, which new nodes need to read the public cluster-info ConfigMap when joining with a bootstrap token.
  • Make sure the API server uses the Node and RBAC authorisation modes and never AlwaysAllow.
  • Where nothing depends on anonymous requests, start the API server with --anonymous-auth=false. Check health checks and load balancer probes first, as some rely on anonymous access to the health endpoints; newer Kubernetes releases can instead limit anonymous access to named endpoints through the authentication configuration file.
  • Restrict network access to the API server to administrators, nodes and the systems that need it, rather than exposing it to the internet.
kubectl get clusterrolebindings,rolebindings -A -o json | jq -r '.items[] | select(any(.subjects[]?; .name == "system:anonymous" or .name == "system:unauthenticated")) | .metadata.name'

Confirm the fix by repeating the unauthenticated requests and checking that only the health and version endpoints respond, or that every request is refused with 401 Unauthorized.

References


Add This Finding to Your Library

In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.

Free trial  ·  No card required

Only need the reporting? Our reporting tool is free and open source, with the same library.


More Containers and Kubernetes Findings

Every Containers and Kubernetes finding