Skip to contentSkip to conversation

python3-pyjwt: fix CVE-2026-102269

PATCH New Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco) 1 participant 8 messages Nov 5

lore
Share & tools
lore
#0 lore raw

PATCH 1/8 python3-pyjwt: fix CVE-2026-102269

From: Hetvi Thakar <[email protected]>

This patch applies the upstream fix as referenced in [2], using the commit shown in [1].

It also applies the upstream follow-up [3] to accept canonical Base64URL padding while continuing to reject malformed JWS segments.

[1] https://github.com/jpadilla/pyjwt/commit/e6f48401001609a8f99e71fcaf355fb895d508a8
[2] https://github.com/jpadilla/pyjwt/security/advisories/GHSA-hxm8-2xgr-2p9m
[3] https://github.com/jpadilla/pyjwt/commit/7bf32526738fe837387bdedd4849a4a525c33a79

---
 .../python3-pyjwt/CVE-2026-102269_p1.patch    | 138 ++++++++++++++
 .../python3-pyjwt/CVE-2026-102269_p2.patch    | 169 ++++++++++++++++++
 .../python/python3-pyjwt_2.8.0.bb             |   2 +
 3 files changed, 309 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-pyjwt/CVE-2026-102269_p1.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-pyjwt/CVE-2026-102269_p2.patch
meta-python/recipes-devtools/python/python3-pyjwt/CVE-2026-102269_p1.patch new file +138 -0
new file mode 100644
index 0000000000..68fe3f4edc
@@ -0,0 +1,138 @@
+From cfcc99413c41c6b59a6de6fc222291367d8922b2 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Jos=C3=A9=20Padilla?= <[email protected]>
+Date: Wed, 14 Oct 2026 02:38:35 -0700
+Subject: [PATCH] Reject non-canonical compact JWS segments
+
+CVE: CVE-2026-102269
+Upstream-Status: Backport [https://github.com/jpadilla/pyjwt/commit/e6f48401001609a8f99e71fcaf355fb895d508a8]
+
+Backport Changes:
+- Added a separating blank line after _BASE64URL_ALPHABET to retain two
+  blank lines before PyJWS; PyJWT 2.8.0 lacks the adjacent upstream
+  _ALGORITHM_UNSET constant.
+
+Signed-off-by: Hetvi Thakar <[email protected]>
+---
+ jwt/api_jws.py               | 36 ++++++++++++++++++++++++------------
+ tests/test_api_jws.py        | 11 +++++++++++
+ tests/test_compressed_jwt.py |  8 ++++----
+ 3 files changed, 39 insertions(+), 16 deletions(-)
+
+diff --git a/jwt/api_jws.py b/jwt/api_jws.py
+index 0d5ab2b..10618b7 100644
+--- a/jwt/api_jws.py
++++ b/jwt/api_jws.py
+@@ -23,6 +23,10 @@ from .warnings import RemovedInPyjwt3Warning
+ if TYPE_CHECKING:
+     from .algorithms import AllowedPrivateKeys, AllowedPublicKeys
+ 
++_BASE64URL_ALPHABET = (
++    b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
++)
++
+ 
+ class PyJWS:
+     header_typ = "JWT"
+@@ -248,6 +252,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")
+@@ -261,10 +282,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 = json.loads(header_data)
+@@ -283,15 +301,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 29f84a7..3b05845 100644
+--- a/tests/test_api_jws.py
++++ b/tests/test_api_jws.py
+@@ -478,6 +478,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, payload):
+         jws_message = jws.encode(payload, key=None, algorithm=None)
+ 
+diff --git a/tests/test_compressed_jwt.py b/tests/test_compressed_jwt.py
+index 21fac3f..7603633 100644
+--- a/tests/test_compressed_jwt.py
++++ b/tests/test_compressed_jwt.py
+@@ -20,8 +20,8 @@ def test_decodes_complete_valid_jwt_with_compressed_payload():
+     # 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"]
+@@ -31,7 +31,7 @@ def test_decodes_complete_valid_jwt_with_compressed_payload():
+         "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/CVE-2026-102269_p2.patch new file +169 -0

169 lines not on this page · raw message

