Summary
A critical authorization flaw in Kyverno allows a namespace-scoped NamespacedMutatingPolicy to target resources in another namespace through the generator library. A user who can create such policies may cause the cluster-wide admission controller to create or modify resources across namespace boundaries, potentially enabling privilege escalation.
Affected context
The issue affects Kyverno deployments using NamespacedMutatingPolicy resources in the affected 1.18 release range. It becomes risky when a user can create or modify a namespace-scoped policy and the admission controller has cluster-wide permissions to generate resources. The vulnerability is present when policy compilation validates syntax and semantics without enforcing the policy's namespace boundary during generator execution.
Exploit preconditions
- Attack surface: Kyverno policy creation and admission-controller processing
- Required access: Permission to create a NamespacedMutatingPolicy in at least one namespace
- Trigger point: Evaluation of the policy's CEL match conditions and generator operation
- Authorization context: The admission controller operates with permissions broader than the policy author's namespace
- Why exploitation is possible: Namespace scope is checked during compilation but is not enforced when the generator processes the target namespace
Why this happens
The vulnerability results from a mismatch between policy scope validation and runtime resource-generation authorization. The CEL compiler exposes generator functionality to match conditions, while validation confirms that the policy compiles without ensuring that generated resources remain within the policy namespace. The resource-generation path likewise accepts a cross-namespace target without rejecting it. This maps to CWE-862: Missing Authorization, because a namespace boundary is represented but not enforced when an operation is performed.
Potential impact
- Unauthorized creation or modification of resources in other namespaces
- Exposure or alteration of ConfigMaps, Secrets, and policy-related objects
- Creation of NetworkPolicies that may weaken network isolation
- Creation of RoleBindings that could grant additional permissions
- Privilege escalation from namespace-level access toward broader cluster access
- Disruption of workloads or security controls in unrelated namespaces
General mitigation guidance
Mitigation generally focuses on enforcing authorization boundaries at every policy execution and resource-generation layer.
Common defensive patterns include:
- Restricting generator operations to the namespace associated with the policy
- Rechecking target namespace authorization immediately before resource creation
- Treating policy-declared namespaces as untrusted input rather than authoritative scope
- Applying least-privilege permissions to admission controllers and generated-resource identities
- Separating policy compilation from authorization decisions and validating both independently
- Limiting which resource kinds a namespace-scoped policy may generate
- Using admission and RBAC policies to prevent unauthorized cross-namespace resource creation
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis of policy compilers and generators for missing scope or ownership checks
- Code review signals where namespace or tenant boundaries are validated only during parsing or compilation
- Tests that attempt cross-namespace generation from namespace-scoped policy objects
- Authorization-policy checks confirming that generated resource targets are independently validated
- Audit-log monitoring for unusual resource creation by the Kyverno admission-controller identity
- Alerts for namespace-scoped users creating RoleBindings, Secrets, NetworkPolicies, or other sensitive resources outside their namespace
- Automated security review tools that identify unchecked user-controlled namespace parameters

