On November 24, Akamai published the story behind a CVSS 10.0 bug in Kyverno, the CNCF policy engine a lot of teams use to keep Kubernetes tenants inside their own namespaces. The fix shipped in Kyverno 1.19.2. The cause was a single character: ?.

A user who was only allowed to write policies in the default namespace could make Kyverno read ConfigMaps from kube-system, and then read the stolen data back out of an admission error message. Akamai says 4% of the enterprise networks in its telemetry were running vulnerable Kyverno instances.

I don't think the interesting part is Kubernetes. The interesting part is that the validator and the HTTP client disagreed about what the URL meant, and that is a bug I can write in Python in about four lines. So I did, and then I wrote the version I'd actually ship.

What happened, in plain terms

Kyverno policies can fetch extra data during admission with an apiCall block. The policy author gives a urlPath, and Kyverno, which runs with broad cluster permissions, makes that request. Since that is an obvious confused-deputy risk, an earlier fix (CVE-2026-22039) added a check: a namespaced policy may only call URLs inside its own namespace.

The check worked like this, according to the Kyverno security advisory GHSA-pcx2-xcq4-65vf:

  1. Percent-decode the path with url.PathUnescape.
  2. Normalize it with Go's path.Clean.
  3. Match this regex and compare the captured namespace with the policy's namespace:
^/api(s)?/.*?/namespaces/([^/]+)/?.*$ 

path.Clean is a file-path function. In a file name, ? is just a character. So this input:

/api/v1/configmaps?x=/namespaces/default/ 

came out of the cleaner almost unchanged, the regex found /namespaces/default/ inside the query string, and the check passed. Then Kyverno handed the original string to client-go, which parsed it as a URL: path /api/v1/configmaps, query x=/namespaces/default/. The API server ignored the unknown parameter and returned ConfigMaps from every namespace.

To get the data out, the proof of concept used a policy that always denies, with a message template like LEAKED DATA: {{ leakedData }}. Creating any ConfigMap triggered the policy, and the denial message shown to the attacker contained the secret value.

Two separate lessons are in there:

  • Parser differential: the code that checks a URL and the code that uses it must parse it the same way.
  • Validate-then-use-something-else: Kyverno validated the cleaned path but executed the raw one. The advisory calls this out as a TOCTOU-style flaw in its own right.

And a bonus one: error messages that interpolate fetched data are an exfiltration channel.

The same bug in Python

Most of our work is Django and Python, so here's a faithful port of the vulnerable check. posixpath.normpath plays the role of path.Clean:

import posixpath, re from urllib.parse import unquote NS = re.compile(r'^/api(s)?/.*?/namespaces/([^/]+)/?.*$') def naive_allowed(path: str, allowed: str = "default") -> bool: clean = posixpath.normpath(unquote(path)) m = NS.match(clean) return bool(m and m.group(2) == allowed) 

Then I asked requests what it would actually send for each input, by preparing a request and looking at the path of the final URL:

import requests from urllib.parse import urlsplit def sent_path(path: str) -> str: r = requests.Request("GET", "https://k8s.internal" + path).prepare() return urlsplit(r.url).path 

Results on Python 3.13, requests 2.34.2, urllib3 2.8.0:

Input Naive check Path requests sends
/api/v1/namespaces/default/configmaps/allowed allowed same
/api/v1/namespaces/kube-system/secrets blocked same
/api/v1/configmaps?x=/namespaces/default/ allowed /api/v1/configmaps
/api/v1/secrets#/namespaces/default/ allowed /api/v1/secrets
/api/v1/nodes%3Fx=/namespaces/default/ allowed /api/v1/nodes%3Fx=/namespaces/default/
/api/v1/namespaces/default/../../nodes blocked /api/v1/nodes

Rows three and four are the Kyverno bug, and the fragment version is new to me: # is just as invisible to normpath as ?, and the HTTP client drops the fragment before sending.

Row five is the reverse mistake. Decoding before splitting turns %3F into a real ? in the validator's copy, while the client sends the encoded form. Here that probably just produces a 404, but "the validator and the sender saw different strings" is exactly the condition you never want.

Row six surprised me in a good way: the naive check blocked it, but only because normpath collapsed .. and the result had no namespace. Notice that urllib3 also removed the dot segments before sending. Your validator and your client both normalizing is fine; it's when only one of them does that you get a gap.

A check I'd actually ship

The fix pattern from the advisory works in any language: parse with a URL parser first, validate the parsed pieces, and send exactly the string you validated. I'd also make it strict, because a server-side fetch built from user input has no business containing a query string it doesn't understand.