meta-python/recipes-devtools/python/python3-pyjwt_2.8.0.bb +2 -0
index 3804d8ab72..5a1dac4df6 100644
@@ -11,6 +11,8 @@ SRC_URI += " \
     file://CVE-2026-48524.patch \
     file://CVE-2026-48525.patch \
     file://CVE-2026-48526.patch \
+    file://CVE-2026-102269_p1.patch \
+    file://CVE-2026-102269_p2.patch \
 "
 SRC_URI[sha256sum] = "57e28d156e3d5c10088e0c68abb90bfac3df82b40a71bd0daa20c65ccd5c23de"
 
Signature · 1 line
2.35.6
#1 lore raw

PATCH 2/8 python3-pyjwt: fix CVE-2026-102267

From: Hetvi Thakar <[email protected]>

This patch applies the upstream fix as referenced in [2], using the commit shown in [1].

Reject redirects when PyJWKClient fetches a JWKS to prevent requests from following redirects to unintended destinations.

[1] https://github.com/jpadilla/pyjwt/commit/0a795b8e1f6ef08f634aa7086fc41cc6d5ce3e56
[2] https://github.com/jpadilla/pyjwt/security/advisories/GHSA-9v7f-9g4p-ffgj

---
 .../python3-pyjwt/CVE-2026-102267.patch       | 223 ++++++++++++++++++
 .../python/python3-pyjwt_2.8.0.bb             |   1 +
 2 files changed, 224 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-pyjwt/CVE-2026-102267.patch
meta-python/recipes-devtools/python/python3-pyjwt/CVE-2026-102267.patch new file +223 -0
new file mode 100644
index 0000000000..d83cd8ca59
@@ -0,0 +1,223 @@
+From 67ef104edd43a60ba87db0740364778eae796fe2 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Jos=C3=A9=20Padilla?= <[email protected]>
+Date: Wed, 14 Oct 2026 02:41:53 -0700
+Subject: [PATCH] Reject redirects in PyJWKClient fetches
+
+CVE: CVE-2026-102267
+Upstream-Status: Backport [https://github.com/jpadilla/pyjwt/commit/0a795b8e1f6ef08f634aa7086fc41cc6d5ce3e56]
+
+Backport Changes:
+- Used the existing typing.List import for the handlers annotation.
+- Omitted the mocked_http_error_response opener-mock conversion because
+  that helper is absent from the PyJWT 2.8.0 test suite.
+- Adapted the two SSL-context tests from live requests to opener mocks;
+  the 2.8.0 success test needs a local ssl_ctx and an explicit mocked
+  get_jwk_set call, and its failure test needs the certificate-error mock.
+
+Signed-off-by: Hetvi Thakar <[email protected]>
+---
+ jwt/jwks_client.py        | 21 +++++++--
+ tests/test_jwks_client.py | 96 ++++++++++++++++++++++++++++++++++-----
+ 2 files changed, 103 insertions(+), 14 deletions(-)
+
+diff --git a/jwt/jwks_client.py b/jwt/jwks_client.py
+index 0e7d226..ab601a4 100644
+--- a/jwt/jwks_client.py
++++ b/jwt/jwks_client.py
+@@ -12,6 +12,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,
+@@ -61,9 +74,11 @@ class PyJWKClient:
+     def fetch_data(self) -> Any:
+         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:
+             raise PyJWKClientConnectionError(
+diff --git a/tests/test_jwks_client.py b/tests/test_jwks_client.py
+index 4a836f2..b3f2555 100644
+--- a/tests/test_jwks_client.py
++++ b/tests/test_jwks_client.py
+@@ -1,7 +1,9 @@
+ import contextlib
+ import json
+ import ssl
++import threading
+ import time
++from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
+ from unittest import mock
+ from urllib.error import URLError
+ 
+@@ -9,6 +11,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
+ 
+@@ -47,7 +50,10 @@ RESPONSE_DATA_NO_MATCHING_KID = {
+ 
+ @contextlib.contextmanager
+ def mocked_success_response(data):
+-    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()
+@@ -58,7 +64,10 @@ def mocked_success_response(data):
+ 
+ @contextlib.contextmanager
+ def mocked_failed_response():
+-    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
+ 
+@@ -67,7 +76,10 @@ def mocked_failed_response():
+ def mocked_first_call_wrong_kid_second_call_correct_kid(
+     response_data_one, response_data_two
+ ):
+-    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()
+@@ -81,13 +93,60 @@ def mocked_first_call_wrong_kid_second_call_correct_kid(
+ 
+ @contextlib.contextmanager
+ def mocked_timeout():
+-    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
+ 
+ 
+ @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):
+         url = "https://dev-87evx9ru.auth0.com/.well-known/jwks.json"
+ 
+@@ -372,9 +431,22 @@ class TestPyJWKClient:
+ 
+     def test_get_jwt_set_sslcontext_default(self):
+         url = "https://dev-87evx9ru.auth0.com/.well-known/jwks.json"
+-        jwks_client = PyJWKClient(url, ssl_context=ssl.create_default_context())
+-
+-        jwk_set = jwks_client.get_jwk_set()
++        ssl_ctx = ssl.create_default_context()
++        jwks_client = PyJWKClient(url, ssl_context=ssl_ctx)
++
++        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()
++            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
+ 
+@@ -384,7 +456,9 @@ class TestPyJWKClient:
+             url, ssl_context=ssl.SSLContext(protocol=ssl.PROTOCOL_TLS_CLIENT)
+         )
+ 
+-        with pytest.raises(PyJWKClientError):
+-            jwks_client.get_jwk_set()
+-
+-        assert "Failed to get an expected error"
++        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):
++                jwks_client.get_jwk_set()
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-pyjwt_2.8.0.bb +1 -0
index 5a1dac4df6..fa03d1e616 100644
@@ -13,6 +13,7 @@ SRC_URI += " \
     file://CVE-2026-48526.patch \
     file://CVE-2026-102269_p1.patch \
     file://CVE-2026-102269_p2.patch \
+    file://CVE-2026-102267.patch \
 "
 SRC_URI[sha256sum] = "57e28d156e3d5c10088e0c68abb90bfac3df82b40a71bd0daa20c65ccd5c23de"
 
Signature · 1 line
2.35.6
#2 lore raw

PATCH 3/8 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].

