python3-pyjwt: Security fixes
cover python3-pyjwt: Security fixes
From: Hetvi Thakar <[email protected]>
Use this body before the automatically generated patch list and diffstat:
This series backports the upstream PyJWT security fixes for the following CVEs to python3-pyjwt 2.12.1:
- CVE-2026-101917
- CVE-2026-101918
- CVE-2026-102267
- CVE-2026-102268
- CVE-2026-102269
- CVE-2026-102270
- CVE-2026-102271
- CVE-2026-102274
- CVE-2026-102275
- CVE-2026-103001
CVE-2026-102268 and CVE-2026-102270 are addressed by the same upstream commit and are therefore included in one patch.
Each fix was selected from the upstream commit referenced by its corresponding PyJWT security advisory.
Validation performed:
- The complete series applies cleanly to the Wrynose branch.
- bitbake python3-pyjwt -c patch -f completed successfully.
- bitbake core-image-minimal completed successfully.
Hetvi Thakar (9):
python3-pyjwt: fix CVE-2026-103001
python3-pyjwt: fix CVE-2026-102274
python3-pyjwt: fix CVE-2026-102269
python3-pyjwt: fix CVE-2026-102267
python3-pyjwt: fix CVE-2026-102268 and CVE-2026-102270
python3-pyjwt: fix CVE-2026-102271
python3-pyjwt: fix CVE-2026-101917
python3-pyjwt: fix CVE-2026-102275
python3-pyjwt: fix CVE-2026-101918
.../python/files/CVE-2026-101917.patch | 311 ++++++++++++++++++ .../python/files/CVE-2026-101918.patch | 122 +++++++ .../python/files/CVE-2026-102267.patch | 223 +++++++++++++ .../CVE-2026-102268_CVE-2026-102270.patch | 113 +++++++ .../python/files/CVE-2026-102269.patch | 133 ++++++++ .../python/files/CVE-2026-102271.patch | 136 ++++++++ .../python/files/CVE-2026-102274.patch | 63 ++++ .../python/files/CVE-2026-102275.patch | 82 +++++ .../python/files/CVE-2026-103001.patch | 128 +++++++ .../python/python3-pyjwt_2.12.1.bb | 10 +- 10 files changed, 1320 insertions(+), 1 deletion(-) create mode 100644 meta-python/recipes-devtools/python/files/CVE-2026-101917.patch create mode 100644 meta-python/recipes-devtools/python/files/CVE-2026-101918.patch create mode 100644 meta-python/recipes-devtools/python/files/CVE-2026-102267.patch create mode 100644 meta-python/recipes-devtools/python/files/CVE-2026-102268_CVE-2026-102270.patch create mode 100644 meta-python/recipes-devtools/python/files/CVE-2026-102269.patch create mode 100644 meta-python/recipes-devtools/python/files/CVE-2026-102271.patch create mode 100644 meta-python/recipes-devtools/python/files/CVE-2026-102274.patch create mode 100644 meta-python/recipes-devtools/python/files/CVE-2026-102275.patch create mode 100644 meta-python/recipes-devtools/python/files/CVE-2026-103001.patch
Signature · 1 line
2.35.6
PATCH 1/9 python3-pyjwt: fix CVE-2026-103001
From: Hetvi Thakar <[email protected]>
This patch applies the upstream fix as referenced in [2], using the commit shown in [1].
[1] https://github.com/jpadilla/pyjwt/commit/0c87c8c8b1a74cac99ad8115f3050efcb7fbed35
[2] https://github.com/jpadilla/pyjwt/security/advisories/GHSA-gvp8-978c-rx2q
--- .../python/files/CVE-2026-103001.patch | 128 ++++++++++++++++++ .../python/python3-pyjwt_2.12.1.bb | 2 +- 2 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 meta-python/recipes-devtools/python/files/CVE-2026-103001.patch
meta-python/recipes-devtools/python/files/CVE-2026-103001.patch new file +128 -0
@@ -0,0 +1,128 @@ +From 0c87c8c8b1a74cac99ad8115f3050efcb7fbed35 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jos=C3=A9=20Padilla?= <[email protected]> +Date: Tue, 8 Sep 2026 15:10:07 -0400 +Subject: [PATCH] Merge commit from fork +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: José Padilla <[email protected]> + +CVE: CVE-2026-103001 +Upstream-Status: Backport [https://github.com/jpadilla/pyjwt/commit/0c87c8c8b1a74cac99ad8115f3050efcb7fbed35] + +(cherry picked from commit 0c87c8c8b1a74cac99ad8115f3050efcb7fbed35) +Signed-off-by: Hetvi Thakar <[email protected]> +--- + jwt/api_jwt.py | 20 +++++++++------- + tests/test_api_jwt.py | 56 +++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 67 insertions(+), 9 deletions(-) + +diff --git a/jwt/api_jwt.py b/jwt/api_jwt.py +index 429c2d7..f298ea9 100644 +--- a/jwt/api_jwt.py ++++ b/jwt/api_jwt.py +@@ -76,16 +76,18 @@ class PyJWT: + if options is None: + return self.options + ++ merged_options = cast("Options", dict(options)) ++ + # (defensive) set defaults for verify_x to False if verify_signature is False +- if not options.get("verify_signature", True): +- options["verify_exp"] = options.get("verify_exp", False) +- options["verify_nbf"] = options.get("verify_nbf", False) +- options["verify_iat"] = options.get("verify_iat", False) +- options["verify_aud"] = options.get("verify_aud", False) +- options["verify_iss"] = options.get("verify_iss", False) +- options["verify_sub"] = options.get("verify_sub", False) +- options["verify_jti"] = options.get("verify_jti", False) +- return {**self.options, **options} ++ if not merged_options.get("verify_signature", True): ++ merged_options["verify_exp"] = merged_options.get("verify_exp", False) ++ merged_options["verify_nbf"] = merged_options.get("verify_nbf", False) ++ merged_options["verify_iat"] = merged_options.get("verify_iat", False) ++ merged_options["verify_aud"] = merged_options.get("verify_aud", False) ++ merged_options["verify_iss"] = merged_options.get("verify_iss", False) ++ merged_options["verify_sub"] = merged_options.get("verify_sub", False) ++ merged_options["verify_jti"] = merged_options.get("verify_jti", False) ++ return {**self.options, **merged_options} + + def encode( + self, +diff --git a/tests/test_api_jwt.py b/tests/test_api_jwt.py +index 8b54204..dd28816 100644 +--- a/tests/test_api_jwt.py ++++ b/tests/test_api_jwt.py +@@ -1,6 +1,7 @@ + import json + import time + from calendar import timegm ++from collections.abc import MutableMapping + from datetime import datetime, timedelta, timezone + from decimal import Decimal + +@@ -38,6 +39,61 @@ def payload() -> dict[str, object]: + + + class TestJWT: ++ def test_decode_does_not_mutate_options_when_signature_verification_is_disabled( ++ self, jwt: PyJWT ++ ) -> None: ++ options: Options = {"verify_signature": False} ++ token = jwt.encode({"claim": "value"}, "a" * 32, algorithm="HS256") ++ original_options = options.copy() ++ ++ jwt.decode(token, options=options) ++ ++ assert options == original_options ++ ++ def test_reused_options_do_not_disable_claim_verification(self, jwt: PyJWT) -> None: ++ options: Options = {"verify_signature": False} ++ token = jwt.encode({"exp": utc_timestamp() - 1}, "a" * 32, algorithm="HS256") ++ ++ jwt.decode(token, options=options) ++ options["verify_signature"] = True ++ ++ with pytest.raises(ExpiredSignatureError): ++ jwt.decode(token, "a" * 32, algorithms=["HS256"], options=options) ++ ++ def test_decode_complete_preserves_mutable_mapping_input(self, jwt: PyJWT) -> None: ++ class MappingWithoutCopy(MutableMapping[str, object]): ++ def __init__(self, values: dict[str, object]) -> None: ++ self.values = values ++ ++ def __getitem__(self, key: str) -> object: ++ return self.values[key] ++ ++ def __setitem__(self, key: str, value: object) -> None: ++ self.values[key] = value ++ ++ def __delitem__(self, key: str) -> None: ++ del self.values[key] ++ ++ def __iter__(self): ++ return iter(self.values) ++ ++ def __len__(self) -> int: ++ return len(self.values) ++ ++ options = MappingWithoutCopy({"verify_signature": False}) ++ token = jwt.encode({"claim": "value"}, "a" * 32, algorithm="HS256") ++ ++ jwt.decode_complete(token, options=options) # type: ignore[arg-type] ++ ++ assert dict(options) == {"verify_signature": False} ++ ++ def test_constructor_does_not_mutate_options_input(self, jwt: PyJWT) -> None: ++ options: Options = {"verify_signature": False} ++ ++ PyJWT(options=options) ++ ++ assert options == {"verify_signature": False} ++ + def test_jwt_with_options(self) -> None: + jwt = PyJWT(options={"verify_signature": False}) + assert jwt.options["verify_signature"] is False +-- +2.35.6
meta-python/recipes-devtools/python/python3-pyjwt_2.12.1.bb +1 -1
@@ -10,6 +10,7 @@ SRC_URI += "file://CVE-2026-48522.patch \ file://CVE-2026-48524.patch \ file://CVE-2026-48525.patch \ file://CVE-2026-48526.patch \ + file://CVE-2026-103001.patch \ " SRC_URI[sha256sum] = "c74a7a2adf861c04d002db713dd85f84beb242228e671280bf709d765b03672b"
@@ -25,4 +26,3 @@ RDEPENDS:${PN} = "\ " BBCLASSEXTEND = "native nativesdk" -
Signature · 1 line
2.35.6
PATCH 2/9 python3-pyjwt: fix CVE-2026-102274
In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)From: Hetvi Thakar <[email protected]>
This patch applies the upstream fix as referenced in [2], using the commit shown in [1].
[1] https://github.com/jpadilla/pyjwt/commit/8915570a0bfda9f0ff0e34e7fb09bdb9d71580cf
[2] https://github.com/jpadilla/pyjwt/security/advisories/GHSA-w6j9-cwv2-h6wq
--- .../python/files/CVE-2026-102274.patch | 63 +++++++++++++++++++ .../python/python3-pyjwt_2.12.1.bb | 1 + 2 files changed, 64 insertions(+) create mode 100644 meta-python/recipes-devtools/python/files/CVE-2026-102274.patch
meta-python/recipes-devtools/python/files/CVE-2026-102274.patch new file +63 -0
@@ -0,0 +1,63 @@ +From 8915570a0bfda9f0ff0e34e7fb09bdb9d71580cf Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jos=C3=A9=20Padilla?= <[email protected]> +Date: Tue, 8 Sep 2026 16:13:35 -0400 +Subject: [PATCH] Skip malformed JWKs in JWK sets + +CVE: CVE-2026-102274 +Upstream-Status: Backport [https://github.com/jpadilla/pyjwt/commit/8915570a0bfda9f0ff0e34e7fb09bdb9d71580cf] + +(cherry picked from commit 8915570a0bfda9f0ff0e34e7fb09bdb9d71580cf) +Signed-off-by: Hetvi Thakar <[email protected]> +--- + jwt/api_jwk.py | 7 ++++++- + tests/test_api_jwk.py | 17 +++++++++++++++++ + 2 files changed, 23 insertions(+), 1 deletion(-) + +diff --git a/jwt/api_jwk.py b/jwt/api_jwk.py +index 4ae7cc3..5ee26b4 100644 +--- a/jwt/api_jwk.py ++++ b/jwt/api_jwk.py +@@ -79,7 +79,12 @@ class PyJWK: + f"Unable to find an algorithm for key: {self._jwk_data}", + ) from None + +- self.key = self.Algorithm.from_jwk(self._jwk_data) ++ try: ++ self.key = self.Algorithm.from_jwk(self._jwk_data) ++ except ValueError as error: ++ raise InvalidKeyError( ++ f"Unable to construct key from JWK: {error}" ++ ) from error + + @staticmethod + def from_dict(obj: JWKDict, algorithm: str | None = None) -> PyJWK: +diff --git a/tests/test_api_jwk.py b/tests/test_api_jwk.py +index 221e2e2..b081034 100644 +--- a/tests/test_api_jwk.py ++++ b/tests/test_api_jwk.py +@@ -224,6 +224,23 @@ class TestPyJWK: + + + class TestPyJWKSet: ++ @crypto_required ++ def test_should_skip_malformed_rsa_key_and_load_remaining_keys(self) -> None: ++ with open(key_path("jwk_rsa_key.json")) as keyfile: ++ malformed_key = json.loads(keyfile.read()) ++ ++ malformed_key["d"] = "AAAAAA" ++ for parameter in ("p", "q", "dp", "dq", "qi"): ++ del malformed_key[parameter] ++ ++ with open(key_path("jwk_rsa_pub.json")) as keyfile: ++ valid_key = json.loads(keyfile.read()) ++ ++ jwk_set = PyJWKSet.from_dict({"keys": [malformed_key, valid_key]}) ++ ++ assert len(jwk_set.keys) == 1 ++ assert jwk_set.keys[0].key_type == "RSA" ++ + @crypto_required + def test_should_load_keys_from_jwk_data_dict(self) -> None: + algo = RSAAlgorithm(RSAAlgorithm.SHA256) +-- +2.35.6
meta-python/recipes-devtools/python/python3-pyjwt_2.12.1.bb +1 -0
@@ -11,6 +11,7 @@ SRC_URI += "file://CVE-2026-48522.patch \ file://CVE-2026-48525.patch \ file://CVE-2026-48526.patch \ file://CVE-2026-103001.patch \ + file://CVE-2026-102274.patch \ " SRC_URI[sha256sum] = "c74a7a2adf861c04d002db713dd85f84beb242228e671280bf709d765b03672b"
Signature · 1 line
2.35.6
PATCH 3/9 python3-pyjwt: fix CVE-2026-102269
In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)From: Hetvi Thakar <[email protected]>
This patch applies the upstream fix as referenced in [2], using the commit shown in [1].
[1] https://github.com/jpadilla/pyjwt/commit/e6f48401001609a8f99e71fcaf355fb895d508a8
[2] https://github.com/jpadilla/pyjwt/security/advisories/GHSA-hxm8-2xgr-2p9m
--- .../python/files/CVE-2026-102269.patch | 133 ++++++++++++++++++ .../python/python3-pyjwt_2.12.1.bb | 1 + 2 files changed, 134 insertions(+) create mode 100644 meta-python/recipes-devtools/python/files/CVE-2026-102269.patch
meta-python/recipes-devtools/python/files/CVE-2026-102269.patch new file +133 -0
@@ -0,0 +1,133 @@ +From e6f48401001609a8f99e71fcaf355fb895d508a8 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jos=C3=A9=20Padilla?= <[email protected]> +Date: Wed, 9 Sep 2026 09:46:01 -0400 +Subject: [PATCH] Reject non-canonical compact JWS segments + +CVE: CVE-2026-102269 +Upstream-Status: Backport [https://github.com/jpadilla/pyjwt/commit/e6f48401001609a8f99e71fcaf355fb895d508a8] + +(cherry picked from commit e6f48401001609a8f99e71fcaf355fb895d508a8) +Signed-off-by: Hetvi Thakar <[email protected]> +--- + jwt/api_jws.py | 35 +++++++++++++++++++++++------------ + tests/test_api_jws.py | 11 +++++++++++ + tests/test_compressed_jwt.py | 8 ++++---- + 3 files changed, 38 insertions(+), 16 deletions(-) + +diff --git a/jwt/api_jws.py b/jwt/api_jws.py +index 5a91bce..2ee2f22 100644 +--- a/jwt/api_jws.py ++++ b/jwt/api_jws.py +@@ -28,6 +28,9 @@ if TYPE_CHECKING: + from .types import SigOptions + + _ALGORITHM_UNSET = object() ++_BASE64URL_ALPHABET = ( ++ b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" ++) + + + class PyJWS: +@@ -291,6 +294,23 @@ class PyJWS: + + return headers + ++ @staticmethod ++ def _decode_base64url_segment(segment: bytes, name: str) -> bytes: ++ if len(segment) % 4 == 1 or any( ++ character not in _BASE64URL_ALPHABET for character in segment ++ ): ++ raise DecodeError(f"Invalid {name} padding") ++ ++ try: ++ decoded = base64url_decode(segment) ++ except (TypeError, binascii.Error) as err: ++ raise DecodeError(f"Invalid {name} padding") from err ++ ++ if base64url_encode(decoded) != segment: ++ raise DecodeError(f"Invalid {name} padding") ++ ++ return decoded ++ + def _load(self, jwt: str | bytes) -> tuple[bytes, bytes, dict[str, Any], bytes]: + if isinstance(jwt, str): + jwt = jwt.encode("utf-8") +@@ -304,10 +324,7 @@ class PyJWS: + except ValueError as err: + raise DecodeError("Not enough segments") from err + +- try: +- header_data = base64url_decode(header_segment) +- except (TypeError, binascii.Error) as err: +- raise DecodeError("Invalid header padding") from err ++ header_data = self._decode_base64url_segment(header_segment, "header") + + try: + header: dict[str, Any] = json.loads(header_data) +@@ -331,15 +348,9 @@ class PyJWS: + ) + payload = b"" + else: +- try: +- payload = base64url_decode(payload_segment) +- except (TypeError, binascii.Error) as err: +- raise DecodeError("Invalid payload padding") from err ++ payload = self._decode_base64url_segment(payload_segment, "payload") + +- try: +- signature = base64url_decode(crypto_segment) +- except (TypeError, binascii.Error) as err: +- raise DecodeError("Invalid crypto padding") from err ++ signature = self._decode_base64url_segment(crypto_segment, "crypto") + + return (payload, signing_input, header, signature) + +diff --git a/tests/test_api_jws.py b/tests/test_api_jws.py +index 01de813..7e0a97b 100644 +--- a/tests/test_api_jws.py ++++ b/tests/test_api_jws.py +@@ -658,6 +658,17 @@ class TestJWS: + + assert "Invalid crypto padding" in str(exc.value) + ++ def test_decode_rejects_non_canonical_crypto_segment( ++ self, jws: PyJWS, payload: bytes ++ ) -> None: ++ secret = "a" * 32 ++ token = jws.encode(payload, secret, algorithm="HS256") ++ header, encoded_payload, signature = token.split(".") ++ mutated_token = ".".join((header, encoded_payload, f"{signature}!!!!")) ++ ++ with pytest.raises(DecodeError, match="Invalid crypto padding"): ++ jws.decode(mutated_token, secret, algorithms=["HS256"]) ++ + def test_decode_with_algo_none_should_fail( + self, jws: PyJWS, payload: bytes + ) -> None: +diff --git a/tests/test_compressed_jwt.py b/tests/test_compressed_jwt.py +index 1968cb4..51c61a8 100644 +--- a/tests/test_compressed_jwt.py ++++ b/tests/test_compressed_jwt.py +@@ -22,8 +22,8 @@ def test_decodes_complete_valid_jwt_with_compressed_payload() -> None: + # Buffer.from(pako.deflateRaw('{"hello": "world"}')).toString('base64') + example_jwt = ( + b"eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9" +- b".q1bKSM3JyVeyUlAqzy/KSVGqBQA=" +- b".08wHYeuh1rJXmcBcMrz6NxmbxAnCQp2rGTKfRNIkxiw=" ++ b".q1bKSM3JyVeyUlAqzy_KSVGqBQA" ++ b".AAn1elCJC5MQCYFwTwa2tjjtyLgqLUVU-Y1vFBsU8jo" + ) + decoded = CompressedPyJWT().decode_complete( + example_jwt, example_secret, algorithms=["HS256"] +@@ -33,7 +33,7 @@ def test_decodes_complete_valid_jwt_with_compressed_payload() -> None: + "header": {"alg": "HS256", "typ": "JWT"}, + "payload": example_payload, + "signature": ( +- b"\xd3\xcc\x07a\xeb\xa1\xd6\xb2W\x99\xc0\\2\xbc\xfa7" +- b"\x19\x9b\xc4\t\xc2B\x9d\xab\x192\x9fD\xd2$\xc6," ++ b"\x00\t\xf5zP\x89\x0b\x93\x10\t\x81pO\x06\xb6\xb68" ++ b"\xed\xc8\xb8*-ET\xf9\x8do\x14\x1b\x14\xf2:" + ), + } +-- +2.35.6
meta-python/recipes-devtools/python/python3-pyjwt_2.12.1.bb +1 -0
@@ -12,6 +12,7 @@ SRC_URI += "file://CVE-2026-48522.patch \ file://CVE-2026-48526.patch \ file://CVE-2026-103001.patch \ file://CVE-2026-102274.patch \ + file://CVE-2026-102269.patch \ " SRC_URI[sha256sum] = "c74a7a2adf861c04d002db713dd85f84beb242228e671280bf709d765b03672b"
Signature · 1 line
2.35.6
PATCH 4/9 python3-pyjwt: fix CVE-2026-102267
In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)From: Hetvi Thakar <[email protected]>
This patch applies the upstream fix as referenced in [2], using the commit shown in [1].
[1] https://github.com/jpadilla/pyjwt/commit/0a795b8e1f6ef08f634aa7086fc41cc6d5ce3e56
[2] https://github.com/jpadilla/pyjwt/security/advisories/GHSA-9v7f-9g4p-ffgj
--- .../python/files/CVE-2026-102267.patch | 223 ++++++++++++++++++ .../python/python3-pyjwt_2.12.1.bb | 1 + 2 files changed, 224 insertions(+) create mode 100644 meta-python/recipes-devtools/python/files/CVE-2026-102267.patch
meta-python/recipes-devtools/python/files/CVE-2026-102267.patch new file +223 -0
@@ -0,0 +1,223 @@ +From 0a795b8e1f6ef08f634aa7086fc41cc6d5ce3e56 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jos=C3=A9=20Padilla?= <[email protected]> +Date: Wed, 9 Sep 2026 20:20:46 -0400 +Subject: [PATCH] Reject redirects in PyJWKClient fetches + +CVE: CVE-2026-102267 +Upstream-Status: Backport [https://github.com/jpadilla/pyjwt/commit/0a795b8e1f6ef08f634aa7086fc41cc6d5ce3e56] + +(cherry picked from commit 0a795b8e1f6ef08f634aa7086fc41cc6d5ce3e56) +Signed-off-by: Hetvi Thakar <[email protected]> +--- + jwt/jwks_client.py | 21 +++++++-- + tests/test_jwks_client.py | 91 ++++++++++++++++++++++++++++++++++----- + 2 files changed, 99 insertions(+), 13 deletions(-) + +diff --git a/jwt/jwks_client.py b/jwt/jwks_client.py +index 41f333a..cfc9003 100644 +--- a/jwt/jwks_client.py ++++ b/jwt/jwks_client.py +@@ -14,6 +14,19 @@ from .exceptions import PyJWKClientConnectionError, PyJWKClientError + from .jwk_set_cache import JWKSetCache + + ++class _NoRedirectHandler(urllib.request.HTTPRedirectHandler): ++ def redirect_request( ++ self, ++ req: urllib.request.Request, ++ fp: Any, ++ code: int, ++ msg: str, ++ headers: Any, ++ newurl: str, ++ ) -> None: ++ return None ++ ++ + class PyJWKClient: + def __init__( + self, +@@ -115,9 +128,11 @@ class PyJWKClient: + """ + try: + r = urllib.request.Request(url=self.uri, headers=self.headers) +- with urllib.request.urlopen( +- r, timeout=self.timeout, context=self.ssl_context +- ) as response: ++ handlers: list[Any] = [_NoRedirectHandler()] ++ if self.ssl_context is not None: ++ handlers.append(urllib.request.HTTPSHandler(context=self.ssl_context)) ++ opener = urllib.request.build_opener(*handlers) ++ with opener.open(r, timeout=self.timeout) as response: + jwk_set = json.load(response) + except (URLError, TimeoutError) as e: + if isinstance(e, HTTPError): +diff --git a/tests/test_jwks_client.py b/tests/test_jwks_client.py +index da68664..49471ac 100644 +--- a/tests/test_jwks_client.py ++++ b/tests/test_jwks_client.py +@@ -2,8 +2,10 @@ import contextlib + import io + import json + import ssl ++import threading + import time + from collections.abc import Iterator ++from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer + from unittest import mock + from urllib.error import HTTPError, URLError + from email.message import Message +@@ -12,6 +14,7 @@ import pytest + + import jwt + from jwt import PyJWKClient ++from jwt.jwks_client import _NoRedirectHandler + from jwt.api_jwk import PyJWK + from jwt.exceptions import PyJWKClientConnectionError, PyJWKClientError + +@@ -50,7 +53,10 @@ RESPONSE_DATA_NO_MATCHING_KID = { + + @contextlib.contextmanager + def mocked_success_response(data: object) -> Iterator[mock.Mock]: +- with mock.patch("urllib.request.urlopen") as urlopen_mock: ++ with mock.patch("urllib.request.build_opener") as build_opener_mock: ++ opener = mock.Mock() ++ build_opener_mock.return_value = opener ++ urlopen_mock = opener.open + response = mock.Mock() + response.__enter__ = mock.Mock(return_value=response) + response.__exit__ = mock.Mock() +@@ -61,7 +67,10 @@ def mocked_success_response(data: object) -> Iterator[mock.Mock]: + + @contextlib.contextmanager + def mocked_failed_response() -> Iterator[mock.Mock]: +- with mock.patch("urllib.request.urlopen") as urlopen_mock: ++ with mock.patch("urllib.request.build_opener") as build_opener_mock: ++ opener = mock.Mock() ++ build_opener_mock.return_value = opener ++ urlopen_mock = opener.open + urlopen_mock.side_effect = URLError("Fail to process the request.") + yield urlopen_mock + +@@ -70,7 +79,10 @@ def mocked_failed_response() -> Iterator[mock.Mock]: + def mocked_first_call_wrong_kid_second_call_correct_kid( + response_data_one: object, response_data_two: object + ) -> Iterator[mock.Mock]: +- with mock.patch("urllib.request.urlopen") as urlopen_mock: ++ with mock.patch("urllib.request.build_opener") as build_opener_mock: ++ opener = mock.Mock() ++ build_opener_mock.return_value = opener ++ urlopen_mock = opener.open + response = mock.Mock() + response.__enter__ = mock.Mock(return_value=response) + response.__exit__ = mock.Mock() +@@ -84,14 +96,20 @@ def mocked_first_call_wrong_kid_second_call_correct_kid( + + @contextlib.contextmanager + def mocked_timeout() -> Iterator[mock.Mock]: +- with mock.patch("urllib.request.urlopen") as urlopen_mock: ++ with mock.patch("urllib.request.build_opener") as build_opener_mock: ++ opener = mock.Mock() ++ build_opener_mock.return_value = opener ++ urlopen_mock = opener.open + urlopen_mock.side_effect = TimeoutError("timed out") + yield urlopen_mock + + + @contextlib.contextmanager + def mocked_http_error_response() -> Iterator[tuple[mock.Mock, HTTPError]]: +- with mock.patch("urllib.request.urlopen") as urlopen_mock: ++ with mock.patch("urllib.request.build_opener") as build_opener_mock: ++ opener = mock.Mock() ++ build_opener_mock.return_value = opener ++ urlopen_mock = opener.open + http_error = HTTPError( + url="https://example.com", + code=401, +@@ -105,6 +123,50 @@ def mocked_http_error_response() -> Iterator[tuple[mock.Mock, HTTPError]]: + + @crypto_required + class TestPyJWKClient: ++ def test_fetch_data_rejects_redirect_without_contacting_destination(self) -> None: ++ destination_requests = 0 ++ ++ class RedirectHandler(BaseHTTPRequestHandler): ++ def do_GET(self) -> None: # noqa: N802 - stdlib handler API ++ nonlocal destination_requests ++ if self.path == "/start": ++ self.send_response(302) ++ self.send_header("Location", f"{base_url}/destination") ++ self.end_headers() ++ else: ++ destination_requests += 1 ++ self.send_response(200) ++ self.end_headers() ++ ++ def log_message(self, _format: str, *args: object) -> None: ++ return ++ ++ server = ThreadingHTTPServer(("127.0.0.1", 0), RedirectHandler) ++ base_url = f"http://127.0.0.1:{server.server_port}" ++ thread = threading.Thread(target=server.serve_forever, daemon=True) ++ thread.start() ++ try: ++ client = PyJWKClient( ++ f"{base_url}/start", headers={"Authorization": "secret"} ++ ) ++ with pytest.raises(PyJWKClientConnectionError): ++ client.fetch_data() ++ assert destination_requests == 0 ++ finally: ++ server.shutdown() ++ server.server_close() ++ thread.join() ++ ++ def test_redirect_handler_does_not_follow_redirects(self) -> None: ++ handler = _NoRedirectHandler() ++ ++ assert ( ++ handler.redirect_request( ++ mock.Mock(), mock.Mock(), 302, "Found", {}, "https://other.test" ++ ) ++ is None ++ ) ++ + def test_fetch_data_forwards_headers_to_correct_url(self) -> None: + url = "https://dev-87evx9ru.auth0.com/.well-known/jwks.json" + +@@ -401,10 +463,19 @@ class TestPyJWKClient: + ssl_ctx = ssl.create_default_context() + jwks_client = PyJWKClient(url, ssl_context=ssl_ctx) + +- with mocked_success_response(RESPONSE_DATA_WITH_MATCHING_KID) as mock_request: ++ with mock.patch("urllib.request.build_opener") as build_opener_mock: ++ opener = mock.Mock() ++ build_opener_mock.return_value = opener ++ response = mock.Mock() ++ response.__enter__ = mock.Mock(return_value=response) ++ response.__exit__ = mock.Mock() ++ response.read.return_value = json.dumps(RESPONSE_DATA_WITH_MATCHING_KID) ++ opener.open.return_value = response + jwk_set = jwks_client.get_jwk_set() +- request_call = mock_request.call_args +- assert request_call[1].get("context") is ssl_ctx ++ handlers = build_opener_mock.call_args.args ++ assert any( ++ getattr(handler, "_context", None) is ssl_ctx for handler in handlers ++ ) + + assert jwk_set is not None + +@@ -414,8 +485,8 @@ class TestPyJWKClient: + url, ssl_context=ssl.SSLContext(protocol=ssl.PROTOCOL_TLS_CLIENT) + ) + +- with mock.patch("urllib.request.urlopen") as urlopen_mock: +- urlopen_mock.side_effect = URLError( ++ with mock.patch("urllib.request.build_opener") as build_opener_mock: ++ build_opener_mock.return_value.open.side_effect = URLError( + ssl.SSLCertVerificationError("certificate verify failed") + ) + with pytest.raises(PyJWKClientError): +-- +2.35.6
meta-python/recipes-devtools/python/python3-pyjwt_2.12.1.bb +1 -0
@@ -13,6 +13,7 @@ SRC_URI += "file://CVE-2026-48522.patch \ file://CVE-2026-103001.patch \ file://CVE-2026-102274.patch \ file://CVE-2026-102269.patch \ + file://CVE-2026-102267.patch \ " SRC_URI[sha256sum] = "c74a7a2adf861c04d002db713dd85f84beb242228e671280bf709d765b03672b"
Signature · 1 line
2.35.6
PATCH 5/9 python3-pyjwt: fix CVE-2026-102268 and CVE-2026-102270
In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)From: Hetvi Thakar <[email protected]>
This patch applies the shared upstream fix as referenced in [2] and [3], using the commit shown in [1].
[1] https://github.com/jpadilla/pyjwt/commit/8b4e233a22206b34ec1186e912e75c0b2396ac07
[2] https://github.com/jpadilla/pyjwt/security/advisories/GHSA-ffc3-869f-jxw9
[3] https://github.com/jpadilla/pyjwt/security/advisories/GHSA-jwrc-g2q2-pq5p
--- .../CVE-2026-102268_CVE-2026-102270.patch | 113 ++++++++++++++++++ .../python/python3-pyjwt_2.12.1.bb | 1 + 2 files changed, 114 insertions(+) create mode 100644 meta-python/recipes-devtools/python/files/CVE-2026-102268_CVE-2026-102270.patch
meta-python/recipes-devtools/python/files/CVE-2026-102268_CVE-2026-102270.patch new file +113 -0
@@ -0,0 +1,113 @@ +From 8b4e233a22206b34ec1186e912e75c0b2396ac07 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jos=C3=A9=20Padilla?= <[email protected]> +Date: Wed, 9 Sep 2026 21:49:21 -0400 +Subject: [PATCH] fix: reject loader-accepted PEM variants + +CVE: CVE-2026-102268 CVE-2026-102270 +Upstream-Status: Backport [https://github.com/jpadilla/pyjwt/commit/8b4e233a22206b34ec1186e912e75c0b2396ac07] + +(cherry picked from commit 8b4e233a22206b34ec1186e912e75c0b2396ac07) +Signed-off-by: Hetvi Thakar <[email protected]> +--- + jwt/utils.py | 20 ++++++++++-------- + tests/test_algorithms.py | 44 +++++++++++++++++++++++++++++++++++++++- + 2 files changed, 55 insertions(+), 9 deletions(-) + +diff --git a/jwt/utils.py b/jwt/utils.py +index 56e89bb..914cb50 100644 +--- a/jwt/utils.py ++++ b/jwt/utils.py +@@ -113,18 +113,22 @@ _PEMS = { + b"X509 CRL", + } + +-_PEM_RE = re.compile( +- b"----[- ]BEGIN (" +- + b"|".join(_PEMS) +- + b""")[- ]----\r? +-.+?\r? +-----[- ]END \\1[- ]----\r?\n?""", +- re.DOTALL, ++# Accept PEM formatting variants that the cryptography loader accepts, while ++# retaining the explicit asymmetric-key marker check. ++_PEM_MARKER_RE = re.compile( ++ b"(?=(----[- ](BEGIN|END) (" + b"|".join(_PEMS) + b")[- ]----))" + ) + + + def is_pem_format(key: bytes) -> bool: +- return bool(_PEM_RE.search(key)) ++ begin_markers: dict[bytes, int] = {} ++ for marker in _PEM_MARKER_RE.finditer(key): ++ marker_type, label = marker.group(2), marker.group(3) ++ if marker_type == b"BEGIN": ++ begin_markers[label] = marker.start(1) + len(marker.group(1)) ++ elif label in begin_markers and begin_markers[label] < marker.start(1): ++ return True ++ return False + + + # Based on https://github.com/pyca/cryptography/blob/bcb70852d577b3f490f015378c75cba74986297b/src/cryptography/hazmat/primitives/serialization/ssh.py#L40-L46 +diff --git a/tests/test_algorithms.py b/tests/test_algorithms.py +index 82659cf..4e149a7 100644 +--- a/tests/test_algorithms.py ++++ b/tests/test_algorithms.py +@@ -1,6 +1,6 @@ + import base64 + import json +-from typing import Union, cast ++from typing import Callable, Union, cast + + import pytest + +@@ -89,6 +89,48 @@ class TestAlgorithms: + with open(key_path(key)) as keyfile: + algo.prepare_key(keyfile.read()) + ++ @pytest.mark.parametrize( ++ "mutation", ++ [ ++ lambda key: key.replace(b"-----END", b"\t-----END"), ++ lambda key: key.replace(b"\n", b"\r"), ++ lambda key: key.replace(b"\n", b""), ++ ], ++ ) ++ def test_hmac_should_reject_loader_accepted_pem_mutations( ++ self, mutation: Callable[[bytes], bytes] ++ ) -> None: ++ algo = HMACAlgorithm(HMACAlgorithm.SHA256) ++ with open(key_path("testkey2_rsa.pub.pem"), "rb") as keyfile: ++ mutated_key = mutation(keyfile.read()) ++ ++ with pytest.raises(InvalidKeyError): ++ algo.prepare_key(mutated_key) ++ ++ def test_hmac_should_accept_incomplete_pem_marker(self) -> None: ++ algo = HMACAlgorithm(HMACAlgorithm.SHA256) ++ key = b"-----BEGIN PUBLIC KEY-----" * 10000 ++ ++ assert algo.prepare_key(key) == key ++ ++ def test_hmac_should_reject_a_later_pem_block(self) -> None: ++ algo = HMACAlgorithm(HMACAlgorithm.SHA256) ++ with open(key_path("testkey2_rsa.pub.pem"), "rb") as keyfile: ++ key = b"-----BEGIN PUBLIC KEY-----" + keyfile.read() ++ ++ with pytest.raises(InvalidKeyError): ++ algo.prepare_key(key) ++ ++ def test_hmac_should_reject_a_pem_block_after_an_overlapping_end_marker( ++ self, ++ ) -> None: ++ algo = HMACAlgorithm(HMACAlgorithm.SHA256) ++ with open(key_path("testkey2_rsa.pub.pem"), "rb") as keyfile: ++ key = b"-----END CERTIFICATE" + keyfile.read() ++ ++ with pytest.raises(InvalidKeyError): ++ algo.prepare_key(key) ++ + def test_hmac_jwk_should_parse_and_verify(self) -> None: + algo = HMACAlgorithm(HMACAlgorithm.SHA256) + +-- +2.35.6
meta-python/recipes-devtools/python/python3-pyjwt_2.12.1.bb +1 -0
@@ -14,6 +14,7 @@ SRC_URI += "file://CVE-2026-48522.patch \ file://CVE-2026-102274.patch \ file://CVE-2026-102269.patch \ file://CVE-2026-102267.patch \ + file://CVE-2026-102268_CVE-2026-102270.patch \ " SRC_URI[sha256sum] = "c74a7a2adf861c04d002db713dd85f84beb242228e671280bf709d765b03672b"
Signature · 1 line
2.35.6
PATCH 6/9 python3-pyjwt: fix CVE-2026-102271
In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)From: Hetvi Thakar <[email protected]>
This patch applies the upstream fix as referenced in [2], using the commit shown in [1].
[1] https://github.com/jpadilla/pyjwt/commit/2798504fa2663364573cf2d1043d8d7fef389499
[2] https://github.com/jpadilla/pyjwt/security/advisories/GHSA-p4g4-x82p-q773
--- .../python/files/CVE-2026-102271.patch | 136 ++++++++++++++++++ .../python/python3-pyjwt_2.12.1.bb | 1 + 2 files changed, 137 insertions(+) create mode 100644 meta-python/recipes-devtools/python/files/CVE-2026-102271.patch
meta-python/recipes-devtools/python/files/CVE-2026-102271.patch new file +136 -0
@@ -0,0 +1,136 @@ +From 2798504fa2663364573cf2d1043d8d7fef389499 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jos=C3=A9=20Padilla?= <[email protected]> +Date: Thu, 10 Sep 2026 08:33:25 -0400 +Subject: [PATCH] fix: reject DER public keys as HMAC secrets + +CVE: CVE-2026-102271 +Upstream-Status: Backport [https://github.com/jpadilla/pyjwt/commit/2798504fa2663364573cf2d1043d8d7fef389499] + +(cherry picked from commit 2798504fa2663364573cf2d1043d8d7fef389499) +Signed-off-by: Hetvi Thakar <[email protected]> +--- + jwt/algorithms.py | 27 ++++++++++++++++++++++++++- + tests/test_algorithms.py | 39 +++++++++++++++++++++++++++++++++++++++ + 2 files changed, 65 insertions(+), 1 deletion(-) + +diff --git a/jwt/algorithms.py b/jwt/algorithms.py +index cf6da45..432fdcf 100644 +--- a/jwt/algorithms.py ++++ b/jwt/algorithms.py +@@ -33,6 +33,7 @@ from .utils import ( + ) + + try: ++ from cryptography import x509 + from cryptography.exceptions import InvalidSignature, UnsupportedAlgorithm + from cryptography.hazmat.backends import default_backend + from cryptography.hazmat.primitives import hashes +@@ -72,6 +73,7 @@ try: + NoEncryption, + PrivateFormat, + PublicFormat, ++ load_der_public_key, + load_pem_private_key, + load_pem_public_key, + load_ssh_public_key, +@@ -322,10 +324,33 @@ class HMACAlgorithm(Algorithm): + def __init__(self, hash_alg: HashlibHash) -> None: + self.hash_alg = hash_alg + ++ @staticmethod ++ def _is_der_key(key_bytes: bytes) -> bool: ++ if not has_crypto: ++ return False ++ ++ try: ++ load_der_public_key(key_bytes) ++ except (TypeError, ValueError, UnsupportedAlgorithm): ++ pass ++ else: ++ return True ++ ++ try: ++ x509.load_der_x509_certificate(key_bytes) ++ except (TypeError, ValueError, UnsupportedAlgorithm): ++ return False ++ else: ++ return True ++ + def prepare_key(self, key: str | bytes) -> bytes: + key_bytes = force_bytes(key) + +- if is_pem_format(key_bytes) or is_ssh_key(key_bytes): ++ if ( ++ is_pem_format(key_bytes) ++ or is_ssh_key(key_bytes) ++ or self._is_der_key(key_bytes) ++ ): + raise InvalidKeyError( + "The specified key is an asymmetric key or x509 certificate and" + " should not be used as an HMAC secret." +diff --git a/tests/test_algorithms.py b/tests/test_algorithms.py +index 4e149a7..acaa1fe 100644 +--- a/tests/test_algorithms.py ++++ b/tests/test_algorithms.py +@@ -12,6 +12,7 @@ from .keys import load_ec_pub_key_p_521, load_hmac_key, load_rsa_pub_key + from .utils import crypto_required, key_path + + if has_crypto: ++ from cryptography import x509 + from cryptography.hazmat.primitives.asymmetric.ec import ( + EllipticCurvePrivateKey, + EllipticCurvePublicKey, +@@ -28,6 +29,10 @@ if has_crypto: + RSAPrivateKey, + RSAPublicKey, + ) ++ from cryptography.hazmat.primitives.serialization import ( ++ Encoding, ++ PublicFormat, ++ ) + + from jwt.algorithms import ECAlgorithm, OKPAlgorithm, RSAAlgorithm, RSAPSSAlgorithm + +@@ -187,6 +192,40 @@ class TestAlgorithms: + key = algo.prepare_key('{"this": "is just a json-shaped secret"}') + assert key == b'{"this": "is just a json-shaped secret"}' + ++ @crypto_required ++ @pytest.mark.parametrize( ++ "key_format_name", ++ ("SubjectPublicKeyInfo", "PKCS1"), ++ ) ++ def test_hmac_prepare_key_rejects_der_public_key( ++ self, key_format_name: str ++ ) -> None: ++ algo = HMACAlgorithm(HMACAlgorithm.SHA256) ++ public_key = cast(RSAPublicKey, load_rsa_pub_key()) ++ der_key = public_key.public_bytes( ++ Encoding.DER, getattr(PublicFormat, key_format_name) ++ ) ++ ++ with pytest.raises(InvalidKeyError, match="asymmetric key"): ++ algo.prepare_key(der_key) ++ ++ @crypto_required ++ def test_hmac_prepare_key_rejects_der_certificate(self) -> None: ++ algo = HMACAlgorithm(HMACAlgorithm.SHA256) ++ with open(key_path("testkey_rsa.cer"), "rb") as certificate_file: ++ certificate = x509.load_pem_x509_certificate(certificate_file.read()) ++ der_certificate = certificate.public_bytes(Encoding.DER) ++ ++ with pytest.raises(InvalidKeyError, match="x509 certificate"): ++ algo.prepare_key(der_certificate) ++ ++ @crypto_required ++ def test_hmac_prepare_key_accepts_non_key_binary_secret(self) -> None: ++ algo = HMACAlgorithm(HMACAlgorithm.SHA256) ++ secret = b"\x30\x82not-a-der-key" ++ ++ assert algo.prepare_key(secret) == secret ++ + @crypto_required + def test_rsa_should_parse_pem_public_key(self) -> None: + algo = RSAAlgorithm(RSAAlgorithm.SHA256) +-- +2.35.6
meta-python/recipes-devtools/python/python3-pyjwt_2.12.1.bb +1 -0
@@ -15,6 +15,7 @@ SRC_URI += "file://CVE-2026-48522.patch \ file://CVE-2026-102269.patch \ file://CVE-2026-102267.patch \ file://CVE-2026-102268_CVE-2026-102270.patch \ + file://CVE-2026-102271.patch \ " SRC_URI[sha256sum] = "c74a7a2adf861c04d002db713dd85f84beb242228e671280bf709d765b03672b"
Signature · 1 line
2.35.6
PATCH 7/9 python3-pyjwt: fix CVE-2026-101917
In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)From: Hetvi Thakar <[email protected]>
This patch applies the upstream fix as referenced in [2], using the commit shown in [1].
[1] https://github.com/jpadilla/pyjwt/commit/ba4853a75fb9676362da17f67d0f64bd18afd4e1
[2] https://github.com/jpadilla/pyjwt/security/advisories/GHSA-2gx3-rcp4-g85q
--- .../python/files/CVE-2026-101917.patch | 311 ++++++++++++++++++ .../python/python3-pyjwt_2.12.1.bb | 1 + 2 files changed, 312 insertions(+) create mode 100644 meta-python/recipes-devtools/python/files/CVE-2026-101917.patch
meta-python/recipes-devtools/python/files/CVE-2026-101917.patch new file +311 -0
@@ -0,0 +1,311 @@ +From ba4853a75fb9676362da17f67d0f64bd18afd4e1 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jos=C3=A9=20Padilla?= <[email protected]> +Date: Thu, 10 Sep 2026 14:10:52 -0400 +Subject: [PATCH] Throttle repeated PyJWKClient refreshes + +CVE: CVE-2026-101917 +Upstream-Status: Backport [https://github.com/jpadilla/pyjwt/commit/ba4853a75fb9676362da17f67d0f64bd18afd4e1] + +(cherry picked from commit ba4853a75fb9676362da17f67d0f64bd18afd4e1) +Signed-off-by: Hetvi Thakar <[email protected]> +--- + jwt/jwks_client.py | 63 ++++++++++++++--- + tests/test_jwks_client.py | 141 +++++++++++++++++++++++++++++++++++++- + 2 files changed, 192 insertions(+), 12 deletions(-) + +diff --git a/jwt/jwks_client.py b/jwt/jwks_client.py +index cfc9003..dcf1edd 100644 +--- a/jwt/jwks_client.py ++++ b/jwt/jwks_client.py +@@ -1,6 +1,9 @@ + from __future__ import annotations + + import json ++import math ++import threading ++import time + import urllib.request + from functools import lru_cache + from ssl import SSLContext +@@ -38,6 +41,7 @@ class PyJWKClient: + headers: dict[str, Any] | None = None, + timeout: float = 30, + ssl_context: SSLContext | None = None, ++ cooldown_duration: float = 30, + ): + """A client for retrieving signing keys from a JWKS endpoint. + +@@ -54,6 +58,14 @@ class PyJWKClient: + - ``lifespan``: Time in seconds before the cached JWK Set expires. + Defaults to ``300`` (5 minutes). Must be greater than 0. + ++ Unknown key IDs can trigger one forced refresh after the cooldown ++ period configured by ``cooldown_duration``. Every successful fetch ++ starts this cooldown, including the initial fetch and cache-expiry ++ fetches. A newly rotated key may therefore wait for the cooldown ++ period before it is fetched; set ``cooldown_duration`` to ``0`` to ++ disable this behavior. The cooldown is bypassed when ++ ``cache_jwk_set`` is ``False``. ++ + **Tier 2 — Signing key cache** (disabled by default): + Caches individual signing keys (looked up by ``kid``) using an LRU + cache with **no time-based expiration**. Keys are evicted only when +@@ -80,6 +92,9 @@ class PyJWKClient: + :type timeout: float + :param ssl_context: Optional SSL context for the request. + :type ssl_context: ssl.SSLContext or None ++ :param cooldown_duration: Minimum time in seconds between forced ++ refreshes after an unknown key ID. Defaults to ``30``. ++ :type cooldown_duration: float + """ + if headers is None: + headers = {} +@@ -98,6 +113,18 @@ class PyJWKClient: + self.headers = headers + self.timeout = timeout + self.ssl_context = ssl_context ++ if cooldown_duration < 0: ++ raise PyJWKClientError( ++ "Cooldown duration must be greater than or equal to 0, " ++ f'the input is "{cooldown_duration}"' ++ ) ++ if not math.isfinite(cooldown_duration): ++ raise PyJWKClientError( ++ f'Cooldown duration must be finite, the input is "{cooldown_duration}"' ++ ) ++ self.cooldown_duration = cooldown_duration ++ self._last_successful_fetch: float | None = None ++ self._client_lock = threading.RLock() + + if cache_jwk_set: + # Init jwt set cache with default or given lifespan. +@@ -147,6 +174,7 @@ class PyJWKClient: + # wipe that breaks legitimate auth. + if self.jwk_set_cache is not None: + self.jwk_set_cache.put(jwk_set) ++ self._last_successful_fetch = time.monotonic() + return jwk_set + + def get_jwk_set(self, refresh: bool = False) -> PyJWKSet: +@@ -186,6 +214,10 @@ class PyJWKClient: + :raises PyJWKClientError: If no signing keys are found. + """ + jwk_set = self.get_jwk_set(refresh) ++ return self._get_signing_keys_from_jwk_set(jwk_set) ++ ++ @staticmethod ++ def _get_signing_keys_from_jwk_set(jwk_set: PyJWKSet) -> list[PyJWK]: + signing_keys = [ + jwk_set_key + for jwk_set_key in jwk_set.keys +@@ -200,8 +232,9 @@ class PyJWKClient: + def get_signing_key(self, kid: str) -> PyJWK: + """Return the signing key matching the given ``kid``. + +- If no match is found in the current JWK Set, the set is +- refreshed from the endpoint and the lookup is retried once. ++ If no match is found in the current JWK Set, the set is refreshed ++ from the endpoint and the lookup is retried once when the refresh ++ cooldown permits it. + + :param kid: The key ID to look up. + :type kid: str +@@ -210,20 +243,28 @@ class PyJWKClient: + :raises PyJWKClientError: If no matching key is found after + refreshing. + """ +- signing_keys = self.get_signing_keys() +- signing_key = self.match_kid(signing_keys, kid) +- +- if not signing_key: +- # If no matching signing key from the jwk set, refresh the jwk set and try again. +- signing_keys = self.get_signing_keys(refresh=True) ++ with self._client_lock: ++ signing_keys = self.get_signing_keys() + signing_key = self.match_kid(signing_keys, kid) + + if not signing_key: +- raise PyJWKClientError( +- f'Unable to find a signing key that matches: "{kid}"' ++ cooling_down = ( ++ self.jwk_set_cache is not None ++ and self._last_successful_fetch is not None ++ and time.monotonic() - self._last_successful_fetch ++ < self.cooldown_duration + ) ++ if not cooling_down: ++ signing_keys = self.get_signing_keys(refresh=True) ++ self._last_successful_fetch = time.monotonic() ++ signing_key = self.match_kid(signing_keys, kid) + +- return signing_key ++ if not signing_key: ++ raise PyJWKClientError( ++ f'Unable to find a signing key that matches: "{kid}"' ++ ) ++ ++ return signing_key + + def get_signing_key_from_jwt(self, token: str | bytes) -> PyJWK: + """Return the signing key for a JWT by reading its ``kid`` header. +diff --git a/tests/test_jwks_client.py b/tests/test_jwks_client.py +index 49471ac..c66dfd7 100644 +--- a/tests/test_jwks_client.py ++++ b/tests/test_jwks_client.py +@@ -386,7 +386,7 @@ class TestPyJWKClient: + + def test_get_jwt_set_refresh_cache(self) -> None: + url = "https://dev-87evx9ru.auth0.com/.well-known/jwks.json" +- jwks_client = PyJWKClient(url) ++ jwks_client = PyJWKClient(url, cooldown_duration=0) + + kid = "NEE1QURBOTM4MzI5RkFDNTYxOTU1MDg2ODgwQ0UzMTk1QjYyRkRFQw" + +@@ -411,6 +411,145 @@ class TestPyJWKClient: + ): + jwks_client.get_signing_key(kid) + ++ def test_unknown_kid_refresh_is_cooled_down(self) -> None: ++ url = "https://dev-87evx9ru.auth0.com/.well-known/jwks.json" ++ kid = "unknown-kid" ++ jwks_client = PyJWKClient(url, cooldown_duration=30) ++ ++ with mock.patch("urllib.request.build_opener") as build_opener_mock: ++ opener = mock.Mock() ++ build_opener_mock.return_value = opener ++ response = mock.Mock() ++ response.__enter__ = mock.Mock(return_value=response) ++ response.__exit__ = mock.Mock() ++ response.read.return_value = json.dumps(RESPONSE_DATA_NO_MATCHING_KID) ++ opener.open.return_value = response ++ ++ for _ in range(2): ++ with pytest.raises(PyJWKClientError, match="matches"): ++ jwks_client.get_signing_key(kid) ++ ++ assert opener.open.call_count == 1 ++ ++ def test_unknown_kid_refresh_runs_again_after_cooldown(self) -> None: ++ url = "https://dev-87evx9ru.auth0.com/.well-known/jwks.json" ++ kid = "unknown-kid" ++ jwks_client = PyJWKClient(url, cooldown_duration=0.01) ++ ++ with mock.patch("urllib.request.build_opener") as build_opener_mock: ++ opener = mock.Mock() ++ build_opener_mock.return_value = opener ++ response = mock.Mock() ++ response.__enter__ = mock.Mock(return_value=response) ++ response.__exit__ = mock.Mock() ++ response.read.return_value = json.dumps(RESPONSE_DATA_NO_MATCHING_KID) ++ opener.open.return_value = response ++ ++ clock = [0.0] ++ with mock.patch( ++ "jwt.jwks_client.time.monotonic", side_effect=lambda: clock[0] ++ ): ++ with pytest.raises(PyJWKClientError, match="matches"): ++ jwks_client.get_signing_key(kid) ++ clock[0] = 0.02 ++ with pytest.raises(PyJWKClientError, match="matches"): ++ jwks_client.get_signing_key(kid) ++ ++ assert opener.open.call_count == 2 ++ ++ def test_unknown_kid_refresh_serializes_concurrent_misses(self) -> None: ++ url = "https://dev-87evx9ru.auth0.com/.well-known/jwks.json" ++ kid = "unknown-kid" ++ jwks_client = PyJWKClient(url, cooldown_duration=30) ++ refresh_started = threading.Event() ++ second_done = threading.Event() ++ release_refresh = threading.Event() ++ ++ with mock.patch("urllib.request.build_opener") as build_opener_mock: ++ opener = mock.Mock() ++ build_opener_mock.return_value = opener ++ response = mock.Mock() ++ response.__enter__ = mock.Mock(return_value=response) ++ response.__exit__ = mock.Mock() ++ response.read.return_value = json.dumps(RESPONSE_DATA_NO_MATCHING_KID) ++ ++ opener.open.return_value = response ++ jwks_client.get_jwk_set() ++ jwks_client._last_successful_fetch = 0 ++ ++ def open_response(*args: object, **kwargs: object) -> mock.Mock: ++ if opener.open.call_count == 1: ++ refresh_started.set() ++ release_refresh.wait(timeout=5) ++ return response ++ ++ opener.open.reset_mock() ++ opener.open.side_effect = open_response ++ errors: list[Exception] = [] ++ ++ def lookup() -> None: ++ try: ++ jwks_client.get_signing_key(kid) ++ except PyJWKClientError as error: ++ errors.append(error) ++ ++ first = threading.Thread(target=lookup) ++ ++ def second_lookup() -> None: ++ lookup() ++ second_done.set() ++ ++ second = threading.Thread(target=second_lookup) ++ with mock.patch("jwt.jwks_client.time.monotonic", return_value=31): ++ first.start() ++ assert refresh_started.wait(timeout=5) ++ second.start() ++ assert not second_done.wait(timeout=0.1) ++ release_refresh.set() ++ first.join(timeout=5) ++ second.join(timeout=5) ++ ++ assert len(errors) == 2 ++ assert not first.is_alive() ++ assert not second.is_alive() ++ assert opener.open.call_count == 1 ++ ++ def test_unknown_kid_refresh_ignores_cooldown_when_cache_disabled(self) -> None: ++ url = "https://dev-87evx9ru.auth0.com/.well-known/jwks.json" ++ kid = "unknown-kid" ++ jwks_client = PyJWKClient(url, cache_jwk_set=False, cooldown_duration=30) ++ ++ with mock.patch("urllib.request.build_opener") as build_opener_mock: ++ opener = mock.Mock() ++ build_opener_mock.return_value = opener ++ response = mock.Mock() ++ response.__enter__ = mock.Mock(return_value=response) ++ response.__exit__ = mock.Mock() ++ response.read.side_effect = [ ++ json.dumps(RESPONSE_DATA_NO_MATCHING_KID), ++ json.dumps(RESPONSE_DATA_NO_MATCHING_KID), ++ json.dumps(RESPONSE_DATA_NO_MATCHING_KID), ++ json.dumps(RESPONSE_DATA_NO_MATCHING_KID), ++ ] ++ opener.open.return_value = response ++ ++ for _ in range(2): ++ with pytest.raises(PyJWKClientError, match="matches"): ++ jwks_client.get_signing_key(kid) ++ ++ assert opener.open.call_count == 4 ++ ++ @pytest.mark.parametrize( ++ "cooldown_duration", [float("nan"), float("inf"), float("-inf")] ++ ) ++ def test_unknown_kid_refresh_rejects_non_finite_cooldown( ++ self, cooldown_duration: float ++ ) -> None: ++ url = "https://dev-87evx9ru.auth0.com/.well-known/jwks.json" ++ ++ with pytest.raises(PyJWKClientError, match="Cooldown duration"): ++ PyJWKClient(url, cooldown_duration=cooldown_duration) ++ + def test_get_jwt_set_invalid_lifespan(self) -> None: + url = "https://dev-87evx9ru.auth0.com/.well-known/jwks.json" + +-- +2.35.6
meta-python/recipes-devtools/python/python3-pyjwt_2.12.1.bb +1 -0
@@ -16,6 +16,7 @@ SRC_URI += "file://CVE-2026-48522.patch \ file://CVE-2026-102267.patch \ file://CVE-2026-102268_CVE-2026-102270.patch \ file://CVE-2026-102271.patch \ + file://CVE-2026-101917.patch \ " SRC_URI[sha256sum] = "c74a7a2adf861c04d002db713dd85f84beb242228e671280bf709d765b03672b"
Signature · 1 line
2.35.6
PATCH 8/9 python3-pyjwt: fix CVE-2026-102275
In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)From: Hetvi Thakar <[email protected]>
This patch applies the upstream fix as referenced in [2], using the commit shown in [1].
[1] https://github.com/jpadilla/pyjwt/commit/3cd9ceec33ced359decbad75b413ad668ae6332c
[2] https://github.com/jpadilla/pyjwt/security/advisories/GHSA-x33g-cr3x-6449
--- .../python/files/CVE-2026-102275.patch | 82 +++++++++++++++++++ .../python/python3-pyjwt_2.12.1.bb | 1 + 2 files changed, 83 insertions(+) create mode 100644 meta-python/recipes-devtools/python/files/CVE-2026-102275.patch
meta-python/recipes-devtools/python/files/CVE-2026-102275.patch new file +82 -0
@@ -0,0 +1,82 @@ +From 3cd9ceec33ced359decbad75b413ad668ae6332c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jos=C3=A9=20Padilla?= <[email protected]> +Date: Fri, 11 Sep 2026 22:29:12 -0400 +Subject: [PATCH] fix: reject inconsistent OKP private keys + +CVE: CVE-2026-102275 +Upstream-Status: Backport [https://github.com/jpadilla/pyjwt/commit/3cd9ceec33ced359decbad75b413ad668ae6332c] + +(cherry picked from commit 3cd9ceec33ced359decbad75b413ad668ae6332c) +Signed-off-by: Hetvi Thakar <[email protected]> +--- + jwt/algorithms.py | 14 ++++++++++++-- + tests/test_algorithms.py | 29 +++++++++++++++++++++++++++++ + 2 files changed, 41 insertions(+), 2 deletions(-) + +diff --git a/jwt/algorithms.py b/jwt/algorithms.py +index 432fdcf..03976c9 100644 +--- a/jwt/algorithms.py ++++ b/jwt/algorithms.py +@@ -1036,8 +1036,18 @@ if has_crypto: + return Ed25519PublicKey.from_public_bytes(x) + return Ed448PublicKey.from_public_bytes(x) + d = base64url_decode(obj.get("d")) ++ private_key: Ed25519PrivateKey | Ed448PrivateKey + if curve == "Ed25519": +- return Ed25519PrivateKey.from_private_bytes(d) +- return Ed448PrivateKey.from_private_bytes(d) ++ private_key = Ed25519PrivateKey.from_private_bytes(d) ++ else: ++ private_key = Ed448PrivateKey.from_private_bytes(d) ++ if ( ++ private_key.public_key().public_bytes( ++ encoding=Encoding.Raw, format=PublicFormat.Raw ++ ) ++ != x ++ ): ++ raise InvalidKeyError("Public key does not match private key") ++ return private_key + except ValueError as err: + raise InvalidKeyError("Invalid key parameter") from err +diff --git a/tests/test_algorithms.py b/tests/test_algorithms.py +index acaa1fe..089b881 100644 +--- a/tests/test_algorithms.py ++++ b/tests/test_algorithms.py +@@ -933,6 +933,35 @@ class TestAlgorithmsRFC7520: + + @crypto_required + class TestOKPAlgorithms: ++ @pytest.mark.parametrize("curve", ("Ed25519", "Ed448")) ++ @pytest.mark.parametrize("as_dict", (False, True)) ++ def test_okp_jwk_should_reject_inconsistent_private_key( ++ self, curve: str, as_dict: bool ++ ) -> None: ++ with open(key_path(f"jwk_okp_key_{curve}.json")) as keyfile: ++ jwk = json.load(keyfile) ++ ++ d = base64url_decode(jwk["d"]) ++ jwk["d"] = ( ++ base64.urlsafe_b64encode(bytes([d[0] ^ 1]) + d[1:]).rstrip(b"=").decode() ++ ) ++ ++ with pytest.raises(InvalidKeyError): ++ OKPAlgorithm.from_jwk(jwk if as_dict else json.dumps(jwk)) ++ ++ @pytest.mark.parametrize("curve", ("Ed25519", "Ed448")) ++ @pytest.mark.parametrize("length", (0, 1, 56, 58)) ++ def test_okp_jwk_should_reject_private_key_with_invalid_public_length( ++ self, curve: str, length: int ++ ) -> None: ++ with open(key_path(f"jwk_okp_key_{curve}.json")) as keyfile: ++ jwk = json.load(keyfile) ++ ++ jwk["x"] = base64.urlsafe_b64encode(b"\x00" * length).rstrip(b"=").decode() ++ ++ with pytest.raises(InvalidKeyError): ++ OKPAlgorithm.from_jwk(jwk) ++ + hello_world_sig = b"Qxa47mk/azzUgmY2StAOguAd4P7YBLpyCfU3JdbaiWnXM4o4WibXwmIHvNYgN3frtE2fcyd8OYEaOiD/KiwkCg==" + hello_world_sig_pem = b"9ueQE7PT8uudHIQb2zZZ7tB7k1X3jeTnIfOVvGCINZejrqQbru1EXPeuMlGcQEZrGkLVcfMmr99W/+byxfppAg==" + hello_world = b"Hello World!" +-- +2.35.6
meta-python/recipes-devtools/python/python3-pyjwt_2.12.1.bb +1 -0
@@ -17,6 +17,7 @@ SRC_URI += "file://CVE-2026-48522.patch \ file://CVE-2026-102268_CVE-2026-102270.patch \ file://CVE-2026-102271.patch \ file://CVE-2026-101917.patch \ + file://CVE-2026-102275.patch \ " SRC_URI[sha256sum] = "c74a7a2adf861c04d002db713dd85f84beb242228e671280bf709d765b03672b"
Signature · 1 line
2.35.6
PATCH 9/9 python3-pyjwt: fix CVE-2026-101918
In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)From: Hetvi Thakar <[email protected]>
This patch applies the upstream fix as referenced in [2], using the commit shown in [1].
[1] https://github.com/jpadilla/pyjwt/commit/5fde08a6cf906aa7698de2d6391d88b73006b17b
[2] https://github.com/jpadilla/pyjwt/security/advisories/GHSA-42vr-xj54-vc7v
--- .../python/files/CVE-2026-101918.patch | 122 ++++++++++++++++++ .../python/python3-pyjwt_2.12.1.bb | 1 + 2 files changed, 123 insertions(+) create mode 100644 meta-python/recipes-devtools/python/files/CVE-2026-101918.patch
meta-python/recipes-devtools/python/files/CVE-2026-101918.patch new file +122 -0
@@ -0,0 +1,122 @@ +From 5fde08a6cf906aa7698de2d6391d88b73006b17b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jos=C3=A9=20Padilla?= <[email protected]> +Date: Tue, 22 Sep 2026 11:44:19 -0400 +Subject: [PATCH] fix: normalize recursive JWT payload errors + +CVE: CVE-2026-101918 +Upstream-Status: Backport [https://github.com/jpadilla/pyjwt/commit/5fde08a6cf906aa7698de2d6391d88b73006b17b] + +Backport Changes: +- Adapted the PyJWKClient regression-test imports to the older Wrynose + test module, which lacks later unrelated PyJWKSet imports. + +(cherry picked from commit 5fde08a6cf906aa7698de2d6391d88b73006b17b) +Signed-off-by: Hetvi Thakar <[email protected]> +--- + jwt/api_jwt.py | 2 +- + tests/test_api_jwt.py | 18 +++++++++++++++++- + tests/test_jwks_client.py | 26 +++++++++++++++++++++++++- + 3 files changed, 43 insertions(+), 3 deletions(-) + +diff --git a/jwt/api_jwt.py b/jwt/api_jwt.py +index f298ea9..d6917c0 100644 +--- a/jwt/api_jwt.py ++++ b/jwt/api_jwt.py +@@ -293,7 +293,7 @@ class PyJWT: + """ + try: + payload: dict[str, Any] = json.loads(decoded["payload"]) +- except ValueError as e: ++ except (ValueError, RecursionError) as e: + raise DecodeError(f"Invalid payload string: {e}") from e + if not isinstance(payload, dict): + raise DecodeError("Invalid payload string: must be a json object") +diff --git a/tests/test_api_jwt.py b/tests/test_api_jwt.py +index dd28816..96f9179 100644 +--- a/tests/test_api_jwt.py ++++ b/tests/test_api_jwt.py +@@ -7,6 +7,7 @@ from decimal import Decimal + + import pytest + ++import jwt as pyjwt + from jwt.types import Options + from jwt.api_jwk import PyJWK + from jwt.api_jwt import PyJWT +@@ -21,7 +22,7 @@ from jwt.exceptions import ( + InvalidSubjectError, + MissingRequiredClaimError, + ) +-from jwt.utils import base64url_decode ++from jwt.utils import base64url_decode, base64url_encode + from jwt.warnings import RemovedInPyjwt3Warning + + from .utils import crypto_required, key_path, utc_timestamp +@@ -177,6 +178,21 @@ class TestJWT: + + assert "Invalid payload string" in str(exc.value) + ++ def test_decode_deeply_nested_payload_throws_decode_error(self) -> None: ++ nested_payload = b"[" * 100_000 + b"]" * 100_000 ++ token = ".".join( ++ ( ++ "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9", ++ base64url_encode(nested_payload).decode(), ++ "", ++ ) ++ ) ++ ++ with pytest.raises(DecodeError, match="Invalid payload") as exc: ++ pyjwt.decode(token, options={"verify_signature": False}) ++ ++ assert isinstance(exc.value.__cause__, RecursionError) ++ + def test_decode_with_non_mapping_payload_throws_exception(self, jwt: PyJWT) -> None: + secret = "secret" + example_jwt = ( +diff --git a/tests/test_jwks_client.py b/tests/test_jwks_client.py +index c66dfd7..cf6f6e1 100644 +--- a/tests/test_jwks_client.py ++++ b/tests/test_jwks_client.py +@@ -16,7 +16,12 @@ import jwt + from jwt import PyJWKClient + from jwt.jwks_client import _NoRedirectHandler + from jwt.api_jwk import PyJWK +-from jwt.exceptions import PyJWKClientConnectionError, PyJWKClientError ++from jwt.exceptions import ( ++ DecodeError, ++ PyJWKClientConnectionError, ++ PyJWKClientError, ++) ++from jwt.utils import base64url_encode + + from .utils import crypto_required + +@@ -298,6 +303,25 @@ class TestPyJWKClient: + "gty": "client-credentials", + } + ++ def test_get_signing_key_from_jwt_rejects_deeply_nested_payload(self) -> None: ++ nested_payload = b"[" * 100_000 + b"]" * 100_000 ++ header = b'{"alg":"RS256","kid":"test-key"}' ++ token = ".".join( ++ ( ++ base64url_encode(header).decode(), ++ base64url_encode(nested_payload).decode(), ++ "", ++ ) ++ ) ++ ++ with mocked_success_response(RESPONSE_DATA_WITH_MATCHING_KID) as open_mock: ++ jwks_client = PyJWKClient("https://example.test/.well-known/jwks.json") ++ with pytest.raises(DecodeError, match="Invalid payload") as exc: ++ jwks_client.get_signing_key_from_jwt(token) ++ ++ assert isinstance(exc.value.__cause__, RecursionError) ++ assert open_mock.call_count == 0 ++ + def test_get_jwk_set_caches_result(self) -> None: + url = "https://dev-87evx9ru.auth0.com/.well-known/jwks.json" + +-- +2.35.6
meta-python/recipes-devtools/python/python3-pyjwt_2.12.1.bb +1 -0
@@ -18,6 +18,7 @@ SRC_URI += "file://CVE-2026-48522.patch \ file://CVE-2026-102271.patch \ file://CVE-2026-101917.patch \ file://CVE-2026-102275.patch \ + file://CVE-2026-101918.patch \ " SRC_URI[sha256sum] = "c74a7a2adf861c04d002db713dd85f84beb242228e671280bf709d765b03672b"
Signature · 1 line
2.35.6