import posixpath from urllib.parse import urlsplit def strict_allowed(path: str, allowed: str = "default") -> tuple[bool, str]: u = urlsplit(path) if u.scheme or u.netloc or u.query or u.fragment: return False, "rejected: query/fragment/host" raw = u.path if "%" in raw: return False, "rejected: encoded chars" clean = posixpath.normpath(raw) if clean != raw.rstrip("/"): return False, "rejected: not canonical" parts = clean.split("/") # /api/v1/namespaces/<ns>/... or /apis/<group>/<version>/namespaces/<ns>/... i = 3 if parts[1] == "api" else 4 if parts[1] == "apis" else None if i is None or len(parts) <= i + 1 or parts[i] != "namespaces": return False, "rejected: not namespaced" return parts[i + 1] == allowed, clean 

Then the caller uses the second return value, never the original input:

ok, canonical = strict_allowed(user_path, allowed=tenant.namespace) if not ok: raise PermissionDenied(canonical) resp = session.get(K8S_BASE + canonical, timeout=5) 

Against the same six inputs, it allowed the first, blocked the second, and rejected the other four with a reason. Some design notes:

  • Position, not pattern. The namespace is read from a fixed path segment. The original regex's lazy .*? let /namespaces/ match anywhere, which is why a query string could satisfy it.
  • Reject, don't repair. I refuse non-canonical input instead of normalizing it and continuing. If someone sends .. or %2F to an internal API proxy, I'd rather see a 403 in the logs than guess what they meant.
  • One string. Validation and execution share canonical. That alone would have stopped the Kyverno bypass, even with the weak regex.

If you need query parameters (say labelSelector), build them yourself from an allowlist and pass them as params=, so they can never be confused with the path.

Where this shows up in ordinary web apps

You probably don't have a Kubernetes API proxy. You almost certainly have one of these:

Redirect targets. ?next= handling is the classic parser differential. Browsers follow the WHATWG URL rules, which treat \ like / in http(s) URLs. Python's urlsplit doesn't. I ran a "starts with / or contains our host" check next to Django's built-in helper on Django 6.1.3:

from django.utils.http import url_has_allowed_host_and_scheme url_has_allowed_host_and_scheme(target, allowed_hosts={"app.example.com"}, require_https=True) 
Target Naive check urlsplit().hostname Django helper
/dashboard allowed None allowed
//evil.test/x allowed evil.test blocked
/\evil.test/x allowed None blocked
https://app.example.com@evil.test/ allowed evil.test blocked
https://evil.test?next=https://app.example.com/ allowed evil.test blocked

The /\evil.test/x row is the scary one: Python's own parser says "no host," so even a check based on urlsplit would let it through, while a browser would go to evil.test. Use the framework helper; it exists because people kept getting this wrong.

Webhook and import URLs (SSRF). If users give you a URL to fetch, validate the parsed hostname after DNS resolution, against the IP you actually connect to. Checking the string and then letting the HTTP library resolve it again is the same validate-one-thing, use-another pattern.

Internal proxies and BFFs. Any /proxy/<path> endpoint that forwards to an internal service with a service account is a small Kyverno. Same rules: parse, check segments, forward the canonical string, and never forward raw user input.

Error messages. Kyverno's leak worked because a denial message echoed fetched data. In Django, the equivalent is a validation error or a DRF exception detail that includes a value from another system. Keep user-facing errors generic and log the details server-side.

What to do this week

  1. If you run Kyverno, upgrade to 1.19.2 or later. Then review who can create namespaced Policy objects; in multi-tenant clusters that permission is often handed out widely, and it was the only one this attack needed.
  2. Grep your code for URL checks built on string tools: startswith("/"), in url, regexes over a full URL, and normpath on anything that came from a request.
  3. For each one, ask: does the code that checks this value use the exact same string as the code that sends it?
  4. Replace hand-written redirect checks with url_has_allowed_host_and_scheme.
  5. Add the six payloads from the table above as unit tests for any path validator. They take a minute to write and they encode a CVSS 10 lesson.

If you're designing tenant boundaries from scratch, I'd put isolation as low in the stack as you can and treat every "deputy" with broad permissions as the risky part. We collected the patterns we use for that in our multi-tenant architecture guide.

The takeaway

Kyverno's maintainers had already thought about this exact attack and shipped a fix for it. The bypass still got through because two pieces of code read one string two different ways. That will keep happening anywhere we validate text and then hand it to a parser.

So I'm curious where you land: when you validate URLs from users, do you reject anything non-canonical, or do you normalize and carry on? And has a parser differential ever bitten you in production?