Use a bounded PEM marker scan to reject loader-accepted public-key variants and avoid excessive regular-expression backtracking.

[1] https://github.com/jpadilla/pyjwt/commit/8b4e233a22206b34ec1186e912e75c0b2396ac07
[2] https://github.com/jpadilla/pyjwt/security/advisories/GHSA-ffc3-869f-jxw9
[3] https://github.com/advisories/GHSA-jwrc-g2q2-pq5p

---
 .../CVE-2026-102268_CVE-2026-102270.patch     | 116 ++++++++++++++++++
 .../python/python3-pyjwt_2.8.0.bb             |   1 +
 2 files changed, 117 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-pyjwt/CVE-2026-102268_CVE-2026-102270.patch
meta-python/recipes-devtools/python/python3-pyjwt/CVE-2026-102268_CVE-2026-102270.patch new file +116 -0
new file mode 100644
index 0000000000..ed7fd0949b
@@ -0,0 +1,116 @@
+From 5b3dab98c3a6c6cd64dca4895451c1dd11f04b08 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Jos=C3=A9=20Padilla?= <[email protected]>
+Date: Wed, 14 Oct 2026 02:43:17 -0700
+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]
+
+Backport Changes:
+- Retain the existing Any import when adding Callable to the PyJWT 2.8.0
+  regression tests; the upstream test suite imports Union instead.
+
+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 81c5ee4..4e3ad3c 100644
+--- a/jwt/utils.py
++++ b/jwt/utils.py
+@@ -116,18 +116,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 e5220c6..0fbffc9 100644
+--- a/tests/test_algorithms.py
++++ b/tests/test_algorithms.py
+@@ -1,6 +1,6 @@
+ import base64
+ import json
+-from typing import Any, cast
++from typing import Any, Callable, cast
+ 
+ import pytest
+ 
+@@ -82,6 +82,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):
+         algo = HMACAlgorithm(HMACAlgorithm.SHA256)
+ 
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-pyjwt_2.8.0.bb +1 -0
index fa03d1e616..f62b8aa7bb 100644
@@ -14,6 +14,7 @@ SRC_URI += " \
     file://CVE-2026-102269_p1.patch \
     file://CVE-2026-102269_p2.patch \
     file://CVE-2026-102267.patch \
+    file://CVE-2026-102268_CVE-2026-102270.patch \
 "
 SRC_URI[sha256sum] = "57e28d156e3d5c10088e0c68abb90bfac3df82b40a71bd0daa20c65ccd5c23de"
 
