This message is not a bug but one of Kubernetes' most important protections: whoever may create roles can only grant permissions they hold themselves. Otherwise any account with create roles could promote itself at will.
Symptom
kubectl create role self-secrets --verb=get --resource=secrets \
--as=system:serviceaccount:attacker:default -n attacker
Error from server (Forbidden): roles.rbac.authorization.k8s.io "self-secrets" is
forbidden: user "system:serviceaccount:attacker:default" ... is attempting to grant
RBAC permissions not currently held:
{APIGroups:[""], Resources:["secrets"], Verbs:["get"]}
A service account with create on roles tries to give itself read access to secrets.
Diagnosis
Check that the account has no escalate – then the protection applies.
kubectl auth can-i escalate roles --as=system:serviceaccount:attacker:default -n attacker
Causes
ProtectionEscalation protection applies
The account has create on roles but no get on secrets itself. So it may not create a role with that permission.
escalateDangerous: escalate and bind
If the account gets the verbs escalate and bind, the protection is gone – it writes the permissions for itself.
kubectl create role self-secrets --verb=get,list --resource=secrets \ --as=system:serviceaccount:attacker:default -n attacker kubectl create rolebinding self-secrets --role=self-secrets \ --serviceaccount=attacker:default \ --as=system:serviceaccount:attacker:default -n attacker kubectl auth can-i list secrets --as=system:serviceaccount:attacker:default -n attacker role.rbac.authorization.k8s.io/self-secrets created rolebinding.rbac.authorization.k8s.io/self-secrets created yes
Fix
Don't: Do not give the account escalate or bind to make the message go away – that disables exactly the protection that just saved you.
Attacking and securing Kubernetes, Day 3: impersonation and escalate – how RBAC verbs lead to privilege escalation.
Go to day 3 →
FAQ
How do I find accounts with escalate or bind?
With kubectl auth can-i escalate roles --as=<account> per account, or by searching all roles and cluster roles for these verbs.
Can an admission policy help?
Yes, Kyverno can block RBAC objects with impersonate or escalate at creation time.