RBAC permits impersonation

Impersonation can let users act with the permissions of other identities and requires strict control.

Description

impersonate permits API requests under the identity of a specified user, group or service account. Grant it only to administrators who need it and limit the identities they can use with resourceNames.

Potential impact

If a target identity has broader privileges, the caller can perform operations beyond their own permissions.

Remediation

Remove impersonation grants from ordinary accounts and check whether other roles still allow them. When reviewing audit records, check both the original caller and the identity used for the request.

Examples

The examples omit the bindings that would assign these ClusterRoles to accounts.

Before

yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: impersonator-role
rules:
  - apiGroups: [""]
    resources: ["users", "groups", "serviceaccounts"]
    verbs: ["impersonate"]

After

yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: impersonator-role-neg
rules:
  - apiGroups: [""]
    resources: ["serviceaccounts"]
    verbs: ["get"]

The second role permits only get on ServiceAccounts. Ordinary users and groups are not resources that can be retrieved from the Kubernetes API.

References