Signature · 1 line
2.35.6
#3 lore raw

PATCH 4/8 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].

Reject DER-encoded public keys and certificates when preparing an HMAC key to prevent asymmetric-key material from being accepted as an HMAC secret.

[1] https://github.com/jpadilla/pyjwt/commit/2798504fa2663364573cf2d1043d8d7fef389499
[2] https://github.com/jpadilla/pyjwt/security/advisories/GHSA-p4g4-x82p-q773

---
 .../python3-pyjwt/CVE-2026-102271.patch       | 141 ++++++++++++++++++
 .../python/python3-pyjwt_2.8.0.bb             |   1 +
 2 files changed, 142 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-pyjwt/CVE-2026-102271.patch
meta-python/recipes-devtools/python/python3-pyjwt/CVE-2026-102271.patch new file +141 -0
new file mode 100644
index 0000000000..82938afb27
@@ -0,0 +1,141 @@
+From 20f172fe70aad3314ee988d343c5f1fb05b4ff70 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Jos=C3=A9=20Padilla?= <[email protected]>
+Date: Wed, 14 Oct 2026 05:10:38 -0700
+Subject: [PATCH] fix: reject DER public keys as HMAC secrets
+
+CVE: CVE-2026-102271
+Upstream-Status: Backport [https://github.com/jpadilla/pyjwt/commit/2798504fa2663364573cf2d1043d8d7fef389499]
+
+Backport Changes:
+- Import UnsupportedAlgorithm, which the PyJWT 2.8.0 algorithms module
+  does not already import, for the DER loader exception handlers.
+
+Signed-off-by: Hetvi Thakar <[email protected]>
+---
+ jwt/algorithms.py        | 29 +++++++++++++++++++++++++++--
+ tests/test_algorithms.py | 39 +++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 66 insertions(+), 2 deletions(-)
+
+diff --git a/jwt/algorithms.py b/jwt/algorithms.py
+index b6303ed..fcfca89 100644
+--- a/jwt/algorithms.py
++++ b/jwt/algorithms.py
+@@ -28,7 +28,8 @@ else:
+ 
+ 
+ try:
+-    from cryptography.exceptions import InvalidSignature
++    from cryptography import x509
++    from cryptography.exceptions import InvalidSignature, UnsupportedAlgorithm
+     from cryptography.hazmat.backends import default_backend
+     from cryptography.hazmat.primitives import hashes
+     from cryptography.hazmat.primitives.asymmetric import padding
+@@ -67,6 +68,7 @@ try:
+         NoEncryption,
+         PrivateFormat,
+         PublicFormat,
++        load_der_public_key,
+         load_pem_private_key,
+         load_pem_public_key,
+         load_ssh_public_key,
+@@ -261,10 +263,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 0fbffc9..c843903 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
+ 
+@@ -172,6 +177,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):
+         algo = RSAAlgorithm(RSAAlgorithm.SHA256)
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-pyjwt_2.8.0.bb +1 -0
index f62b8aa7bb..612b1c9cde 100644
@@ -15,6 +15,7 @@ SRC_URI += " \
     file://CVE-2026-102269_p2.patch \
     file://CVE-2026-102267.patch \
     file://CVE-2026-102268_CVE-2026-102270.patch \
+    file://CVE-2026-102271.patch \
 "
 SRC_URI[sha256sum] = "57e28d156e3d5c10088e0c68abb90bfac3df82b40a71bd0daa20c65ccd5c23de"
 
Signature · 1 line
2.35.6
#4 lore raw

PATCH 5/8 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].

Throttle repeated JWKS refreshes for unknown key IDs with a client cooldown to prevent repeated endpoint fetches.

[1] https://github.com/jpadilla/pyjwt/commit/ba4853a75fb9676362da17f67d0f64bd18afd4e1
[2] https://github.com/jpadilla/pyjwt/security/advisories/GHSA-2gx3-rcp4-g85q

