The vulnerability is a denial of service in the Kyverno controller caused by an unsafe type assertion in the ForEach function located in pkg/engine/mutate/mutation.go. When a Kyverno Policy or ClusterPolicy is created with a forEach mutation where the patchesJson6902 field contains a variable that resolves to nil, the code attempts a type assertion on a nil value, which triggers a panic.
This panic causes the Kyverno background controller to crash and enter a CrashLoopBackOff state, effectively disabling background policy enforcement and other background tasks. The admission controller is also affected, as it will drop connections for any resource operations that match the malicious policy, blocking those operations.
The identified vulnerable functions are github.com/kyverno/kyverno/pkg/engine/mutate.ForEach, which contains the faulty code, and github.com/kyverno/kyverno/pkg/engine/handlers/mutation.(*forEachMutator).mutateElements and github.com/kyverno/kyverno/pkg/engine/handlers/mutation.(*forEachMutator).mutateForEach, which are on the direct call path leading to the panic and would appear in a runtime profile during exploitation. The patch addresses the issue by replacing the unsafe type assertion with a safe one, preventing the panic.