Summary
A critical authorization boundary bypass in Kyverno's namespaced Policy apiCall feature allows policies to trigger Kubernetes API requests using the Kyverno admission controller ServiceAccount without being constrained to the policy's namespace.
Any authenticated user who can create a namespaced Policy may indirectly issue cross-namespace or cluster-scoped API calls through Kyverno, breaking namespace isolation and potentially enabling unauthorized reads and writes across the cluster.
Affected context
This vulnerability affects Kyverno deployments where:
- The Kyverno admission controller is installed with a ServiceAccount that has permissions beyond a single namespace.
- Namespaced Kyverno Policies can use the
apiCallrule to make Kubernetes API requests viaurlPath. - Regular users, developers, or automation have rights to create or modify namespaced Kyverno Policies.
In such environments, the admission controller executes apiCall requests using its own RBAC privileges, and due to missing namespace scoping on urlPath, those requests can target resources anywhere that ServiceAccount is allowed to access.
Exploit preconditions
- Attack surface: Kubernetes API server via Kyverno admission controller (Policy creation/updates).
- Required access:
- An authenticated Kubernetes identity.
- Permission to create or update namespaced Kyverno Policy objects in at least one namespace.
- Trigger point:
- Creation or modification of a namespaced Policy that uses
apiCallwith a craftedurlPathand context variable substitutions. - Admission events that cause Kyverno to evaluate and execute the policy's
apiCall. - Why exploitation is possible:
- The resolved
urlPathinapiCallis executed with the Kyverno admission controller ServiceAccount identity. - No enforcement ensures that the
urlPathis restricted to the Policy's namespace. - Attackers can leverage context variables to dynamically construct paths that target cross-namespace or cluster-scoped resources within the ServiceAccount's RBAC envelope.
Why this happens
The bug stems from Kyverno's policy execution model treating apiCall requests as trusted, system-level operations without sufficiently binding them to the originating namespace or user.
Specifically:
- The
urlPathin namespaced Policies is resolved and then executed under the Kyverno admission controller ServiceAccount. - Namespace isolation assumptions are not enforced at the
apiCalllayer; there is no check that the constructed path addresses only resources in the Policy's namespace. - Context variable substitution allows the policy author to shape the final
urlPathat runtime, enabling arbitrary path construction within the ServiceAccount's RBAC scope.
This aligns with CWE-269: Improper Privilege Management, because a lower-privileged actor can cause actions to be executed with higher-privileged credentials, and is conceptually related to CWE-918 where backend requests are issued under a more trusted identity than the caller.
Potential impact
- Unauthorized cross-namespace reads of Kubernetes resources such as:
- ConfigMaps
- Secrets (where the Kyverno ServiceAccount has read permissions)
- Other namespaced objects (Deployments, Pods, Services, etc.).
- Cluster-scoped or cross-namespace writes, for example:
- Creating or modifying ClusterPolicies.
- Mutating resources in other namespaces.
- Modifying cluster-scoped configuration objects allowed by the ServiceAccount's RBAC.
- Escalation of privileges from a limited, namespace-scoped user to the effective privileges of the Kyverno admission controller ServiceAccount.
- Compromise of multi-tenant isolation boundaries by enabling one tenant's policies to interact with another tenant's resources.
- Potential stepping stone for broader cluster compromise if Kyverno's ServiceAccount is highly privileged.
General mitigation guidance
Mitigation focuses on tightening privilege boundaries, constraining policy-driven API calls, and reducing the blast radius of any misbehaving policy:
- Constrain Kyverno ServiceAccount privileges:
- Apply least-privilege RBAC to the Kyverno admission controller ServiceAccount.
- Avoid granting broad cluster-admin or unrestricted read access unless strictly necessary.
- Scope and gate
apiCallusage: - Prefer patterns that do not require arbitrary API calls from within policies.
- Restrict who can define policies that use
apiCall, treating them as high-risk capabilities. - Consider separating roles for "policy authors with apiCall" from general developers.
- Reinforce namespace isolation:
- Align RBAC, Kyverno policies, and naming conventions so that Kyverno's permissions are scoped per namespace where feasible.
- Use separate instances or ServiceAccounts per trust boundary (e.g., per tenant or environment) where operationally possible.
- Harden policy lifecycle:
- Introduce peer review or security approval for high-impact policies (especially those invoking
apiCall). - Use policy-as-code workflows with code review and automated checks instead of ad-hoc in-cluster edits.
- Defense-in-depth controls:
- Monitor and audit Kyverno's API interactions using Kubernetes audit logs.
- Apply network policies or admission controls that limit unintended access paths even for controller ServiceAccounts.
How teams detect issues like this
Detection can combine code/policy review, configuration analysis, and runtime monitoring:
- Policy and configuration review:
- Regularly review Kyverno Policies that use
apiCall, focusing on: - Dynamic or variable-based
urlPathconstruction. - Attempts to reference cluster-scoped or cross-namespace resource paths.
- Implement internal guidelines flagging or prohibiting unbounded
apiCallusage.
- Static and automated checks:
- Use policy-as-code scanners or static analysis tools to:
- Detect Policies that employ
apiCallwithout explicit namespace scoping. - Flag patterns where
urlPathcan resolve to cluster-level APIs or foreign namespaces. - Integrate these checks into CI pipelines for Kyverno policy repositories.
- RBAC and posture assessment:
- Periodically analyze the Kyverno admission controller ServiceAccount RBAC:
- Identify over-privileged roles or cluster-wide permissions.
- Alert on drift from baseline least-privilege configurations.
- Runtime logging and audit:
- Enable and review Kubernetes API audit logs, focusing on:
- Requests issued by the Kyverno admission controller ServiceAccount targeting unexpected namespaces or cluster-scoped resources.
- Surges in ClusterPolicy creation or cross-namespace access originating from Kyverno.
- Correlate suspicious API patterns back to specific Kyverno Policies for targeted remediation.