---
 .../python3-pyjwt/CVE-2026-101917.patch       | 311 ++++++++++++++++++
 .../python/python3-pyjwt_2.8.0.bb             |   1 +
 2 files changed, 312 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-pyjwt/CVE-2026-101917.patch
meta-python/recipes-devtools/python/python3-pyjwt/CVE-2026-101917.patch new file +311 -0
new file mode 100644
index 0000000000..eb5d0f3014
@@ -0,0 +1,311 @@
+From 92c0ba0994dd1cc57321d3c70b17974de0e8ebb5 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Jos=C3=A9=20Padilla?= <[email protected]>
+Date: Wed, 14 Oct 2026 05:12:02 -0700
+Subject: [PATCH] Throttle repeated PyJWKClient refreshes
+
+CVE: CVE-2026-101917
+Upstream-Status: Backport [https://github.com/jpadilla/pyjwt/commit/ba4853a75fb9676362da17f67d0f64bd18afd4e1]
+
+Backport Changes:
+- Add minimal constructor and get_signing_key docstrings carrying the
+  upstream cooldown wording and parameter documentation because PyJWT 2.8.0
+  lacks the newer method docstrings.
+- Use Optional[float] for _last_successful_fetch and List[PyJWK] for the
+  extracted signing-key helper to match the 2.8.0 typing imports.
+- Also set cooldown_duration=0 in the existing
+  test_get_jwt_set_no_matching_kid_after_second_attempt test, which assumes
+  an immediate second fetch; upstream already has that setting.
+
+Signed-off-by: Hetvi Thakar <[email protected]>
+---
+ jwt/jwks_client.py        |  67 +++++++++++++++---
+ tests/test_jwks_client.py | 143 +++++++++++++++++++++++++++++++++++++-
+ 2 files changed, 199 insertions(+), 11 deletions(-)
+
+diff --git a/jwt/jwks_client.py b/jwt/jwks_client.py
+index ab601a4..ab5f40c 100644
+--- a/jwt/jwks_client.py
++++ b/jwt/jwks_client.py
+@@ -1,4 +1,7 @@
+ import json
++import math
++import threading
++import time
+ import urllib.request
+ from functools import lru_cache
+ from ssl import SSLContext
+@@ -36,7 +39,22 @@ class PyJWKClient:
+         headers: Optional[Dict[str, Any]] = None,
+         timeout: int = 30,
+         ssl_context: Optional[SSLContext] = None,
++        cooldown_duration: float = 30,
+     ):
++        """A client for retrieving signing keys from a JWKS endpoint.
++
++        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``.
++
++        :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 = {}
+         # urllib's default OpenerDirector also handles file://, ftp://, and
+@@ -54,6 +72,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: Optional[float] = None
++        self._client_lock = threading.RLock()
+ 
+         if cache_jwk_set:
+             # Init jwt set cache with default or given lifespan.
+@@ -89,6 +119,7 @@ class PyJWKClient:
+         # finally block on error would discard a previously cached JWKS.
+         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:
+@@ -106,6 +137,10 @@ class PyJWKClient:
+ 
+     def get_signing_keys(self, refresh: bool = False) -> List[PyJWK]:
+         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
+@@ -118,20 +153,34 @@ class PyJWKClient:
+         return signing_keys
+ 
+     def get_signing_key(self, kid: str) -> PyJWK:
+-        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)
++        """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 when the refresh
++        cooldown permits it.
++        """
++        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) -> PyJWK:
+         unverified = decode_token(token, options={"verify_signature": False})
+diff --git a/tests/test_jwks_client.py b/tests/test_jwks_client.py
+index b3f2555..ed730d7 100644
+--- a/tests/test_jwks_client.py
++++ b/tests/test_jwks_client.py
+@@ -362,7 +362,7 @@ class TestPyJWKClient:
+ 
+     def test_get_jwt_set_refresh_cache(self):
+         url = "https://dev-87evx9ru.auth0.com/.well-known/jwks.json"
+-        jwks_client = PyJWKClient(url)
++        jwks_client = PyJWKClient(url, cooldown_duration=0)
+ 
+         kid = "NEE1QURBOTM4MzI5RkFDNTYxOTU1MDg2ODgwQ0UzMTk1QjYyRkRFQw"
+ 
+@@ -377,7 +377,7 @@ class TestPyJWKClient:
+ 
+     def test_get_jwt_set_no_matching_kid_after_second_attempt(self):
+         url = "https://dev-87evx9ru.auth0.com/.well-known/jwks.json"
+-        jwks_client = PyJWKClient(url)
++        jwks_client = PyJWKClient(url, cooldown_duration=0)
+ 
+         kid = "NEE1QURBOTM4MzI5RkFDNTYxOTU1MDg2ODgwQ0UzMTk1QjYyRkRFQw"
+ 
+@@ -387,6 +387,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):
+         url = "https://dev-87evx9ru.auth0.com/.well-known/jwks.json"
+ 
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-pyjwt_2.8.0.bb +1 -0
index 612b1c9cde..f260bb1817 100644
@@ -16,6 +16,7 @@ SRC_URI += " \
     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] = "57e28d156e3d5c10088e0c68abb90bfac3df82b40a71bd0daa20c65ccd5c23de"
 
Signature · 1 line
2.35.6
#5 lore raw

PATCH 6/8 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].

Require the public component of an imported OKP private JWK to match the public key derived from its private component.

[1] https://github.com/jpadilla/pyjwt/commit/3cd9ceec33ced359decbad75b413ad668ae6332c
[2] https://github.com/jpadilla/pyjwt/security/advisories/GHSA-x33g-cr3x-6449

---
 .../python3-pyjwt/CVE-2026-102275.patch       | 81 +++++++++++++++++++
 .../python/python3-pyjwt_2.8.0.bb             |  1 +
 2 files changed, 82 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-pyjwt/CVE-2026-102275.patch
meta-python/recipes-devtools/python/python3-pyjwt/CVE-2026-102275.patch new file +81 -0
new file mode 100644
index 0000000000..9d281bee1b
@@ -0,0 +1,81 @@
+From 64f02b83a79f25b687eaf990f7f871ece4faea8f Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Jos=C3=A9=20Padilla?= <[email protected]>
+Date: Wed, 14 Oct 2026 05:12:30 -0700
+Subject: [PATCH] fix: reject inconsistent OKP private keys
+
+CVE: CVE-2026-102275
+Upstream-Status: Backport [https://github.com/jpadilla/pyjwt/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 fcfca89..38c0a2e 100644
+--- a/jwt/algorithms.py
++++ b/jwt/algorithms.py
+@@ -893,8 +893,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 c843903..afc569b 100644
+--- a/tests/test_algorithms.py
++++ b/tests/test_algorithms.py
+@@ -906,6 +906,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 = b"Hello World!"
+ 
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-pyjwt_2.8.0.bb +1 -0
index f260bb1817..c235499d24 100644
@@ -17,6 +17,7 @@ SRC_URI += " \
     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] = "57e28d156e3d5c10088e0c68abb90bfac3df82b40a71bd0daa20c65ccd5c23de"
 
Signature · 1 line
2.35.6
#6 lore raw

PATCH 7/8 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].

Normalize recursive JSON payload failures to DecodeError. Include the upstream follow-up [3] as a separate CVE-2026-101918_p2.patch. It makes the regression tests deterministic and verifies that payload recursion errors cause no JWKS request.

[1] https://github.com/jpadilla/pyjwt/commit/5fde08a6cf906aa7698de2d6391d88b73006b17b
[2] https://github.com/jpadilla/pyjwt/security/advisories/GHSA-42vr-xj54-vc7v
[3] https://github.com/jpadilla/pyjwt/commit/9bc06658f875b9b40091539140bbbdc4639161c3

---
 .../python3-pyjwt/CVE-2026-101918_p1.patch    | 121 ++++++++++++++++++
 .../python3-pyjwt/CVE-2026-101918_p2.patch    | 109 ++++++++++++++++
 .../python/python3-pyjwt_2.8.0.bb             |   2 +
 3 files changed, 232 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-pyjwt/CVE-2026-101918_p1.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-pyjwt/CVE-2026-101918_p2.patch
meta-python/recipes-devtools/python/python3-pyjwt/CVE-2026-101918_p1.patch new file +121 -0
new file mode 100644
index 0000000000..be2a17d507
@@ -0,0 +1,121 @@
+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:
+- Add explicit exception chaining to the PyJWT 2.8.0 payload parser,
+  which lacks the upstream raise-from clause used by the regression tests.
+- Add DecodeError to the existing single-line jwt.exceptions import in
+  tests/test_jwks_client.py; newer upstream-only exceptions are absent.
+
+Signed-off-by: Hetvi Thakar <[email protected]>
+---
+ jwt/api_jwt.py            |  4 ++--
+ tests/test_api_jwt.py     | 18 +++++++++++++++++-
+ tests/test_jwks_client.py | 22 +++++++++++++++++++++-
+ 3 files changed, 40 insertions(+), 4 deletions(-)
+
+diff --git a/jwt/api_jwt.py b/jwt/api_jwt.py
+index 48d739a..ae0dc35 100644
+--- a/jwt/api_jwt.py
++++ b/jwt/api_jwt.py
+@@ -176,8 +176,8 @@ class PyJWT:
+         """
+         try:
+             payload = json.loads(decoded["payload"])
+-        except ValueError as e:
+-            raise DecodeError(f"Invalid payload string: {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")
+         return payload
+diff --git a/tests/test_api_jwt.py b/tests/test_api_jwt.py
+index 2598b12..0a5f91c 100644
+--- a/tests/test_api_jwt.py
++++ b/tests/test_api_jwt.py
+@@ -6,6 +6,7 @@ from decimal import Decimal
+ 
+ import pytest
+ 
++import jwt as pyjwt
+ from jwt.api_jwt import PyJWT
+ from jwt.exceptions import (
+     DecodeError,
+@@ -16,7 +17,7 @@ from jwt.exceptions import (
+     InvalidIssuerError,
+     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
+@@ -34,6 +35,21 @@ def payload():
+ 
+ 
+ class TestJWT:
++    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_decodes_valid_jwt(self, jwt):
+         example_payload = {"hello": "world"}
+         example_secret = "secret"
+diff --git a/tests/test_jwks_client.py b/tests/test_jwks_client.py
+index ed730d7..43530df 100644
+--- a/tests/test_jwks_client.py
++++ b/tests/test_jwks_client.py
+@@ -13,7 +13,8 @@ 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
+ 
+@@ -103,6 +104,25 @@ def mocked_timeout():
+ 
+ @crypto_required
+ class TestPyJWKClient:
++    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_fetch_data_rejects_redirect_without_contacting_destination(self) -> None:
+         destination_requests = 0
+ 
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-pyjwt/CVE-2026-101918_p2.patch new file +109 -0

109 lines not on this page · raw message

meta-python/recipes-devtools/python/python3-pyjwt_2.8.0.bb +2 -0
index c235499d24..b3a1c49726 100644
@@ -18,6 +18,8 @@ SRC_URI += " \
     file://CVE-2026-102271.patch \
     file://CVE-2026-101917.patch \
     file://CVE-2026-102275.patch \
+    file://CVE-2026-101918_p1.patch \
+    file://CVE-2026-101918_p2.patch \
 "
 SRC_URI[sha256sum] = "57e28d156e3d5c10088e0c68abb90bfac3df82b40a71bd0daa20c65ccd5c23de"
 
Signature · 1 line
2.35.6
#7 lore raw

PATCH 8/8 python3-pyjwt: fix CVE-2026-32597 test indentation

In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Hetvi Thakar <[email protected]>

Correct the indentation of the unknown critical-header regression test in the CVE-2026-32597 backport [1]. The malformed method definition prevents pytest from collecting tests/test_api_jws.py and blocks the JWS regression suite.

[1] https://github.com/jpadilla/pyjwt/commit/051ea341b5573fe3edcd53042f347929b92c2b92

---
 .../recipes-devtools/python/python3-pyjwt/CVE-2026-32597.patch  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta-python/recipes-devtools/python/python3-pyjwt/CVE-2026-32597.patch +1 -1
index c38628d0b3..20e25aa911 100644
@@ -99,7 +99,7 @@ index 3385716..434874b 100644
          assert len(record) == 1
          assert "foo" in str(record[0].message)
 +
-+        def test_decode_rejects_unknown_crit_extension(
++    def test_decode_rejects_unknown_crit_extension(
 +        self, jws: PyJWS, payload: bytes
 +    ) -> None:
 +        secret = "secret"
Signature · 1 line
2.35.6