summaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python/python3-pyjwt
diff options
context:
space:
mode:
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-pyjwt')
-rw-r--r--meta-python/recipes-devtools/python/python3-pyjwt/CVE-2026-32597.patch79
1 files changed, 79 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-pyjwt/CVE-2026-32597.patch b/meta-python/recipes-devtools/python/python3-pyjwt/CVE-2026-32597.patch
new file mode 100644
index 0000000000..7fec45e13c
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-pyjwt/CVE-2026-32597.patch
@@ -0,0 +1,79 @@
1From c77d816548bd768df262ba0204904168584c0bd1 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Jos=C3=A9=20Padilla?= <jpadilla@webapplicate.com>
3Date: Thu, 12 Mar 2026 12:46:08 -0400
4Subject: [PATCH] Merge commit from fork
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Co-authored-by: José Padilla <jpadilla@users.noreply.github.com>
10
11CVE: CVE-2026-32597
12Upstream-Status: Backport [https://github.com/jpadilla/pyjwt/commit/051ea341b5573fe3edcd53042f347929b92c2b92]
13
14Dropped changes to the changelog, version bump and tests during backport.
15
16Signed-off-by: Ankur Tyagi <ankur.tyagi85@gmail.com>
17---
18 jwt/api_jws.py | 27 +++++++++++++++++++++++++--
19 1 file changed, 25 insertions(+), 2 deletions(-)
20
21diff --git a/jwt/api_jws.py b/jwt/api_jws.py
22index 654ee0b..db2c80f 100644
23--- a/jwt/api_jws.py
24+++ b/jwt/api_jws.py
25@@ -137,7 +137,7 @@ class PyJWS:
26 header: dict[str, Any] = {"typ": self.header_typ, "alg": algorithm_}
27
28 if headers:
29- self._validate_headers(headers)
30+ self._validate_headers(headers, encoding=True)
31 header.update(headers)
32
33 if not header["typ"]:
34@@ -208,6 +208,8 @@ class PyJWS:
35
36 payload, signing_input, header, signature = self._load(jwt)
37
38+ self._validate_headers(header)
39+
40 if header.get("b64", True) is False:
41 if detached_payload is None:
42 raise DecodeError(
43@@ -327,14 +329,35 @@ class PyJWS:
44 if not alg_obj.verify(signing_input, prepared_key, signature):
45 raise InvalidSignatureError("Signature verification failed")
46
47- def _validate_headers(self, headers: dict[str, Any]) -> None:
48+ # Extensions that PyJWT actually understands and supports
49+ _supported_crit: set[str] = {"b64"}
50+
51+ def _validate_headers(
52+ self, headers: dict[str, Any], *, encoding: bool = False
53+ ) -> None:
54 if "kid" in headers:
55 self._validate_kid(headers["kid"])
56+ if not encoding and "crit" in headers:
57+ self._validate_crit(headers)
58
59 def _validate_kid(self, kid: Any) -> None:
60 if not isinstance(kid, str):
61 raise InvalidTokenError("Key ID header parameter must be a string")
62
63+ def _validate_crit(self, headers: dict[str, Any]) -> None:
64+ crit = headers["crit"]
65+ if not isinstance(crit, list) or len(crit) == 0:
66+ raise InvalidTokenError("Invalid 'crit' header: must be a non-empty list")
67+ for ext in crit:
68+ if not isinstance(ext, str):
69+ raise InvalidTokenError("Invalid 'crit' header: values must be strings")
70+ if ext not in self._supported_crit:
71+ raise InvalidTokenError(f"Unsupported critical extension: {ext}")
72+ if ext not in headers:
73+ raise InvalidTokenError(
74+ f"Critical extension '{ext}' is missing from headers"
75+ )
76+
77
78 _jws_global_obj = PyJWS()
79 encode = _jws_global_obj.encode