Skip to content

Lesson 2 of 13 · 11m

The Verbs That Escalate

escalate, bind, and impersonate sidestep the permission-holding rule, and pods/exec is a shell grant — the meta-verbs to audit first.

The permission-checking is recursive

Give someone create on clusterroles and you gave them everything, unless the API server stops them. It does — Kubernetes has privilege-escalation prevention built into RBAC itself, and understanding it is the difference between reading a role grant and predicting it.

The rules, from pkg/registry/rbac/escalation_check.go and friends:

  • Creating or updating a Role/ClusterRole requires that you already hold every permission the role grants — or that you have the escalate verb on roles/clusterroles.
  • Creating a RoleBinding/ClusterRoleBinding requires bind on the referenced role, or already holding the role's permissions.
  • kubectl --as requires impersonate on users, groups, or serviceaccounts, optionally narrowed by resourceNames.

escalate, bind, and impersonate are the meta-verbs. They are never in anyone's mental model and they are how a modest grant becomes cluster-admin. An operator who can bind the cluster-admin ClusterRole can hand it to a throwaway service account in one request. Audit for these three verbs explicitly; they should exist only on admin accounts.

Verbs that are shells and credential mints

Some resources are not what they look like:

  • pods/exec and pods/portforward are interactive shells inside running containers. Grant them and you granted a terminal, not a monitoring hook.
  • pods/ephemeralcontainers powers kubectl debug — it injects a fresh container into a running pod, sharing its network and process namespaces. Same risk class as exec.
  • serviceaccounts/token calls the TokenRequest API — it mints credentials for a service account on demand. kubectl create token ci-bot works precisely because of this verb.
  • certificatesigningrequests/approval approves CSRs — signing new client certificates, including ones naming system:masters.
  • secrets get/list/watch read every secret in scope. There is no "one secret only" list grant — resourceNames narrows get/update/delete but is ignored by list and watch.
  • nodes/proxy tunnels requests through the API server to the kubelet.
  • Wildcards (verbs: ["*"], apiGroups: ["*"], resources: ["*"]) are the definition of cluster-admin. Any custom role containing a wildcard deserves the same scrutiny as cluster-admin itself.

Two quieter escalation paths worth naming: aggregated ClusterRoles and subject impersonation by group. The default admin, edit, and view roles carry an aggregationRule that merges in any ClusterRole labeled to match — an addon can silently expand admin's power. And impersonation can target groups: impersonate on groups with resourceNames: ["system:masters"] is an instant cluster-admin jump, not a typo to wave through.

When the check itself broke

CVE-2018-1002105, disclosed December 2018, CVSS 9.8, was the first critical Kubernetes CVE. A specially crafted request to an aggregated API server — the extension path used by metrics-server and friends — let a caller reuse the API server's own TLS connection to the backend and send arbitrary requests authenticated as the API server. On default RBAC this turned a low-privilege user — and in some configurations an unauthenticated one — into effective cluster-admin. Fixed in 1.10.11, 1.11.5, and 1.12.3. The lesson that survives the patch: privilege boundaries live in code paths, and the aggregated-API path had its own.

What to actually do

kubectl get clusterroles -o json | \
  jq -r '.items[] | select(.rules[]? | (.verbs | index("escalate","bind","impersonate")) != null or index("*")) | .metadata.name'

Treat that output as sensitive. Audit it, and audit pods/exec-style grants with the same rigor as secrets — a shell in a production pod is a credential-harvesting position, because the pod's service account token and its environment are sitting right there in memory.

The plugin that inverts the audit question is kubectl-who-can (from Aqua Security): kubectl who-can create clusterrolebindings or kubectl who-can get secrets -A answers "who can do this" instead of "what can X do" — exactly the direction you need when hunting the forgotten binding that grants escalate, bind, or impersonate to a service account nobody remembers creating.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.