KCSA · Domain 3: Kubernetes Security Fundamentals · 22% of the exam
Task 3.4: Authorization
Authorization modes, RBAC Roles, ClusterRoles and bindings, aggregation, escalation-prone verbs and checking access with kubectl auth can-i.
Study it
Authentication and authorization with RBAC
Lesson coming
Sample questions
Try each one before opening the answer. Every option is explained, with the CNCF documentation page that proves it.
Question 1 · choose 1
A team lead holds a Role in namespace web that allows create on rolebindings and full access to Deployments and Services, and nothing else. The lead tries to create a RoleBinding in web that binds a colleague to the built-in admin ClusterRole, and the API server refuses. Which grant would let the lead create that binding without receiving the permissions in admin?
Aget and list on clusterroles, so that the API server can confirm admin's rules
Bcreate on clusterrolebindings, since the escalation check applies only to RoleBindings
Cupdate on clusterroles, so that the lead can trim admin before binding it
DThe bind verb on the admin ClusterRole
Show the answer and why
Aget and list on clusterroles, so that the API server can confirm admin's rules
Incorrect
Reading a role grants none of its permissions and is not the bind permission, so the escalation check still refuses the binding.
Bcreate on clusterrolebindings, since the escalation check applies only to RoleBindings
Incorrect
The same rule applies to ClusterRoleBindings: the creator needs the referenced role's permissions or the bind verb.
Cupdate on clusterroles, so that the lead can trim admin before binding it
Incorrect
Editing a role is itself limited by escalation prevention, and changing the shared admin role would affect every binding to it.
DThe bind verb on the admin ClusterRole
Correct
A role binding can be created only by someone who already holds all permissions of the referenced role at that scope or who is authorized to use the bind verb on that role.
RBAC prevents escalation through bindings: you can create or update a role binding only if you already have every permission in the referenced role, at the binding's scope, or have the bind verb on that role. Granting bind on the admin ClusterRole permits the binding without handing the lead those permissions directly.
A team installs a CustomResourceDefinition for backups.example.com. Users bound to the built-in view ClusterRole must be able to get and list backups, with no change to their bindings. An engineer proposes adding the rule directly to the view ClusterRole. What should be done instead?
AEdit view anyway, after annotating it so that API server auto-reconciliation leaves it alone
BAdd the backup rules to the existing system:aggregate-to-view ClusterRole
CCreate a ClusterRole with the backup rules and the label rbac.authorization.k8s.io/aggregate-to-view: "true"
DAdd an aggregation rule to the CustomResourceDefinition that selects the view ClusterRole
Show the answer and why
AEdit view anyway, after annotating it so that API server auto-reconciliation leaves it alone
Incorrect
view is built by aggregation, and the control plane overwrites manually specified rules of an aggregated ClusterRole with the rules it selects.
BAdd the backup rules to the existing system:aggregate-to-view ClusterRole
Incorrect
That is a default role, which auto-reconciliation restores on API server restart, so manual changes to it are lost.
CCreate a ClusterRole with the backup rules and the label rbac.authorization.k8s.io/aggregate-to-view: "true"
Correct
view is an aggregated ClusterRole; the control plane adds the rules of every ClusterRole carrying that label to it.
DAdd an aggregation rule to the CustomResourceDefinition that selects the view ClusterRole
Incorrect
aggregationRule is a field of ClusterRole; a CustomResourceDefinition has no such field.
Default user-facing roles such as view, edit and admin are aggregated ClusterRoles. To extend them for a custom resource, create a separate ClusterRole labeled rbac.authorization.k8s.io/aggregate-to-view: "true" (or -edit, -admin); its rules are combined into the default role, and nobody's binding changes.
A user needs rights in only one namespace. What do the Kubernetes RBAC good practices recommend for granting them?
AA RoleBinding, which gives the rights only within that namespace
BA ClusterRoleBinding, so that the rights also cover future namespaces
CA ClusterRoleBinding to the built-in cluster-admin role
DA wildcard rule on all resources in that namespace
Show the answer and why
AA RoleBinding, which gives the rights only within that namespace
Correct
The good practices say to assign permissions at the namespace level where possible, using RoleBindings rather than ClusterRoleBindings.
BA ClusterRoleBinding, so that the rights also cover future namespaces
Incorrect
A ClusterRoleBinding grants the rights in every namespace, broader than the user needs.
CA ClusterRoleBinding to the built-in cluster-admin role
Incorrect
That grants full rights across the whole cluster, far more than one namespace needs.
DA wildcard rule on all resources in that namespace
Incorrect
The good practices advise avoiding wildcard permissions where possible.
Least privilege in RBAC starts with scope: grant rights at the namespace level with RoleBindings wherever possible, avoid wildcards, and keep cluster-wide bindings for the cases that need them.
What does the AlwaysAllow authorization mode do, and when does the Kubernetes documentation say to use it?
AIt allows read requests only; use it for monitoring users
BIt allows all requests; use it only when authorization is not needed
CIt allows requests that RBAC has already allowed; use it together with RBAC
DIt blocks all requests; use it for testing
Show the answer and why
AIt allows read requests only; use it for monitoring users
Incorrect
AlwaysAllow allows every request, reads and writes alike.
BIt allows all requests; use it only when authorization is not needed
Correct
The authorization page says AlwaysAllow allows all requests, which brings security risks, and should be used only if you do not require authorization.
CIt allows requests that RBAC has already allowed; use it together with RBAC
Incorrect
It allows everything; combined with RBAC it makes RBAC ineffective because nothing is ever denied.
DIt blocks all requests; use it for testing
Incorrect
That describes AlwaysDeny.
AlwaysAllow bypasses authorization entirely, and even listed together with other modes it allows anything they have no opinion on. The documentation limits it to cases where authorization is not required, such as testing.