What is Kubernetes RBAC and what does it enforce?
Kubernetes Role-Based Access Control (RBAC) decides whether an authenticated subject may perform an API action.
- API server receives a request with a subject identity.
- API server evaluates RBAC rules against (verb, resource, namespace, name) and returns allow/deny.
- If denied, the API action does not execute.
How do Kubernetes Roles and ClusterRoles differ?
They differ by scope of what rules can apply to.
- Role: rules apply within one namespace.
- ClusterRole: rules can apply cluster-wide and can also be bound into namespaces.
- Bindings determine which subjects receive those rules in which scope.
How do RoleBindings and ClusterRoleBindings work?
Bindings attach RBAC rules to subjects.
- RoleBinding grants a Role or ClusterRole to subjects within a namespace scope.
- ClusterRoleBinding grants a ClusterRole to subjects across the cluster.
- API server uses bindings to map subject → effective rules before deciding allow/deny.
How does Kubernetes RBAC authorization work for an API request?
Step 1: API server authenticates the request to determine the subject (user, group, service account).
Step 2: API server collects RBAC rules from Roles/ClusterRoles referenced by bindings for that subject.
Step 3: API server matches request (verb, resource, namespace, name) to allowed rules.
Step 4: If a matching allow rule exists, request proceeds; otherwise it is denied.
What breaks Kubernetes RBAC in practice?
Cause → system behavior → security impact.
- Cause: broad ClusterRoleBindings or wildcard rules on sensitive resources.
- Behavior: many requests match allow rules, including actions not intended for that subject.
- Impact: compromise of one credential or pod enables cluster-wide changes or secret access.
What are Kubernetes authentication inputs (certs, tokens, OIDC)?
Authentication inputs are what the API server validates to determine who is calling.
- Client certificates: API server validates certificate chain and maps it to a user identity.
- Bearer tokens: API server validates token via configured authenticators and maps to a user/service account.
- OIDC (OpenID Connect): API server validates tokens issued by an OpenID Provider and maps claims to identity.
How does Kubernetes authenticate a request using a client certificate?
Step 1: Client presents a certificate during TLS connection setup.
Step 2: API server validates the certificate chain against configured client CA trust.
Step 3: API server extracts identity fields (subject, organizations) to form user and group values.
Step 4: API server uses that identity as the subject for RBAC authorization.
How does Kubernetes authenticate a request using a bearer token?
Step 1: Client sends an Authorization header with a token.
Step 2: API server validates the token using configured token authenticators.
Step 3: API server maps validated token to a subject identity (user/groups or service account).
Step 4: API server passes the subject into RBAC authorization.
What is OIDC for Kubernetes authentication?
OIDC (OpenID Connect) lets the API server accept identity tokens issued by an OpenID Provider.
- API server validates token signature and required claims (issuer, audience, expiry).
- API server maps claims (subject, groups) to Kubernetes user and group identity.
- RBAC then authorizes actions based on those identities.
What breaks Kubernetes authentication in practice?
Cause → system behavior → security impact.
- Cause: weak token validation constraints (wrong audience acceptance) or long-lived credentials.
- Behavior: stolen tokens or mis-accepted tokens authenticate successfully.
- Impact: attacker reaches RBAC with a valid subject identity and can act within granted permissions.
What are Kubernetes service accounts and how are they used?
A service account is an in-cluster identity used by pods to call the Kubernetes API.
- Pods can be configured to use a specific service account.
- The service account token is used as bearer authentication to the API server.
- RBAC permissions bound to the service account determine what that pod can do via the API.
How does a pod use a service account token to call the API server?
Step 1: Pod is associated with a service account.
Step 2: Pod obtains the service account token (mounted or requested via token API, depending on configuration).
Step 3: Pod sends API requests with the token as a bearer token.
Step 4: API server authenticates the token as that service account and applies RBAC to allow/deny.
What breaks service account token usage in-cluster?
Cause → system behavior → security impact.
- Cause: tokens are mounted broadly or tokens are readable by unintended processes in the pod.
- Behavior: attacker in the pod reads the token and replays it to the API server.
- Impact: attacker gains the service account’s RBAC permissions and can pivot through the Kubernetes API.
What is Kubernetes admission control?
Admission control is the API server stage that can modify or reject objects after authentication/authorization but before persistence.
- Mutating admission can change the object (defaults, injections).
- Validating admission can reject the object based on rules.
- If admission rejects, the object is not stored and the requested change does not happen.
How does validating vs mutating admission control differ?
They differ in what they are allowed to do to the request object.
- Mutating: can alter fields (add labels, inject sidecars, set defaults).
- Validating: evaluates final object and returns allow/deny without modifying it.
- Order matters because validation often runs after mutation so it can evaluate the final spec.
How does admission control enforce policy on object creation?
Step 1: User submits create/update request to API server.
Step 2: API server authenticates and authorizes the request (RBAC).
Step 3: Mutating admission runs and may modify the object.
Step 4: Validating admission runs and may reject the object.
Step 5: If allowed, API server persists the object; otherwise it returns an error.
What breaks admission control in practice?
Cause → system behavior → security impact.
- Cause: policy not enforced on all relevant operations or namespaces, or bypass via alternate API paths.
- Behavior: unsafe objects are accepted because no validator applies.
- Impact: attacker can deploy privileged pods or unsafe workloads that expand blast radius.
What are Pod Security controls (baseline/restricted mental model)?
Pod Security controls are enforcement rules that block pods with unsafe security context settings.
- Baseline blocks common risky settings while allowing many workloads.
- Restricted blocks a wider set and pushes toward least-privilege runtime settings.
- Enforcement happens at admission time: unsafe pod specs are rejected before they run.
How do Pod Security controls block unsafe pods?
Step 1: Pod spec is submitted to the API server.
Step 2: Pod Security evaluation checks the pod’s security-related fields against the selected profile.
Step 3: If the spec violates required constraints, admission denies the request.
Step 4: If allowed, the pod can be scheduled and started.
What breaks Pod Security controls in practice?
Cause → system behavior → security impact.
- Cause: enforcement mode not enabled or inconsistent across namespaces.
- Behavior: attackers create pods with risky settings because nothing rejects them.
- Impact: privileged workloads enable host access and easier container escapes.
What are Kubernetes NetworkPolicies?
NetworkPolicies define which pod-to-pod and pod-to-external network flows are allowed.
- Enforcement component matches traffic against policy based on pod labels, namespaces, ports, and direction.
- If no policy allows a flow (in a restricted namespace), the flow is blocked.
| Without an enforcing network policy engine, policies do not change traffic behavior.
How do NetworkPolicies enforce traffic rules?
Step 1: A packet/connection is initiated from a pod to a destination.
Step 2: Enforcement component identifies source/destination pods and their labels/namespaces.
Step 3: It evaluates NetworkPolicy rules for ingress/egress that apply to the pods.
Step 4: If a rule allows the flow, it passes; otherwise it is dropped or rejected.
What breaks NetworkPolicies in practice?
Cause → system behavior → security impact.
- Cause: no enforcing plugin or policies allow broad egress/ingress.
- Behavior: traffic is not actually restricted, or is restricted far less than assumed.
- Impact: lateral movement and data exfiltration paths remain open.
What are workload identity patterns (in-cluster vs cloud IAM)?
Workload identity patterns are how a pod proves identity to access services.
- In-cluster: identity is typically a Kubernetes service account used to access the Kubernetes API.
- Cloud IAM integration: identity can be mapped so pods obtain cloud credentials scoped to a pod/service account identity.
- The security property is least privilege through identity-specific authorization checks.