InsightsSecurity
Auditing Kubernetes RBAC: the permissions that quietly equal cluster-admin
Which RBAC grants let a user escalate to full control without holding cluster-admin, such as escalate, bind, impersonate, nodes/proxy and listing Secrets, and how to find them in a running cluster and tighten them safely.
Published November 26, 20268 min read
Most RBAC reviews start and end with one question: who is bound to cluster-admin? That is the right first question and a poor last one. Kubernetes RBAC is purely additive, with no deny rules, and several permissions that look modest let their holder reach the same place by another route. A role that can list Secrets, create Pods or bind to other roles is, in practice, a path to more access than its name suggests.
This article lists the grants worth hunting for, shows how to find them in a live cluster, and describes how to remove them without breaking the controllers and pipelines that depend on them. The claims below come from the RBAC reference and the RBAC good practices page.
The grants that equal more than they say
| Permission | Why it is more than it looks |
|---|---|
get, list or watch on secrets | list and watch also reveal Secret contents. kubectl get secrets -A -o yaml returns all of them. |
create on pods or workload resources | Pods can run as any ServiceAccount in the namespace, so the holder gains that account's API access, and can mount Secrets, ConfigMaps and PersistentVolumes. |
create on persistentvolumes | Includes hostPath volumes, which give a Pod access to the node's filesystem. |
get on nodes/proxy | Reaches the Kubelet API, which allows command execution in every Pod on the node, and bypasses audit logging and admission control. It is not read-only. |
escalate on roles or clusterroles | Lets the holder write roles with more rights than they have. |
bind on roles | Lets the holder create bindings to roles whose rights they do not hold. |
impersonate | Lets the holder act with the rights of other users or groups. |
create on serviceaccounts/token | Issues tokens for existing service accounts. |
create on CSRs plus update on certificatesigningrequests/approval for the kubernetes.io/kube-apiserver-client signer | Can mint client certificates with arbitrary names, including names of system components. |
create, update or patch on validating or mutating webhook configurations | Controls webhooks that can read every admitted object, and mutate it in the mutating case. |
patch on namespaces | Changes namespace labels, which can loosen Pod Security Admission for that namespace. |
None of these is a bug. Controllers, GitOps tools and operators legitimately need some of them. The audit question is whether each holder needs it, at that scope, and whether you know who it is.
Step 1: find the bindings that matter most
Start with the subjects that carry the most weight. These commands need only kubectl and jq:
# Every ClusterRoleBinding to cluster-admin, with its subjects
kubectl get clusterrolebindings -o json | jq -r '
.items[]
| select(.roleRef.name == "cluster-admin")
| .metadata.name as $b
| (.subjects // [])[]
| [$b, .kind, .name, (.namespace // "-")] | @tsv'
# Bindings that grant anything to unauthenticated or all authenticated users
kubectl get clusterrolebindings,rolebindings -A -o json | jq -r '
.items[]
| . as $o
| (.subjects // [])[]
| select(.name == "system:unauthenticated" or .name == "system:authenticated")
| [$o.kind, $o.metadata.name, .name] | @tsv'The default cluster has a few expected results in the second query: system:discovery, system:basic-user and system:public-info-viewer are bound to system:authenticated, and the last one also to system:unauthenticated. Anything beyond those deserves an explanation. The good practices page advises reviewing bindings for system:unauthenticated and removing them where possible, because they give access to anyone who can reach the API server over the network.
Also look for membership of the system:masters group. That group is bound to cluster-admin, but it bypasses RBAC checks entirely, so removing a RoleBinding or ClusterRoleBinding does not revoke it. If a certificate with O=system:masters was issued for a person or a pipeline, revoking it means replacing the credentials, and nothing in RBAC will show it. The only trace is in how the certificate was issued, so check your issuance process and kubeconfig files.
Step 2: find the roles that contain the risky verbs
Search the rules, not the bindings. This query lists roles and cluster roles that grant escalate, bind or impersonate, or use a wildcard verb or resource:
kubectl get clusterroles,roles -A -o json | jq -r '
.items[]
| . as $o
| (.rules // [])[]
| select(
((.verbs // []) | any(. == "*" or . == "escalate" or . == "bind" or . == "impersonate"))
or ((.resources // []) | any(. == "*"))
)
| [$o.kind, ($o.metadata.namespace // "-"), $o.metadata.name,
(.verbs | join(",")), ((.resources // []) | join(","))] | @tsv'Expect many hits from the built-in system: roles and from operators you installed. Filter those out by name prefix and read what remains. For each remaining hit, find who is bound to it, since a risky role that nobody uses is a cleanup item, not an incident.
Do the same for the table above: search for secrets, nodes/proxy, serviceaccounts/token, persistentvolumes and the webhook configuration resources. Remember that aggregated ClusterRoles collect rules from other ClusterRoles through labels, so the built-in admin and edit roles may include rules contributed by CRDs you installed. Read them as they exist in the cluster, not as documented.
Step 3: ask the API what a subject can actually do
Reading YAML shows intent. Asking the API server shows the result after all bindings are merged. kubectl auth can-i can check a single action, and --list prints everything a subject may do in a namespace. Both can be run as another subject if you have the right to impersonate:
# One action, as a CI service account
kubectl auth can-i list secrets -n payments \
--as=system:serviceaccount:ci:deployer
# Everything that account can do in a namespace
kubectl auth can-i --list -n payments \
--as=system:serviceaccount:ci:deployerRun this for the accounts you rely on most: your deployment pipeline, your GitOps controller, monitoring agents and anything that runs with a token outside the cluster. A deploy account that can list Secrets in every namespace is common and rarely intended. If you hold the impersonate right, this is also a reminder of how strong it is.
Step 4: tighten without breaking things
RBAC changes fail quietly: a controller loses a permission and logs a forbidden error that nobody reads until a rollout stalls. A safer order:
- Turn on audit logging for authorization failures, or at least collect API server logs, before changing anything, so that
forbiddenresponses are visible. Compare the count before and after each change. - Replace ClusterRoleBindings with RoleBindings where a subject only works in a few namespaces. A RoleBinding can reference a ClusterRole, so you can keep a shared role and grant it per namespace.
- Give each workload its own ServiceAccount. Default RBAC grants no permissions to service accounts outside
kube-systembeyond API discovery, but thedefaultaccount in a namespace is shared by every Pod that names no other account, so any permission you add to it reaches all of them. - Stop mounting tokens that Pods do not use with
automountServiceAccountToken: false. - Replace wildcards with lists. Write the resources and verbs the subject uses. It is more text and it keeps future resource types out.
- Preview before applying. If you manage RBAC from manifests,
kubectl auth reconcile -f rbac.yaml --dry-run=clientshows what would change. By default it keeps extra permissions and subjects, and with--remove-extra-permissionsand--remove-extra-subjectsit removes them, so run the preview first.
Do not edit the default system: roles and bindings by hand. The API server reconciles them at every start-up, adding missing permissions and subjects, so manual removals disappear. You can opt a role out with the rbac.authorization.kubernetes.io/autoupdate: "false" annotation, but the documentation warns that missing default permissions can leave the cluster non-functional. Fix exposure by controlling who holds the binding, not by trimming built-in roles.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: deployer
namespace: payments
rules:
- apiGroups: ["apps"]
resources: ["deployments"]
verbs: ["get", "list", "watch", "patch"]
- apiGroups: [""]
resources: ["services", "configmaps"]
verbs: ["get", "list", "watch", "create", "update", "patch"]This role cannot read Secrets, create Pods directly or touch roles. A Deployment it patches still creates Pods through the controller, using the ServiceAccount named in the Pod template, which is why that template is the next thing to constrain.
Close the workload path
Because creating Pods implies access to other resources in the namespace, the Pod-creation right deserves a second control. The good practices page recommends enforcing the Baseline or Restricted Pod Security Standard where you do not fully trust the principal creating Pods, and it describes boundaries inside a namespace as weak. Both points matter here: Pod Security Admission stops a Pod from asking for a privileged mode or hostPath, and separate namespaces separate trust levels. Quotas and limit ranges also address the denial-of-service route the page describes, where a user with create rights fills the cluster with large or numerous objects.
The cloud side matters too. If a ServiceAccount maps to a cloud role, a permission to create Pods as that account is also a permission on the cloud role, which is covered in least-privilege IAM.
Keep it reviewed
RBAC drifts, so make the review routine:
- Run the queries above on a schedule and diff the output. A new ClusterRoleBinding to
cluster-admin, or a newsystem:authenticatedsubject, should raise a ticket. - Remove bindings for people who left. The good practices page also notes that an attacker who creates a user with the same name as a deleted user can inherit its rights, so delete the binding, not just the account.
- Keep human access to
cluster-adminshort and logged. The page suggests using impersonation of a low-privileged account for routine work, withcluster-adminkept for when it is needed. - Record the owner of each powerful ServiceAccount, such as the GitOps controller. When the person who set it up moves on, the permission remains.
An RBAC audit does not need a new tool to start. Three queries, one pass through kubectl auth can-i --list for your most powerful accounts, and a rule that every wildcard, bind, escalate and impersonate has a named owner will find most of what matters.