A subject that holds the Kubernetes impersonate verb can act as any user, group or service account it is allowed to name, and inherits everything that identity can do. Impersonation is a legitimate feature used by administrators, access proxies and platform controllers, yet a single broad grant quietly turns a low-privilege account into a path to cluster-admin. This guide explains how impersonation is processed by the API server, how to scope it with resourceNames and the newer constrained impersonation verbs, and how to find and audit impersonated requests. It is written for Kubernetes platform and security engineers who own RBAC and audit policy. It builds on the Kubernetes RBAC Guide and goes deeper on this one verb.
Key takeaways
- Impersonation swaps the identity before authorisation. The API server authenticates the caller, checks the impersonate permission, then evaluates the request entirely as the impersonated user.
- The classic verb is all or nothing. Permission to impersonate an identity grants every action that identity can perform, across all namespaces, so it must be treated like holding that identity's credentials.
- Always pin
resourceNames. A rule onusers,groupsorserviceaccountswithout named values lets the holder become anyone, including members ofsystem:masters. - Constrained impersonation narrows the action as well as the identity. The
impersonate:<mode>andimpersonate-on:<mode>:<verb>verbs, beta and on by default from Kubernetes v1.36, let you allow only specific operations while impersonating. - Every impersonated request is auditable. Audit events carry both
userandimpersonatedUser, which makes impersonation one of the easier privilege paths to monitor if an audit policy is in place.
How impersonation works
The Kubernetes documentation describes impersonation as a way for an authenticated user to act as another user, group or service account through HTTP headers. The request passes through five steps: the client sends its own credentials plus impersonation headers, the API server authenticates the real caller, it checks that the caller holds impersonation privileges for each value supplied, it replaces the request's user information with the impersonated values, and authorisation then runs against the impersonated identity only. Audit records the original caller alongside the substituted identity.
| Header | Purpose | kubectl flag | Notes from the docs |
|---|---|---|---|
Impersonate-User | Username to act as | --as | Required for all other impersonation headers |
Impersonate-Group | Group to act as; may be repeated | --as-group | Optional; requires Impersonate-User |
Impersonate-Uid | Unique identifier for the impersonated user | --as-uid (kubectl 1.23) | Available from API server 1.22; no format imposed |
Impersonate-Extra-<name> | Extra user attributes, such as scopes | --as-user-extra (kubectl 1.35) | Name must be lower case; non-legal header characters percent-encoded |
Service accounts are impersonated by username, in the form system:serviceaccount:<namespace>:<name>, and nodes as system:node:<name>. The SelfSubjectReview API (kubectl auth whoami) returns the impersonated identity when called with impersonation headers, which is useful for confirming what a proxy is actually sending.
The impersonate verb in RBAC
To set a header, the caller needs the impersonate verb on the matching resource. The resources live in two API groups, and missing the second group is a common reason a rule appears not to work.
| Header | RBAC apiGroup | Resource | Scope of the grant |
|---|---|---|---|
Impersonate-User (human or other user) | "" (core) | users | Cluster-wide: needs ClusterRole and ClusterRoleBinding |
Impersonate-Group | "" (core) | groups | Cluster-wide |
Impersonate-User naming a service account | "" (core) | serviceaccounts | Grant can be namespaced, but the service account can act outside that namespace |
Impersonate-Uid | authentication.k8s.io | uids | Cluster-wide |
Impersonate-Extra-scopes (example) | authentication.k8s.io | userextras/scopes | Cluster-wide; one subresource per extra name |
The documentation is explicit that impersonating a user or group is not namespace scoped, because the impersonated identity can do anything it is permitted to do anywhere. A Role and RoleBinding cannot express user or group impersonation; only a ClusterRole bound with a ClusterRoleBinding can. The Kubernetes RBAC good practices page lists impersonate alongside escalate, bind, nodes/proxy and CSR approval as permissions that let holders gain rights beyond what the role appears to grant.
Scoping impersonation with resourceNames
The classic verb can be narrowed only by restricting which values the headers may carry. Do this for every rule. A support role that needs to reproduce a developer's view of the cluster might look like this:
1 Sample only, based on the public documentation cited. Assess it independently against the current official documentation, test outside production and back up first.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: support-impersonate-dev-view
rules:
- apiGroups: [""]
resources: ["users"]
verbs: ["impersonate"]
resourceNames: ["dev-readonly"]
- apiGroups: [""]
resources: ["groups"]
verbs: ["impersonate"]
resourceNames: ["developers"]Points to check when writing these rules:
- Name the group as well as the user: if
groupsis granted withoutresourceNames, the holder can addsystem:mastersto any impersonated user and bypass RBAC entirely, because that group skips authorisation checks and webhooks. - Choose low-privilege targets: impersonating a named identity is only as safe as that identity. Pick dedicated read-only users or groups as targets, never an administrator.
- Treat service account targets as workload credentials: naming a controller's service account grants everything that controller can do. Prefer a purpose-built service account with a narrow role.
- Avoid wildcards:
verbs: ["*"]on any resource includesimpersonate, andresources: ["*"]withimpersonatecovers users, groups and service accounts together.
Constrained impersonation
The upstream docs note that with the classic verb impersonation "either grants full impersonation or none at all". Constrained impersonation, controlled by the ConstrainedImpersonation feature gate (alpha in v1.35, beta and enabled by default from v1.36 according to the feature gate reference checked in November 2026), splits the grant into two permissions: who may be impersonated, and what may be done while impersonating. All verbs use the authentication.k8s.io group.
| Mode | Applies when the impersonated user | Identity verb | Action verb |
|---|---|---|---|
| user-info | Does not start with system:serviceaccount: or system:node: | impersonate:user-info | impersonate-on:user-info:<verb> |
| serviceaccount | Is a service account | impersonate:serviceaccount | impersonate-on:serviceaccount:<verb> |
| arbitrary-node | Starts with system:node:, any node | impersonate:arbitrary-node | impersonate-on:arbitrary-node:<verb> |
| associated-node | Is the node the impersonating service account is bound to | impersonate:associated-node | impersonate-on:associated-node:<verb> |
The action verbs are granted on the real target resource (for example pods in one namespace) through an ordinary Role or ClusterRole, so a controller can be allowed to impersonate a user only to list and watch pods in default. Existing impersonate rules keep working: the API server checks constrained permissions first and falls back to the classic verb. That fallback means adopting constrained impersonation does not remove risk until the old broad rules are deleted. Check your distribution and version before relying on it, and check managed service release notes, since providers control feature gates.
Legitimate uses
| Use | Who holds the verb | Safer pattern |
|---|---|---|
| Testing what a user or service account can do | Platform administrators | Run kubectl auth can-i --list --as=... as an administrator; for delegated testers, grant impersonation only to named low-privilege test identities |
| Reduced-privilege daily administration | Administrators using a low-privilege account | The RBAC good practices page suggests a low-privilege account with impersonation rights to avoid accidental changes; pair with short-lived credentials and alerting on each elevation |
| Access proxies and multi-cluster consoles | A proxy's service account | Proxy authenticates the human, then impersonates them; restrict resourceNames to the groups the proxy maps, and protect the proxy credential as tier zero |
| Node agents reading their own node's pods | A DaemonSet service account | Constrained impersonate:associated-node with impersonate-on:associated-node:list and get instead of cluster-wide pod read |
| Controllers acting on behalf of tenants | An operator or GitOps controller | Impersonate a per-tenant service account so the tenant's RBAC limits what is applied; use constrained verbs to limit actions |
Each of these holders is a non-human identity whose token now carries the combined reach of every identity it can impersonate. Inventory and rotate those tokens as you would any privileged credential: see the Kubernetes Service Account Token Guide and the Kubernetes NHI Security Guide.
Abuse risk explained
From a defender's point of view, the verb matters because it converts one credential into many. The main risk combinations are:
- Unscoped
groupsimpersonation: equivalent to cluster-admin, throughsystem:masters, which cannot be revoked by removing bindings. - Impersonation of controller service accounts: controllers often hold
secretsread, workload creation orbind; impersonating them inherits all of it. - Impersonation plus
bindorescalate: a holder can create a binding that grants itself broader impersonation, defeating any later scoping. The ATT&CK technique T1098 Account Manipulation describes this class of change. - Stolen tokens of proxy or controller identities: whoever holds the token holds the impersonation rights, a form of T1078 Valid Accounts. Secrets exposure inside clusters makes this likely: see the Kubernetes Secrets Security Guide.
- Node impersonation:
impersonate:arbitrary-nodeor classic impersonation ofsystem:node:*names gives the API access of a node identity. Reserve it for agents that genuinely need it and prefer associated-node.
Auditing impersonated requests
Kubernetes logs nothing unless kube-apiserver is started with --audit-policy-file, and a policy with zero rules is invalid. At the Metadata level every event records the requesting user, verb and resource, which is enough to see impersonation. Managed services expose the same events through their control-plane logging, which usually has to be switched on.
| Audit field | What it shows | Detection use |
|---|---|---|
user.username | The real authenticated caller | Attribute the action to the human or service account behind it |
impersonatedUser.username and .groups | The identity the request ran as | Alert on system:masters, system:node:*, admin users or controller service accounts |
authenticationMetadata.impersonationConstraint | Constrained verb used, such as impersonate:user-info | Confirm traffic is moving off the classic verb |
sourceIPs, userAgent | Origin and client (user agent is client supplied, not trusted) | Spot impersonation from unexpected networks or tools |
verb, objectRef, responseStatus.code | Action, target and result | Repeated 403s while impersonating suggest probing |
Annotation apiserver.latency.k8s.io/impersonation | Impersonation processing time for slow non-watch requests | Performance troubleshooting only |
Alongside audit logs, kube-apiserver exposes the metric apiserver_impersonation_attempts_total{mode, decision}, where mode legacy counts use of the classic verb. Watch RBAC changes as well: create, update or patch on clusterroles, roles and their bindings where the rules include impersonate. The Kubernetes Audit Log Detection Guide covers pipeline design, and Reading Service Account Activity in Kubernetes Audit Logs covers service account attribution.
Metrics that show control
- Number of subjects holding
impersonate, by role, with a target of a short, documented list. - Percentage of impersonate rules with
resourceNamesset (target 100%). - Count of rules granting
impersonatethrough wildcards (target zero). - Share of impersonated requests using constrained verbs versus
legacymode, trending up after rollout. - Time from an alert on impersonation of a privileged identity to triage.
Rolling out restrictions safely
- Inventory: export all ClusterRoles and Roles and list every rule whose verbs include
impersonateor*, then map each to its bindings and subjects. - Observe: with audit at
Metadata, collect two to four weeks ofimpersonatedUservalues per caller to learn real usage. - Scope: rewrite each rule with
resourceNamesmatching observed values; test withkubectl auth can-i impersonate users/<name> --as=<holder>in a non-production cluster first. - Constrain: where your version supports it, add constrained verbs for controllers and proxies, then delete the classic rules, since the server falls back to them.
- Roll back: keep the previous manifests in version control and re-apply them if a proxy or controller breaks; failures appear as 403 responses with the impersonated identity in audit.
- Prevent drift: add an admission or CI policy that rejects new
impersonaterules withoutresourceNames. See the Kubernetes Admission Control Guide.
Framework mapping
| Framework | Reference | How it applies |
|---|---|---|
| NIST SP 800-53 Rev 5 | AC-6 Least Privilege; AC-6(9) Log Use of Privileged Functions | Scope impersonation by name; audit every impersonated request |
| NIST SP 800-53 Rev 5 | AU-2, AU-12, AU-6 | Audit policy enabled, events generated and reviewed |
| NIST CSF 2.0 | PR.AA-05; DE.CM-03 | Entitlements reviewed under least privilege; activity monitored |
| MITRE ATT&CK v20 | T1078 Valid Accounts; T1098 Account Manipulation | Use of stolen holder tokens; bindings changed to widen impersonation |
Practitioner checklist
- List every subject that holds
impersonatedirectly or through*, and record an owner and reason for each. - Add
resourceNamesto every impersonate rule, and never allow unscopedgroupsimpersonation. - Remove anyone other than break-glass identities from
system:mastersand alert on its impersonation. - Use dedicated low-privilege identities as impersonation targets for support and testing.
- Adopt constrained impersonation for controllers, proxies and node agents where your version supports it, then delete the classic rules.
- Enable an audit policy at least at
Metadataand alert on privilegedimpersonatedUservalues. - Monitor RBAC changes that add
impersonate,bindorescalate. - Protect and rotate the tokens of every identity that can impersonate, as tier-zero credentials.
Standards and references
- Kubernetes: User Impersonation
- Kubernetes: Feature Gates (ConstrainedImpersonation)
- Kubernetes: Role Based Access Control Good Practices
- Kubernetes: Using RBAC Authorization
- Kubernetes: Auditing
- Kubernetes: Authenticating
- NIST: SP 800-53 Rev. 5 Security and Privacy Controls
Related NHI Mgmt Group resources: Kubernetes RBAC Guide · How to audit Kubernetes cluster admin bindings · Kubernetes Audit Log Detection Guide · Kubernetes NHI Security Guide