PrivEsc and RBAC Exploitation
This section contains few vectors on how to gain privileges inside a K8S cluster.
Overview
Once initial access is gained to a Kubernetes cluster, the next critical phase involves escalating privileges to gain broader access to cluster resources. This section focuses on exploiting Role-Based Access Control (RBAC) misconfigurations, service account abuse, and various privilege escalation techniques specific to Kubernetes environments.
RBAC Architecture Understanding
Before trying to exploit the RBAC model inside K8S we need to understand the hierarchy behind it.
RBAC Components
# RBAC Hierarchy
ClusterRole/Role → ClusterRoleBinding/RoleBinding → Subject (User/Group/ServiceAccount)Key RBAC Objects:
Role: Permissions within a specific namespace
ClusterRole: Cluster-wide permissions
RoleBinding: Binds Role to subjects within namespace
ClusterRoleBinding: Binds ClusterRole to subjects cluster-wide
ServiceAccount: Pod identity for API access
Permission Model
Since K8S uses declarative syntax, the .yml file containing the permission definition should look like this:
Service Account Token Abuse
Service account impersonation allows us to act as another user or service account by abusing Kubernetes API impersonation features. If the attacker’s current identity is permitted to impersonate other principals, they can directly assume higher-privileged identities and access sensitive resources without stealing credentials, leading to rapid privilege escalation.
RBAC Misconfiguration Exploitation
RBAC misconfiguration exploitation occurs when an we have permission to create or modify RoleBindings or ClusterRoleBindings. By binding our own service account to highly privileged roles such as cluster-admin, either imperatively or via malicious YAML manifests, we can escalate privileges and gain full control over the cluster.
Creating Malicious RoleBindings:
YAML-based Privilege Escalation
Pod Creation and Manipulation
Pod creation and manipulation enables us, with sufficient permissions, to execute code at a highly privileged level. By creating privileged pods with access to host namespaces and filesystems, we can break container isolation and interact directly with the underlying node.
Alternatively, modifying existing pods or deployments to inject backdoor or sidecar containers allows persistent access while blending into legitimate workloads, often without immediate detection.
Privileged Pod for Host Access:
Pod Modification and Injection
Here by modifying an existing Pod deployment configuration we can add a new privileged container or a sidecar to gain:
Note on Network Pivoting
Network pivoting is a mandatory step to fully compromise a K8S cluster. Tools such as Ligolo or Chisel allow us to tunnel traffic through compromised pods and reach internal services that are not exposed to the Internet.
For example, after compromising an Internet‑facing web pod, an attacker may use it as a pivot to obtain a reverse shell on an internal pod. If egress rules are misconfigured or overly permissive, the non‑exposed pod can initiate outbound connections through the proxy or gateway and successfully reach the attacker’s listener, enabling lateral movement inside the cluster.
Ligolo-ng (my go to tool):
Last updated
Was this helpful?