<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Kyverno — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/vendors/kyverno/</link><description>Trending threats, MITRE ATT&amp;CK coverage, and detection metadata — refreshed continuously.</description><generator>Hugo</generator><language>en</language><managingEditor>hello@craftedsignal.io</managingEditor><webMaster>hello@craftedsignal.io</webMaster><lastBuildDate>Sat, 27 Jan 2024 12:00:00 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/vendors/kyverno/feed.xml" rel="self" type="application/rss+xml"/><item><title>Kyverno Controller Denial of Service via forEach Mutation Panic</title><link>https://feed.craftedsignal.io/briefs/2024-01-kyverno-dos/</link><pubDate>Sat, 27 Jan 2024 12:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-01-kyverno-dos/</guid><description>An unchecked type assertion in Kyverno versions v1.13.0 to v1.17.1 allows a user with permission to create a Policy or ClusterPolicy to crash the cluster-wide background controller into a persistent CrashLoopBackOff, leading to a denial of service, by crafting a malicious policy that triggers a nil pointer dereference in the forEach mutation handler.</description><content:encoded><![CDATA[<p>A denial-of-service vulnerability exists in the <code>forEach</code> mutation handler of Kyverno, a Kubernetes policy engine. Specifically, Kyverno versions v1.13.0 through v1.17.1 are susceptible to a flaw where an unchecked type assertion within the <code>ForEach</code> function in <code>pkg/engine/mutate/mutation.go</code> can be triggered by a specially crafted <code>Policy</code> or <code>ClusterPolicy</code>. Any user with the ability to create these policy types can exploit this vulnerability. When a <code>patchesJson6902</code> field contains a variable substitution (e.g., <code>{{ element.nonexistent }}</code>) that resolves to <code>nil</code> at runtime, the type assertion <code>.(string)</code> on a nil <code>interface{}</code> triggers an unrecoverable Go panic. This results in the background controller entering a persistent CrashLoopBackOff state, effectively halting background processing. The admission controller will also drop connections and block matching resource operations. CEL-based policies are unaffected.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>An attacker crafts a malicious <code>Policy</code> or <code>ClusterPolicy</code> YAML manifest containing a <code>forEach</code> rule.</li>
<li>The crafted rule includes a <code>patchesJson6902</code> field with a variable substitution, such as <code>{{ element.nonexistent }}</code>, designed to resolve to <code>nil</code> at runtime.</li>
<li>The attacker applies the malicious policy to the Kubernetes cluster. This requires appropriate permissions to create <code>Policy</code> or <code>ClusterPolicy</code> resources.</li>
<li>When a resource matching the policy&rsquo;s <code>match</code> criteria is created or updated, the Kyverno admission controller attempts to apply the policy.</li>
<li>The <code>ForEach</code> function in <code>pkg/engine/mutate/mutation.go</code> is invoked, processing the <code>patchesJson6902</code> field.</li>
<li>The variable substitution resolves to <code>nil</code>, leading to a bare type assertion failure: <code>fe[&quot;patchesJson6902&quot;].(string)</code>.</li>
<li>This triggers an unrecoverable Go panic, causing either the background controller (if triggered by <code>mutateExisting</code> rules) or the admission controller to terminate the connection.</li>
<li>The background controller enters a CrashLoopBackOff state due to the persistent <code>UpdateRequest</code> resources that re-trigger the panic on every restart, achieving a denial-of-service.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation of this vulnerability leads to a denial of service affecting Kyverno&rsquo;s core functionalities within the Kubernetes cluster. An attacker can crash the background controller, halting critical background tasks such as generate rules, mutateExisting rules, and cleanup processes. The admission controller can also be affected, dropping connections and blocking resource operations that match the malicious policy&rsquo;s criteria. If a ClusterPolicy is used, this block extends cluster-wide. This vulnerability allows even users with limited, namespace-scoped permissions (via Policy creation) to impact the entire cluster, thus escalating privileges.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Upgrade to Kyverno version v1.17.2 or later to patch the vulnerability (see Overview).</li>
<li>Deploy the Sigma rule <code>Detect Kyverno Policy with Suspicious forEach</code> to identify potentially malicious policies containing <code>forEach</code> loops with <code>patchesJson6902</code> fields that could trigger the vulnerability.</li>
<li>Monitor Kyverno controller logs for &ldquo;panic: interface conversion: interface {} is nil, not string&rdquo; errors, indicating a potential exploitation attempt (see Attack Chain, step 7).</li>
<li>Implement strict RBAC policies to limit the ability to create or modify Kyverno <code>Policy</code> and <code>ClusterPolicy</code> resources (see Impact).</li>
</ul>
]]></content:encoded><category domain="severity">medium</category><category domain="type">advisory</category><category>kyverno</category><category>denial-of-service</category><category>kubernetes</category><category>policy-engine</category></item></channel></rss>