From patchwork Fri Nov 20 03:46:15 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)" X-Patchwork-Id: 105014 Received: from aer-iport-4.cisco.com (aer-iport-4.cisco.com [173.38.203.54]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.4790.1795146382277774793 for ; Thu, 19 Nov 2026 19:46:23 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: message contains an insecure body length tag" header.i=@cisco.com header.s=iport01 header.b=ASPSrQ02; spf=pass (domain: cisco.com, ip: 173.38.203.54, mailfrom: hthakar@cisco.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=10786; q=dns/txt; s=iport01; t=1795146382; x=1796355982; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=zp+zHUZRPbwzWl1Yn1SsLXY90pZwHoJ++baKVk0nito=; b=ASPSrQ02fpzFAER79yiFhlt8YURQaiw8fUf/gc4NxI8JkUWvzjpHvGj+ Cu/X1+fE8Er+yFUG5AeTrCMZbHoRkijJucMowG9HDfIw5vkFgLkOhqqLN RdLkPMnKrRtOube4BBwzmEwpWmVymeHC00fs8GGNYvhBviwj2wfVDTG5H efTvnwxArd89k5qw4jUSF8yAwBjMs+VhPBSMWd+hX3tc+0gEOOnRX7O5C +fsukXHKaKHc53XRHkumjBZVVSCoMSZwZhTPo0MF3HKclC9VAHMPx5yza CKDEqpiRsKBoPgyUbbLx66q6DS/GOpzC32ACO/BTJD1PYVJ3gPWIuFKkp w==; X-CSE-ConnectionGUID: ys/kPPmyQMKfzfrmLY/Auw== X-CSE-MsgGUID: dbw8CSzxTPiKFqrGCIqMOQ== X-IPAS-Result: A0ADAABEwP9q/9RK/pBaGgEBAQEBAQEBAQEDAQEBARIBAQEBAgIBAQEBgXwFAQEBAQsBglZ1YENJA4xvhziBNWyBFopThWqMWYF+DwEBAQ9EDQQBAYQ/jmkCJjQJDgECBAMCAwEBAQEBAQEBAQEBAQoBAQUBAQECAQcFgQ4Thk8NkBIBOAEYAVkDAQJPCyMhgwIBgjoDNwMRuTyCLIEBgykBPwJDUNhMDYJaAQsUAYE4AYVBgwCFJF0YAYR9JxsbgXKBFYJ0doEFgRpCAQECAYFFhl4EgiKBDIFUjRcCgU+IJkiBHgNZLAFVEw0KCwcFgWgDNRIqFW4yHYEjOxeBBxsGBYEcgR6BEoEDXYErKF4hgQiBdgKCUYIAAgFJQQ4HRVMJJUMSRyQiCBIJARMaLAqBGjU8CSY/FQxnCxoFYQgCDQx0ORAwHiQvBRomPhsKgQwnHx4bDgIfEAYNGA1IESw3FRkEPm4Hk2yCbC0hWhMBByIBASAJLSmBLR4Vkl4nkj2gIHEKKIN5jCSPPoV8GjOEBKZuC5h9glmIBUmCY4QKkXcDTYRqgWg8gUcLB3AVgyIJShkPjisECguDYIF/gxTJSCYyAgkDLwEBBwIHDgMLgWiRfgEB IronPort-Data: A9a23:wB4Dx6/I2Mchc+HBteSSDrUD1H+TJUtcMsCJ2f8bNWPcYEJGY0x3z zdLDzzXPP3bMWqgcoslb9+08htQsZfWmtRlTFFt+CtEQiMRo6IpJzg2wmQcns+2BpeeJK6yx 5xGMrEsFOhtEDmB4E/rYuK8xZVF/fngbqLmD+LZMTxGSwZhSSMw4TpugOdRbrRA2bBVOCvT/ 4mtyyHjEAX9gWAtazhMs/3rRC5H5ZwehhtJ5jTSWtgT1LPuvyF9JI4SI6i3M0z5TuF8dsamR /zOxa2O5WjQ+REgELuNyt4XpWVTH9Y+lSDX4pZnc/DKbipq/0Te4Y5nXBYoUnq7vh3S9zxHJ HqhgrTrIeshFvWkdO3wyHC0GQkmVUFN0OevzXRSLaV/wmWeG0YAzcmCA2knJsobwt5yEFhr1 vIKJioISiHErv+plefTpulE3qzPLeHiMZlavjRryivUSK9/B5vCWK7No9Rf2V/chOgXQaqYP ZdFL2UzKk6ZOXWjOX9PYH46tOe0hnD8eidwo1OOrq1x6G/WpOB0+Oa3aYKNK4HTLSlTtkqSu TLtxHbpPikbF/KG0xWu02uJodaayEsXX6pXTtVU7MVCh0WewGEWAhAaWVa35PW0lEO6c9ZeM FAPvC02oK4/8UamQtXwU1u/unHsg/IHc9NdCag+rQqK0KeRul/fDWkfRTkHY9sj3CMreQEXO payt4uBLVRSXHe9EBpxKp/8QeuOBBUo IronPort-HdrOrdr: A9a23:O+lD+KrdRjM63NBwvEEJTPMaV5obeYIsimQD101hICG9Ffbo9f xG88506faZslsssRIb6LO90de7IE80nKQdieJ6AV7IZmbbUQWTQL2KlbGD/xTQXwvj6+Vaya BsN4J6CNH2EBxGqPyS2njcLz7lq+P3l5xBQozlvhNQcT0= X-Talos-CUID: 9a23:+CYZM2GNuXp4iva1qmJ27wkXIvggY0T473nCLVW9LVcuYaCKHAo= X-Talos-MUID: 9a23:hvVzxA7crHFy6XPAi2vH3Mxlxoxk6bv+I3sfgak+uuqqLDZfEBaEqROOF9o= X-IronPort-Anti-Spam-Filtered: true X-IronPort-AV: E=Sophos;i="6.27,222,1787011200"; d="scan'208";a="62100951" Received: from aer-l-core-11.cisco.com ([144.254.74.212]) by aer-iport-4.cisco.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Nov 2026 03:46:19 +0000 Received: from sjc-ads-5245.cisco.com (sjc-ads-5245.cisco.com [10.28.23.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aer-l-core-11.cisco.com (Postfix) with ESMTPS id 8DB1B180001FD for ; Fri, 20 Nov 2026 03:46:19 +0000 (GMT) Received: by sjc-ads-5245.cisco.com (Postfix, from userid 1887505) id 3A144CC1611; Thu, 19 Nov 2026 19:46:18 -0800 (PST) From: "Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)" To: openembedded-devel@lists.openembedded.org Subject: [meta-python][wrynose][PATCH 1/4] python3-oauthlib: fix CVE-2026-49265 Date: Thu, 19 Nov 2026 19:46:15 -0800 Message-Id: <20261120034618.604880-1-hthakar@cisco.com> X-Mailer: git-send-email 2.35.6 MIME-Version: 1.0 X-Outbound-Client-TLS: ANONYMOUS;sjc-ads-5245.cisco.com [10.28.23.9];TLSv1.3;TLS_AES_256_GCM_SHA384;256 X-Outbound-SMTP-Client: 10.28.23.9, sjc-ads-5245.cisco.com X-Outbound-Node: aer-l-core-11.cisco.com List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Fri, 20 Nov 2026 03:46:25 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-devel/message/132756 From: Hetvi Thakar The plain and S256 PKCE checks use ordinary string equality, exposing verifier/challenge comparisons to prefix-dependent timing differences. Backport upstream fix [1], referenced by NVD [2] and Debian [3], to use hmac.compare_digest for constant-time comparison in OAuthLib 3.3.1. Include upstream follow-up [4] to compare UTF-8 bytes and avoid an uncaught TypeError for non-ASCII input. Retain its regressions and add token-endpoint coverage confirming that a verifier mismatch returns HTTP 400 invalid_grant without issuing a token. Omit the CHANGELOG.rst update because its newer release-note context is absent from the 3.3.1 source. [1] https://github.com/oauthlib/oauthlib/commit/74664d3fe037a354e180e305135c6bab1747a6b0 [2] https://nvd.nist.gov/vuln/detail/CVE-2026-49265 [3] https://security-tracker.debian.org/tracker/CVE-2026-49265 [4] https://github.com/oauthlib/oauthlib/commit/9cf6654bf44bbd47a9187b9204a2c2503a7c97d3 Signed-off-by: Hetvi Thakar --- .../python3-oauthlib/CVE-2026-49265_p1.patch | 51 +++++++ .../python3-oauthlib/CVE-2026-49265_p2.patch | 129 ++++++++++++++++++ .../python/python3-oauthlib_3.3.1.bb | 5 + 3 files changed, 185 insertions(+) create mode 100644 meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49265_p1.patch create mode 100644 meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49265_p2.patch diff --git a/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49265_p1.patch b/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49265_p1.patch new file mode 100644 index 0000000000..b8e74be40c --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49265_p1.patch @@ -0,0 +1,51 @@ +From 74664d3fe037a354e180e305135c6bab1747a6b0 Mon Sep 17 00:00:00 2001 +From: Jonathan Huot +Date: Sat, 11 Jul 2026 13:15:29 +0200 +Subject: [PATCH] Improve PKCE code comparison + +CVE: CVE-2026-49265 +Upstream-Status: Backport [https://github.com/oauthlib/oauthlib/commit/74664d3fe037a354e180e305135c6bab1747a6b0] + +Backport Changes: +- Omit CHANGELOG.rst because its newer release-note context is + absent from the 3.3.1 source. + +Signed-off-by: Hetvi Thakar +--- + oauthlib/oauth2/rfc6749/grant_types/authorization_code.py | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py b/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py +index 09dc619988941ea1dd83e15b4b4f11689b45bb36..c73314ac31a8d5523519fac5aef8a2b2728ec757 100644 +--- a/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py ++++ b/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py +@@ -4,6 +4,7 @@ oauthlib.oauth2.rfc6749.grant_types + """ + import base64 + import hashlib ++import hmac + import json + import logging + +@@ -44,9 +45,10 @@ def code_challenge_method_s256(verifier, challenge): + + .. _`Section 4.3`: https://tools.ietf.org/html/rfc7636#section-4.3 + """ +- return base64.urlsafe_b64encode( ++ expected = base64.urlsafe_b64encode( + hashlib.sha256(verifier.encode()).digest() +- ).decode().rstrip('=') == challenge ++ ).decode().rstrip('=') ++ return hmac.compare_digest(expected, challenge) + + + def code_challenge_method_plain(verifier, challenge): +@@ -58,7 +60,7 @@ def code_challenge_method_plain(verifier, challenge): + + .. _`Section 4.3`: https://tools.ietf.org/html/rfc7636#section-4.3 + """ +- return verifier == challenge ++ return hmac.compare_digest(verifier, challenge) + + + class AuthorizationCodeGrant(GrantTypeBase): diff --git a/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49265_p2.patch b/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49265_p2.patch new file mode 100644 index 0000000000..1ecadbf9f9 --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49265_p2.patch @@ -0,0 +1,129 @@ +From 9cf6654bf44bbd47a9187b9204a2c2503a7c97d3 Mon Sep 17 00:00:00 2001 +From: Vibe Nuage Agent +Date: Tue, 6 Oct 2026 18:03:18 +0000 +Subject: [PATCH] Fix PKCE comparison raising on non-ASCII input + +Encode both operands to UTF-8 bytes before hmac.compare_digest so +any unicode string compares correctly (github issue #988). + +CVE: CVE-2026-49265 +Upstream-Status: Backport [https://github.com/oauthlib/oauthlib/commit/9cf6654bf44bbd47a9187b9204a2c2503a7c97d3] + +Backport Changes: +- Add a token-endpoint regression confirming that a non-ASCII plain + verifier mismatch returns HTTP 400 invalid_grant without issuing a token. + +Co-authored-by: JonathanHuot +Signed-off-by: Hetvi Thakar +--- + .../rfc6749/grant_types/authorization_code.py | 4 +- + .../rfc6749/grant_types/test_authorization_code.py | 63 +++++++++++++++++++++- + 2 files changed, 64 insertions(+), 3 deletions(-) + +diff --git a/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py b/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py +index c73314ac31a8d5523519fac5aef8a2b2728ec757..bde7cc97ee7effbf6161c3f7559bcae76eeac8d0 100644 +--- a/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py ++++ b/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py +@@ -48,7 +48,7 @@ def code_challenge_method_s256(verifier, challenge): + expected = base64.urlsafe_b64encode( + hashlib.sha256(verifier.encode()).digest() + ).decode().rstrip('=') +- return hmac.compare_digest(expected, challenge) ++ return hmac.compare_digest(expected.encode(), challenge.encode()) + + + def code_challenge_method_plain(verifier, challenge): +@@ -60,7 +60,7 @@ def code_challenge_method_plain(verifier, challenge): + + .. _`Section 4.3`: https://tools.ietf.org/html/rfc7636#section-4.3 + """ +- return hmac.compare_digest(verifier, challenge) ++ return hmac.compare_digest(verifier.encode(), challenge.encode()) + + + class AuthorizationCodeGrant(GrantTypeBase): +diff --git a/tests/oauth2/rfc6749/grant_types/test_authorization_code.py b/tests/oauth2/rfc6749/grant_types/test_authorization_code.py +index 77e1a81b462a46ecea665fd8c5de6999d5707119..c05fdb9af33b2379a9c9cb3c1bddba4f80fe47f2 100644 +--- a/tests/oauth2/rfc6749/grant_types/test_authorization_code.py ++++ b/tests/oauth2/rfc6749/grant_types/test_authorization_code.py +@@ -2,8 +2,9 @@ + import json + from unittest import mock + +-from oauthlib.common import Request ++from oauthlib.common import Request, urlencode + from oauthlib.oauth2.rfc6749 import errors ++from oauthlib.oauth2.rfc6749.endpoints import TokenEndpoint + from oauthlib.oauth2.rfc6749.grant_types import ( + AuthorizationCodeGrant, authorization_code, + ) +@@ -306,9 +307,69 @@ class AuthorizationCodeGrantTest(TestCase): + def test_correct_code_challenge_method_plain(self): + self.assertTrue(authorization_code.code_challenge_method_plain("foo", "foo")) + ++ def test_plain_non_ascii_verifier_matches_non_ascii_challenge(self): ++ # Regression test: non-ASCII values previously raised TypeError ++ # from hmac.compare_digest, causing a server error instead of ++ # invalid_grant. (github issue #988) ++ self.assertTrue( ++ authorization_code.code_challenge_method_plain("verifier-\u00e9", "verifier-\u00e9")) ++ self.assertFalse( ++ authorization_code.code_challenge_method_plain("verifier-\u00e9", "verifier")) ++ self.assertFalse( ++ authorization_code.code_challenge_method_plain("verifier", "verifier-\u00e9")) ++ ++ def test_plain_invalid_types_raise(self): ++ # A RequestValidator.get_code_challenge implementation returning ++ # a non-string is a server implementation error and must surface ++ # as such, not as invalid_grant. ++ self.assertRaises((AttributeError, TypeError), ++ authorization_code.code_challenge_method_plain, None, "foo") ++ self.assertRaises((AttributeError, TypeError), ++ authorization_code.code_challenge_method_plain, "foo", None) ++ self.assertRaises((AttributeError, TypeError), ++ authorization_code.code_challenge_method_plain, "foo", {"a": 1}) ++ self.assertRaises((AttributeError, TypeError), ++ authorization_code.code_challenge_method_plain, 42, "foo") ++ self.assertRaises((AttributeError, TypeError), ++ authorization_code.code_challenge_method_plain, b"foo", "foo") ++ ++ def test_plain_non_ascii_verifier_returns_invalid_grant(self): ++ self.mock_validator.is_pkce_required.return_value = True ++ self.mock_validator.get_code_challenge.return_value = "stored-challenge" ++ self.mock_validator.get_code_challenge_method.return_value = "plain" ++ endpoint = TokenEndpoint( ++ default_grant_type="authorization_code", ++ default_token_type=BearerToken(self.mock_validator), ++ grant_types={"authorization_code": self.auth}, ++ ) ++ body = urlencode([ ++ ("grant_type", "authorization_code"), ++ ("client_id", "abcdef"), ++ ("code", "1234"), ++ ("redirect_uri", "https://a.b/cb"), ++ ("code_verifier", "verifier-\u00e9"), ++ ]) ++ ++ _, response, status = endpoint.create_token_response( ++ "https://a.b/token", body=body) ++ ++ self.assertEqual(status, 400) ++ self.assertEqual(json.loads(response)["error"], "invalid_grant") ++ self.mock_validator.save_bearer_token.assert_not_called() ++ + def test_wrong_code_challenge_method_s256(self): + self.assertFalse(authorization_code.code_challenge_method_s256("foo", "bar")) + ++ def test_s256_non_ascii_verifier_does_not_raise(self): ++ self.assertFalse( ++ authorization_code.code_challenge_method_s256("verifier-\u00e9", "foo")) ++ ++ def test_s256_invalid_types_raise(self): ++ self.assertRaises((AttributeError, TypeError), ++ authorization_code.code_challenge_method_s256, None, "foo") ++ self.assertRaises((AttributeError, TypeError), ++ authorization_code.code_challenge_method_s256, "foo", 42) ++ + def test_correct_code_challenge_method_s256(self): + # "abcd" as verifier gives a '+' to base64 + self.assertTrue( diff --git a/meta-python/recipes-devtools/python/python3-oauthlib_3.3.1.bb b/meta-python/recipes-devtools/python/python3-oauthlib_3.3.1.bb index bdc1f0e7b4..0974020a17 100644 --- a/meta-python/recipes-devtools/python/python3-oauthlib_3.3.1.bb +++ b/meta-python/recipes-devtools/python/python3-oauthlib_3.3.1.bb @@ -4,6 +4,11 @@ HOMEPAGE = "https://github.com/idan/oauthlib" LICENSE = "BSD-3-Clause" LIC_FILES_CHKSUM = "file://LICENSE;md5=2699a9fb0d71d5eafd75d8d7c302f7df" +SRC_URI += " \ + file://CVE-2026-49265_p1.patch \ + file://CVE-2026-49265_p2.patch \ +" + SRC_URI[sha256sum] = "0f0f8aa759826a193cf66c12ea1af1637f87b9b4622d46e866952bb022e538c9" CVE_PRODUCT = "oauthlib" From patchwork Fri Nov 20 03:46:16 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)" X-Patchwork-Id: 105015 Received: from aer-iport-1.cisco.com (aer-iport-1.cisco.com [173.38.203.51]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.4791.1795146382343166330 for ; Thu, 19 Nov 2026 19:46:23 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: message contains an insecure body length tag" header.i=@cisco.com header.s=iport01 header.b=GoUX0nx8; spf=pass (domain: cisco.com, ip: 173.38.203.51, mailfrom: hthakar@cisco.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=13990; q=dns/txt; s=iport01; t=1795146382; x=1796355982; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=UJj+P0Lq6xregR0wE8AqUZDUaw622ghwKDkUgdEDmCg=; b=GoUX0nx8cYIBVBFt1IStX9C3yHNAub1+EyhIQne5tqAT/3U9cZ5mA1iI bIo+YuzEdEGQSvx6o5iv5Zm+EfFmb6FKpr2ONl7rJ1kFP3Nl4Be4mZj50 S9M0jPtJ6tBK/vuoG0pszxigvJ6LDd3rENhek2eZ2Pkv2COh45bWPzrPH WlHMjGz5OSPDsqQcHURZhMLirVhLwL559jXXLe4aIhnXIkvv6fiXpEW4X GfrAE6gXrPSK+a4v6m9MktUNdOI+ly0NbmGf5cCAnGIEabdaX//81O0Zd Ise0tMUf1pOO8PWLYwmPm4szyaIKMnX9CuFepHx9rC+TSGu2tugDcjtDc g==; X-CSE-ConnectionGUID: vhiGr+GjT+ixQGRMp1sJkQ== X-CSE-MsgGUID: RTgS+9TYR7+Ao5a1d1XZQQ== X-IPAS-Result: A0AuAABXwf9q/9RK/pBaHQEBAQEJARIBBQUBgXwIAQsBglZ1YENJA4xvhziBNWwDgROKU4VqjFmBfg8BAQEPRA0EAQGEP0YCjiECJjQJDgECBAMCAwEBAQEBAQEBAQEBAQoBAQUBAQECAQcFgQ4ThhUIMg2QEgECAQMyARgBPRwDAQIvIAsjCBmDAgGCOgM3AxG5O4IsgQGDKQE/AkNQ2EwNgloBCxQBgTgBhUGDAIUkXRgBhH0nGxuBcoEVgnR2gQWBGhgqAQGBSIZeBIIigQyBVIELhTGGWwKBT4gmSIEeA1ksAVUTDQoLBwWBaAM1EioVbjIdgSM7F4EHGwYFgRyBHoESgQNdgSsoXiGBCIF2AoJRggACAUlBDgdFUwklQxJHJCIIEgkBExosCoEaNTwJJj8VDGcLGgVhCAINDHQ5EDAeJC8FGiY+GwqBDCcfHhsOAh8QBg0YDUgRLDcVGQQ+bgeTbIImUxkGAXQHEwEHAyABFxJWHAUUDxcPFAYpEQ0EGJJgJZI2oCBxCiiDeYwkjz6FfBozhASBV5JDklQLmH2CWYhOgmOECoQijQsqIANNhGqBaDyBRwsHcBWDIgkKQBkPjFiBVwoLg2CBf4MUUch3JjICCQMvAQEHAgcOAwuBaJAAAiYCBYFPAQE IronPort-Data: A9a23:YHaQlq/sQa5WBmDicsnPDrUD1H+TJUtcMsCJ2f8bNWPcYEJGY0x3n 2VMCm7QP6mJNmWgLdojYI21oEwF7cLdytBlQFQ6rSlEQiMRo6IpJzg2wmQcns+2BpeeJK6yx 5xGMrEsFOhtEDmB4E/rYuK8xZVF/fngbqLmD+LZMTxGSwZhSSMw4TpugOdRbrRA2bBVOCvT/ 4mtyyHjEAX9gWAtazhMs/3rRC5H5ZwehhtJ5jTSWtgT1LPuvyF9JI4SI6i3M0z5TuF8dsamR /zOxa2O5WjQ+REgELuNyt4XpWVTH9Y+lSDX4pZnc/DKbipq/0Te4Y5nXBYoUnq7vh3S9zxHJ HqhgrTrIeshFvWkdO3wyHC0GQkmVUFN0OevzXRSLaV/wmWeG0YAzcmCA2koPYw34KVYA10N9 OwhBwoodkmYpeGPlefTpulE3qzPLeHiMZlavjRryivUSK9/B5vCWK7No9Rf2V/chOgXQaqYP ZdFL2UzKk6ZOXWjOX9PYH46tOe0hnD8eidwo1OOrq1x6G/WpOB0+Oa3aYePIIPXLSlTtnykq VmFrljIOE5ZHdvCwGOJq0Kev9aayEsXX6pXTtVU7MVCh0WewGEWAhAaWVa35PW0lEO6c9ZeM FAPvC02oK4/8UamQtXwU1u/unHsg/IHc9NdCag+rQqK0KeRul/fDWkfRTkHY9sj3CMreQEXO payt4uBLVRSXHe9EBpxKp/8QeuOBBUo IronPort-HdrOrdr: A9a23:tqJJgqhTLalyZRvc/x0zOOxq4HBQXvYji2hC6mlwRA09TyX+rb HLoB1173HJYVoqNU3I3OrwW5VoIkmskKKdn7NxAV7KZmCP0wGVxcNZnOnfKlbbdBEWmNQw6U 4ZSchDIey1K0RmhsDn5wT9OdMhzN6btJ2Mv47lvhBQpcUAUdAY0++/YTzrdHFLeA== X-Talos-CUID: 9a23:BCvHSmoguORqi7z3wSy54s7mUd4lc1LHj1jSHwy5GV9GcpiNEESy+5oxxg== X-Talos-MUID: 9a23:fu+g7Q1u1C4NNdaIikL2xopB4zUj2ZihMwNcraQ85IqtMnF5YjvEvAaOe9py X-IronPort-Anti-Spam-Filtered: true X-IronPort-AV: E=Sophos;i="6.27,222,1787011200"; d="scan'208";a="62152275" Received: from aer-l-core-11.cisco.com ([144.254.74.212]) by aer-iport-1.cisco.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Nov 2026 03:46:20 +0000 Received: from sjc-ads-5245.cisco.com (sjc-ads-5245.cisco.com [10.28.23.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aer-l-core-11.cisco.com (Postfix) with ESMTPS id 8EEBB1800042C for ; Fri, 20 Nov 2026 03:46:19 +0000 (GMT) Received: by sjc-ads-5245.cisco.com (Postfix, from userid 1887505) id 3DB81CBF201; Thu, 19 Nov 2026 19:46:18 -0800 (PST) From: "Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)" To: openembedded-devel@lists.openembedded.org Subject: [meta-python][wrynose][PATCH 2/4] python3-oauthlib: fix CVE-2026-49264 Date: Thu, 19 Nov 2026 19:46:16 -0800 Message-Id: <20261120034618.604880-2-hthakar@cisco.com> X-Mailer: git-send-email 2.35.6 In-Reply-To: <20261120034618.604880-1-hthakar@cisco.com> References: <20261120034618.604880-1-hthakar@cisco.com> MIME-Version: 1.0 X-Outbound-Client-TLS: ANONYMOUS;sjc-ads-5245.cisco.com [10.28.23.9];TLSv1.3;TLS_AES_256_GCM_SHA384;256 X-Outbound-SMTP-Client: 10.28.23.9, sjc-ads-5245.cisco.com X-Outbound-Node: aer-l-core-11.cisco.com List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Fri, 20 Nov 2026 03:46:25 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-devel/message/132757 From: Hetvi Thakar When enable_jsonp=True, the token revocation endpoint reflects an unvalidated callback into its responses. Applications loading these responses as trusted JSONP can execute attacker-controlled JavaScript. Backport upstream fix [1], referenced by NVD [2] and Debian [3], to remove JSONP support from token revocation in OAuthLib 3.3.1. Include upstream follow-up [4] to reject callback passed through keyword arguments, including callback=None, and retain its regression tests. Omit the CHANGELOG.rst update because its newer release-note context is absent from the 3.3.1 source. [1] https://github.com/oauthlib/oauthlib/commit/c888359f3c42bec235b2c5caab2069c9ed62457c [2] https://nvd.nist.gov/vuln/detail/CVE-2026-49264 [3] https://security-tracker.debian.org/tracker/CVE-2026-49264 [4] https://github.com/oauthlib/oauthlib/commit/8f7db807dfeabc69386b4b67b14bb10c9efe56c8 Signed-off-by: Hetvi Thakar --- .../python3-oauthlib/CVE-2026-49264_p1.patch | 200 ++++++++++++++++++ .../python3-oauthlib/CVE-2026-49264_p2.patch | 50 +++++ .../python/python3-oauthlib_3.3.1.bb | 2 + 3 files changed, 252 insertions(+) create mode 100644 meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49264_p1.patch create mode 100644 meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49264_p2.patch diff --git a/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49264_p1.patch b/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49264_p1.patch new file mode 100644 index 0000000000..e336f9b6a7 --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49264_p1.patch @@ -0,0 +1,200 @@ +From c888359f3c42bec235b2c5caab2069c9ed62457c Mon Sep 17 00:00:00 2001 +From: Jonathan Huot +Date: Fri, 22 May 2026 19:51:42 +0000 +Subject: [PATCH] Remove JSONP support from token revocation + +JSONP was useful in the past for cross-origin requests but has been +superseded by CORS browser protections. This change removes the outdated +JSONP functionality. + +Breaking changes: +- Remove enable_jsonp parameter from RevocationEndpoint +- Remove callback parameter from prepare_token_revocation_request +- Remove JSONP documentation and examples +- Remove JSONP tests + +The token revocation endpoint now returns empty response bodies on +success instead of JSONP-wrapped responses. + +CVE: CVE-2026-49264 +Upstream-Status: Backport [https://github.com/oauthlib/oauthlib/commit/c888359f3c42bec235b2c5caab2069c9ed62457c] + +Backport Changes: +- Omit the CHANGELOG.rst hunk because its later WIP section is absent + from 3.3.1. Retain all upstream code, documentation and test changes. + +Signed-off-by: Hetvi Thakar +--- + oauthlib/oauth2/rfc6749/clients/base.py | 24 ++-------------------- + oauthlib/oauth2/rfc6749/endpoints/revocation.py | 11 ++-------- + oauthlib/oauth2/rfc6749/parameters.py | 8 ++------ + tests/oauth2/rfc6749/clients/test_base.py | 7 ------- + .../rfc6749/endpoints/test_revocation_endpoint.py | 13 ------------ + 5 files changed, 6 insertions(+), 57 deletions(-) + +diff --git a/oauthlib/oauth2/rfc6749/clients/base.py b/oauthlib/oauth2/rfc6749/clients/base.py +index 17f833d236cb0f1ca7a4dd85f661b2e6be6b087e..cdbbc191f75393d8e17fbcd852987bb45dd9c0df 100644 +--- a/oauthlib/oauth2/rfc6749/clients/base.py ++++ b/oauthlib/oauth2/rfc6749/clients/base.py +@@ -320,7 +320,7 @@ class Client: + return token_url, FORM_ENC_HEADERS, body + + def prepare_token_revocation_request(self, revocation_url, token, +- token_type_hint="access_token", body='', callback=None, **kwargs): ++ token_type_hint="access_token", body='', **kwargs): + """Prepare a token revocation request. + + :param revocation_url: Provider token revocation endpoint URL. +@@ -329,14 +329,9 @@ class Client: + ``"refresh_token"``. This is optional and if you wish to not pass it you + must provide ``token_type_hint=None``. + :param body: +- :param callback: A jsonp callback such as ``package.callback`` to be invoked +- upon receiving the response. Not that it should not include a () suffix. + :param kwargs: Additional parameters to included in the request. + :returns: The prepared request tuple with (url, headers, body). + +- Note that JSONP request may use GET requests as the parameters will +- be added to the request URL query as opposed to the request body. +- + An example of a revocation request + + .. code-block:: http +@@ -348,21 +343,6 @@ class Client: + + token=45ghiukldjahdnhzdauz&token_type_hint=refresh_token + +- An example of a jsonp revocation request +- +- .. code-block:: http +- +- GET /revoke?token=agabcdefddddafdd&callback=package.myCallback HTTP/1.1 +- Host: server.example.com +- Content-Type: application/x-www-form-urlencoded +- Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW +- +- and an error response +- +- .. code-block:: javascript +- +- package.myCallback({"error":"unsupported_token_type"}); +- + Note that these requests usually require client credentials, client_id in + the case for public clients and provider specific authentication + credentials for confidential clients. +@@ -371,7 +351,7 @@ class Client: + raise InsecureTransportError() + + return prepare_token_revocation_request(revocation_url, token, +- token_type_hint=token_type_hint, body=body, callback=callback, ++ token_type_hint=token_type_hint, body=body, + **kwargs) + + def parse_request_body_response(self, body, scope=None, **kwargs): +diff --git a/oauthlib/oauth2/rfc6749/endpoints/revocation.py b/oauthlib/oauth2/rfc6749/endpoints/revocation.py +index 596d0860fae67017a86b1042fcf9edb674fdf38d..06b450a43fa7c9b74c293b0cbade270629c0a9f1 100644 +--- a/oauthlib/oauth2/rfc6749/endpoints/revocation.py ++++ b/oauthlib/oauth2/rfc6749/endpoints/revocation.py +@@ -27,13 +27,11 @@ class RevocationEndpoint(BaseEndpoint): + valid_token_types = ('access_token', 'refresh_token') + valid_request_methods = ('POST',) + +- def __init__(self, request_validator, supported_token_types=None, +- enable_jsonp=False): ++ def __init__(self, request_validator, supported_token_types=None): + BaseEndpoint.__init__(self) + self.request_validator = request_validator + self.supported_token_types = ( + supported_token_types or self.valid_token_types) +- self.enable_jsonp = enable_jsonp + + @catch_errors_and_unavailability + def create_revocation_response(self, uri, http_method='POST', body=None, +@@ -69,18 +67,13 @@ class RevocationEndpoint(BaseEndpoint): + except OAuth2Error as e: + log.debug('Client error during validation of %r. %r.', request, e) + response_body = e.json +- if self.enable_jsonp and request.callback: +- response_body = '{}({});'.format(request.callback, response_body) + resp_headers.update(e.headers) + return resp_headers, response_body, e.status_code + + self.request_validator.revoke_token(request.token, + request.token_type_hint, request) + +- response_body = '' +- if self.enable_jsonp and request.callback: +- response_body = request.callback + '();' +- return {}, response_body, 200 ++ return {}, '', 200 + + def validate_revocation_request(self, request): + """Ensure the request is valid. +diff --git a/oauthlib/oauth2/rfc6749/parameters.py b/oauthlib/oauth2/rfc6749/parameters.py +index 8268ef927cc2d174f44a00e60cf07156fb223db7..b912e447b817c7ed125900f4e5c455ff416cb6d2 100644 +--- a/oauthlib/oauth2/rfc6749/parameters.py ++++ b/oauthlib/oauth2/rfc6749/parameters.py +@@ -172,7 +172,7 @@ def prepare_token_request(grant_type, body='', include_client_id=True, code_veri + + + def prepare_token_revocation_request(url, token, token_type_hint="access_token", +- callback=None, body='', **kwargs): ++ body='', **kwargs): + """Prepare a token revocation request. + + The client constructs the request by including the following parameters +@@ -222,11 +222,7 @@ def prepare_token_revocation_request(url, token, token_type_hint="access_token", + + headers = {'Content-Type': 'application/x-www-form-urlencoded'} + +- if callback: +- params.append(('callback', callback)) +- return add_params_to_uri(url, params), headers, body +- else: +- return url, headers, add_params_to_qs(body, params) ++ return url, headers, add_params_to_qs(body, params) + + + def parse_authorization_code_response(uri, state=None): +diff --git a/tests/oauth2/rfc6749/clients/test_base.py b/tests/oauth2/rfc6749/clients/test_base.py +index b0970f2d46a5f053ad7100ebda3f09bc27bc5281..d01a1dbdcc4232eacb8dafbf6f81c871f641aa35 100644 +--- a/tests/oauth2/rfc6749/clients/test_base.py ++++ b/tests/oauth2/rfc6749/clients/test_base.py +@@ -237,13 +237,6 @@ class ClientTest(TestCase): + self.assertEqual(h, {'Content-Type': 'application/x-www-form-urlencoded'}) + self.assertEqual(b, 'token=%s&token_type_hint=refresh_token' % token) + +- # JSONP +- u, h, b = client.prepare_token_revocation_request( +- url, token, callback='hello.world') +- self.assertURLEqual(u, url + '?callback=hello.world&token=%s&token_type_hint=access_token' % token) +- self.assertEqual(h, {'Content-Type': 'application/x-www-form-urlencoded'}) +- self.assertEqual(b, '') +- + def test_prepare_authorization_request(self): + redirect_url = 'https://example.com/callback/' + scopes = 'read' +diff --git a/tests/oauth2/rfc6749/endpoints/test_revocation_endpoint.py b/tests/oauth2/rfc6749/endpoints/test_revocation_endpoint.py +index 338dbd91faa795a0c25d7254818fbf72879c2920..d347b1767c285bddd1e99910e173df2343239add 100644 +--- a/tests/oauth2/rfc6749/endpoints/test_revocation_endpoint.py ++++ b/tests/oauth2/rfc6749/endpoints/test_revocation_endpoint.py +@@ -88,19 +88,6 @@ class RevocationEndpointTest(TestCase): + self.assertEqual(loads(b)['error'], 'invalid_client') + self.assertEqual(s, 401) + +- def test_revoke_with_callback(self): +- endpoint = RevocationEndpoint(self.validator, enable_jsonp=True) +- callback = 'package.hello_world' +- for token_type in ('access_token', 'refresh_token', 'invalid'): +- body = urlencode([('token', 'foo'), +- ('token_type_hint', token_type), +- ('callback', callback)]) +- h, b, s = endpoint.create_revocation_response(self.uri, +- headers=self.headers, body=body) +- self.assertEqual(h, {}) +- self.assertEqual(b, callback + '();') +- self.assertEqual(s, 200) +- + def test_revoke_unsupported_token(self): + endpoint = RevocationEndpoint(self.validator, + supported_token_types=['access_token']) diff --git a/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49264_p2.patch b/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49264_p2.patch new file mode 100644 index 0000000000..24694cc8d1 --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49264_p2.patch @@ -0,0 +1,50 @@ +From 8f7db807dfeabc69386b4b67b14bb10c9efe56c8 Mon Sep 17 00:00:00 2001 +From: Jonathan Huot +Date: Sat, 11 Jul 2026 12:21:48 +0200 +Subject: [PATCH] Reject callback in revocation params + +Prevent callback from being accepted via kwargs in prepare_token_revocation_request, and add a regression test to ensure callback now raises TypeError. + +CVE: CVE-2026-49264 +Upstream-Status: Backport [https://github.com/oauthlib/oauthlib/commit/8f7db807dfeabc69386b4b67b14bb10c9efe56c8] + +Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> +Signed-off-by: Hetvi Thakar +--- + oauthlib/oauth2/rfc6749/parameters.py | 3 +++ + tests/oauth2/rfc6749/test_parameters.py | 8 ++++++++ + 2 files changed, 11 insertions(+) + +diff --git a/oauthlib/oauth2/rfc6749/parameters.py b/oauthlib/oauth2/rfc6749/parameters.py +index 1b026037..ae483b9e 100644 +--- a/oauthlib/oauth2/rfc6749/parameters.py ++++ b/oauthlib/oauth2/rfc6749/parameters.py +@@ -216,6 +216,9 @@ def prepare_token_revocation_request(url, token, token_type_hint="access_token", + if token_type_hint: + params.append(('token_type_hint', token_type_hint)) + ++ if 'callback' in kwargs: ++ raise TypeError("prepare_token_revocation_request() got an unexpected keyword argument 'callback'") ++ + for k in kwargs: + if kwargs[k]: + params.append((str(k), kwargs[k])) +diff --git a/tests/oauth2/rfc6749/test_parameters.py b/tests/oauth2/rfc6749/test_parameters.py +index bd8a8b61..0c14de99 100644 +--- a/tests/oauth2/rfc6749/test_parameters.py ++++ b/tests/oauth2/rfc6749/test_parameters.py +@@ -208,6 +208,14 @@ def test_prepare_token_request(self): + self.assertFormBodyEqual(prepare_token_request(**self.cred_grant), self.cred_body) + self.assertFormBodyEqual(prepare_token_request(**self.grant_body_pkce), self.auth_grant_body_pkce) + ++ def test_prepare_token_revocation_request_rejects_callback(self): ++ with self.assertRaisesRegex( ++ TypeError, ++ "prepare_token_revocation_request\\(\\) got an unexpected keyword argument 'callback'"): ++ prepare_token_revocation_request( ++ "https://server.example.com/revoke", "token", callback="jsonp" ++ ) ++ + def test_grant_response(self): + """Verify correct parameter parsing and validation for auth code responses.""" + params = parse_authorization_code_response(self.grant_response) diff --git a/meta-python/recipes-devtools/python/python3-oauthlib_3.3.1.bb b/meta-python/recipes-devtools/python/python3-oauthlib_3.3.1.bb index 0974020a17..ffb07fef30 100644 --- a/meta-python/recipes-devtools/python/python3-oauthlib_3.3.1.bb +++ b/meta-python/recipes-devtools/python/python3-oauthlib_3.3.1.bb @@ -7,6 +7,8 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=2699a9fb0d71d5eafd75d8d7c302f7df" SRC_URI += " \ file://CVE-2026-49265_p1.patch \ file://CVE-2026-49265_p2.patch \ + file://CVE-2026-49264_p1.patch \ + file://CVE-2026-49264_p2.patch \ " SRC_URI[sha256sum] = "0f0f8aa759826a193cf66c12ea1af1637f87b9b4622d46e866952bb022e538c9" From patchwork Fri Nov 20 03:46:17 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)" X-Patchwork-Id: 105016 Received: from aer-iport-6.cisco.com (aer-iport-6.cisco.com [173.38.203.68]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.4792.1795146382716273373 for ; Thu, 19 Nov 2026 19:46:23 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: message contains an insecure body length tag" header.i=@cisco.com header.s=iport01 header.b=YVfqjcMX; spf=pass (domain: cisco.com, ip: 173.38.203.68, mailfrom: hthakar@cisco.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=41868; q=dns/txt; s=iport01; t=1795146382; x=1796355982; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=aT+Mo/+/qbfxXQICuvQQ//GIUl/nTmW9IeoL1e4ek6s=; b=YVfqjcMXplJbvColhBmQSbC2hmYwD2xlyFcwbR7QoHsnjM4xjlr9T26Y KmvWv2B6UhfRDWpATWiwRl53FdHZovv6ww0y69Ms0ayd5Z5a77tnH21L/ ZDI3SIqgTJa+DTcZXpCrtNCj7H/v/dlRPOicO4wii2c2BYNZ1/HSK5BQc BN6EieUOhci60HZOt9idriPqLSd1eLhwisx+6B0vxdPo+NreroA0RHgs6 4HcPF2+fZWNzWTBuRZGpjUTnJpWcmqu57xvr9Mot7PDl3aJoER/LqUNVF +y1euWLOs7FFihtxQPSoVqizvng5+JbYG269tBZdTAYAuz7itZNoXNw+H A==; X-CSE-ConnectionGUID: DL9y2wSrTkiHcHtQe7+XEQ== X-CSE-MsgGUID: 8mxU2vqYRFWh5eECcfPjqQ== X-IPAS-Result: A0C3AgBXwf9q/8xK/pBRCR4BAQsSDIIFC4JXdWBDSQOUJ4IhA4tmhWqMWYF+DwEBAQ9EDQQBAYQ/RgKOIQImNAkOAQIEAwIDAQEBAQEBAQEBAQEBCgEBBQEBAQIBBwWBDhOGTw2QEgECAQMaARcBGAE9HAMBAhkWIAsjCBmDAgGCOgM3AxG5O4IsgQGDKQE/AkNQ2EwNgloBCxQBgTiFQoMAhSRdGAGEfScbG4FygRWDaoEFgRpCAQECAYExFGiFdgSCIoEMgQdNgQuLchoCgU+BW4ZLSIEeA1ksAVUTDQoLBwWBaAM1EioVbjIdgSM7F4EHGwYFgRyBHoESgQNdgSsoXiGBCIF2AoJRggACAUlBDgdFUwklQxJHJCIIEgkBExosCoEaNTwJJj8VDGcLGgVhCAINDHQ5EDAeJC8FGiY+GwqBDCcfHhsOAh8QBg0YDUgRLDcVGQQ+bgeTbIImJgcOAjYvMhMHEwEpAQECFQoId2MBASccAQUDjiCETAkUCQiSNoE1nmtxCiiDeYwkjz6FfBozhASBV6UXC5h9glmIToJjhAqRKwI9DQNNhGqBaDyBRwsHcBWDIglKGQ+OOYNrgX+DFFHIdyYyAgEIAy8BAQcCBw4DC4FokAIkCYFPAQE IronPort-Data: A9a23:AfOyTqvAgVfqoVpDDNf2CQ3dzufnVAJfMUV32f8akzHdYApBsoF/q tZmKTyFOvuNamLwf9EjO4239klQu5PVn4JnGwBprykwE3sWgMeUXt7xwmUckM+xwmwvaGo9s q3yv/GZdJhcokf0/0nrb/656ykmiMlkf5KkYMbcICd9WAR4fykojBNnioYRj5Vh6TSDK1vlV eja/YuFZzdJ5xYuajhKsvvZ8Esw1BjPkGpwUmIWNKgjUGD2zxH5PLpHTYmtIn3xRJVjH+LSb 47r0LGj82rFyAwmA9Wjn6yTWhVirmn6ZFXmZtJ+AsBOszAazsAA+v9T2Mk0NS+7vw60c+VZk 72hg3AfpTABZcUgkMxFO/VR/roX0aduoNcrKlDn2SCfItGvn3bEm51T4E8K0YIw1sImEDtRz uYkKzEtZTCfvu/pg4KWc7w57igjBJGD0II3s3x6iDWcBvE8TNWbGOPB5MRT23E7gcUm8fT2P pZFL2AyMFKfP1sVYgt/5JEWxI9EglH/bz1Rq1uPjaE2+GPUigd21dABNfKIK4fXFJUJwi50o EqW+nTEWA8DBeax9jrY/1+HjeH3nzrCDdd6+LqQs6QCbEeo7msLBRsbUFG2rfW0hguyVsxSL 2QQ+zEytu417EGtQ9z3UhG0rXLCuQQTM+e8CMUz5RvIzu/f5ByUQzBfCDVAc9ch8sQxQFTGy 2O0oj8gPhQ32JX9dJ5X3u78Qe+aUcTNEVI/WA== IronPort-HdrOrdr: A9a23:1AK78aoVVitRnwuVgM72TdQaV5oHeYIsimQD101hICG9Ffbo8/ xG88506faZslsssTQb6LO90cq7MBbhHOBOgLX5VI3KNGKNhILrFvAB0WKI+VLd8kPFmtK1rZ 0BT4FOTPvtEFN9kcH2pCO8E9om3Z271ZrAv5a485+oJjsaEp2JKGxCe2CmLnE= X-Talos-CUID: 9a23:vGq1NWvtu8xV6Xq6srffEpyB6IsJVizMlmjrOXO7CEZiaKGsRADTyI5dxp8= X-Talos-MUID: 9a23:oBS/gw0Upa6fgE1UOva5qDzgjjUjs6G+NRoTiKQ8lfaEaCFdEDyTtDaue9py X-IronPort-Anti-Spam-Filtered: true X-IronPort-AV: E=Sophos;i="6.27,222,1787011200"; d="scan'208";a="59359844" Received: from aer-l-core-03.cisco.com ([144.254.74.204]) by aer-iport-6.cisco.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Nov 2026 03:46:20 +0000 Received: from sjc-ads-5245.cisco.com (sjc-ads-5245.cisco.com [10.28.23.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aer-l-core-03.cisco.com (Postfix) with ESMTPS id 9E027180006C5 for ; Fri, 20 Nov 2026 03:46:19 +0000 (GMT) Received: by sjc-ads-5245.cisco.com (Postfix, from userid 1887505) id 4537BCBF202; Thu, 19 Nov 2026 19:46:18 -0800 (PST) From: "Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)" To: openembedded-devel@lists.openembedded.org Subject: [meta-python][wrynose][PATCH 3/4] python3-oauthlib: fix CVE-2026-118669 Date: Thu, 19 Nov 2026 19:46:17 -0800 Message-Id: <20261120034618.604880-3-hthakar@cisco.com> X-Mailer: git-send-email 2.35.6 In-Reply-To: <20261120034618.604880-1-hthakar@cisco.com> References: <20261120034618.604880-1-hthakar@cisco.com> MIME-Version: 1.0 X-Outbound-Client-TLS: ANONYMOUS;sjc-ads-5245.cisco.com [10.28.23.9];TLSv1.3;TLS_AES_256_GCM_SHA384;256 X-Outbound-SMTP-Client: 10.28.23.9, sjc-ads-5245.cisco.com X-Outbound-Node: aer-l-core-03.cisco.com List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Fri, 20 Nov 2026 03:46:25 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-devel/message/132758 From: Hetvi Thakar The client_credentials and password grants can authenticate one client while authorizing grants and scopes using a supplied client_id for another client, when validators rely on that client_id argument. Backport upstream fix [1], referenced by NVD [2] and Debian [3], to bind authorization to the authenticated client identity and reject a conflicting client_id in OAuthLib 3.3.1. Include authentication-helper prerequisite [4] for the older grant implementation. Public-client validators must attach request.client. Retain the upstream validator contract and regressions, and add cases for missing, matching and inconsistent client identifiers. Omit docs/oauth2/server.rst because the 3.3.1 source archive excludes docs. [1] https://github.com/oauthlib/oauthlib/commit/c951a1d09f99f14e3240973fa83c4f4287d4753d [2] https://nvd.nist.gov/vuln/detail/CVE-2026-118669 [3] https://security-tracker.debian.org/tracker/CVE-2026-118669 [4] https://github.com/oauthlib/oauthlib/commit/90d8aa851b6ce0fd095ed27e0f88051ab02279a9 Signed-off-by: Hetvi Thakar --- .../CVE-2026-118669-dependent.patch | 237 +++++++ .../python3-oauthlib/CVE-2026-118669.patch | 602 ++++++++++++++++++ .../python/python3-oauthlib_3.3.1.bb | 2 + 3 files changed, 841 insertions(+) create mode 100644 meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-118669-dependent.patch create mode 100644 meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-118669.patch diff --git a/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-118669-dependent.patch b/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-118669-dependent.patch new file mode 100644 index 0000000000..f3933854e5 --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-118669-dependent.patch @@ -0,0 +1,237 @@ +From 90d8aa851b6ce0fd095ed27e0f88051ab02279a9 Mon Sep 17 00:00:00 2001 +From: Kyle Hekhuis +Date: Mon, 14 Jul 2025 16:04:42 -0400 +Subject: [PATCH] Add helper method for validating client authentication and + use it in AuthorizationCodeGrant, DeviceCodeGrant, RefreshTokenGrant, and + ResourceOwnerPasswordCredentialsGrant. + +Add some missing imports to the oauth2 __init__.py + +CVE: CVE-2026-118669 +Upstream-Status: Backport [https://github.com/oauthlib/oauthlib/commit/90d8aa851b6ce0fd095ed27e0f88051ab02279a9] + +Signed-off-by: Hetvi Thakar +--- + oauthlib/oauth2/__init__.py | 5 ++-- + .../rfc6749/grant_types/authorization_code.py | 16 +---------- + oauthlib/oauth2/rfc6749/grant_types/base.py | 21 +++++++++++++++ + .../oauth2/rfc6749/grant_types/refresh_token.py | 16 ++++------- + .../resource_owner_password_credentials.py | 9 +------ + oauthlib/oauth2/rfc8628/grant_types/device_code.py | 20 +++++--------- + .../oauth2/rfc8628/grant_types/test_device_code.py | 31 +++++++++++++++++++++- + 7 files changed, 67 insertions(+), 51 deletions(-) + +diff --git a/oauthlib/oauth2/__init__.py b/oauthlib/oauth2/__init__.py +index 3bb5102..0e0bafd 100644 +--- a/oauthlib/oauth2/__init__.py ++++ b/oauthlib/oauth2/__init__.py +@@ -66,5 +66,6 @@ from .rfc6749.request_validator import RequestValidator + from .rfc6749.tokens import BearerToken, OAuth2Token + from .rfc6749.utils import is_secure_transport + from .rfc8628.clients import DeviceClient +-from oauthlib.oauth2.rfc8628.endpoints import DeviceAuthorizationEndpoint, DeviceApplicationServer +-from oauthlib.oauth2.rfc8628.grant_types import DeviceCodeGrant ++from .rfc8628.endpoints import DeviceAuthorizationEndpoint, DeviceApplicationServer ++from .rfc8628.errors import AuthorizationPendingError, SlowDownError, ExpiredTokenError, AccessDenied ++from .rfc8628.grant_types import DeviceCodeGrant +diff --git a/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py b/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py +index 09dc619..f2d6d27 100644 +--- a/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py ++++ b/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py +@@ -452,21 +452,7 @@ class AuthorizationCodeGrant(GrantTypeBase): + raise errors.InvalidRequestError(description='Duplicate %s parameter.' % param, + request=request) + +- if self.request_validator.client_authentication_required(request): +- # If the client type is confidential or the client was issued client +- # credentials (or assigned other authentication requirements), the +- # client MUST authenticate with the authorization server as described +- # in Section 3.2.1. +- # https://tools.ietf.org/html/rfc6749#section-3.2.1 +- if not self.request_validator.authenticate_client(request): +- log.debug('Client authentication failed, %r.', request) +- raise errors.InvalidClientError(request=request) +- elif not self.request_validator.authenticate_client_id(request.client_id, request): +- # REQUIRED, if the client is not authenticating with the +- # authorization server as described in Section 3.2.1. +- # https://tools.ietf.org/html/rfc6749#section-3.2.1 +- log.debug('Client authentication failed, %r.', request) +- raise errors.InvalidClientError(request=request) ++ self.validate_client_authentication(request) + + if not hasattr(request.client, 'client_id'): + raise NotImplementedError('Authenticate client must set the ' +diff --git a/oauthlib/oauth2/rfc6749/grant_types/base.py b/oauthlib/oauth2/rfc6749/grant_types/base.py +index d96a2db..0b69e54 100644 +--- a/oauthlib/oauth2/rfc6749/grant_types/base.py ++++ b/oauthlib/oauth2/rfc6749/grant_types/base.py +@@ -175,6 +175,27 @@ class GrantTypeBase: + request.scopes, request.client, request): + raise errors.InvalidScopeError(request=request) + ++ def validate_client_authentication(self, request): ++ """Raise on failed client authentication.""" ++ # Handles confidential clients ++ if self.request_validator.client_authentication_required(request): ++ # If the client type is confidential or the client was issued client ++ # credentials (or assigned other authentication requirements), the ++ # client MUST authenticate with the authorization server as described ++ # in Section 3.2.1. ++ # https://tools.ietf.org/html/rfc6749#section-3.2.1 ++ if not self.request_validator.authenticate_client(request): ++ log.debug('Client authentication failed, %r.', request) ++ raise errors.InvalidClientError(request=request) ++ ++ # Handles public clients ++ elif not self.request_validator.authenticate_client_id(request.client_id, request): ++ # REQUIRED, if the client is not authenticating with the ++ # authorization server as described in Section 3.2.1. ++ # https://tools.ietf.org/html/rfc6749#section-3.2.1 ++ log.debug('Client authentication failed, %r.', request) ++ raise errors.InvalidClientError(request=request) ++ + def prepare_authorization_response(self, request, token, headers, body, status): + """Place token according to response mode. + +diff --git a/oauthlib/oauth2/rfc6749/grant_types/refresh_token.py b/oauthlib/oauth2/rfc6749/grant_types/refresh_token.py +index 43bf55a..f626f0c 100644 +--- a/oauthlib/oauth2/rfc6749/grant_types/refresh_token.py ++++ b/oauthlib/oauth2/rfc6749/grant_types/refresh_token.py +@@ -96,17 +96,11 @@ class RefreshTokenGrant(GrantTypeBase): + # authentication requirements), the client MUST authenticate with the + # authorization server as described in Section 3.2.1. + # https://tools.ietf.org/html/rfc6749#section-3.2.1 +- if self.request_validator.client_authentication_required(request): +- log.debug('Authenticating client, %r.', request) +- if not self.request_validator.authenticate_client(request): +- log.debug('Invalid client (%r), denying access.', request) +- raise errors.InvalidClientError(request=request) +- # Ensure that request.client_id is set. +- if request.client_id is None and request.client is not None: +- request.client_id = request.client.client_id +- elif not self.request_validator.authenticate_client_id(request.client_id, request): +- log.debug('Client authentication failed, %r.', request) +- raise errors.InvalidClientError(request=request) ++ self.validate_client_authentication(request) ++ ++ # Ensure that request.client_id is set. ++ if request.client_id is None and request.client is not None: ++ request.client_id = request.client.client_id + + # Ensure client is authorized use of this grant type + self.validate_grant_type(request) +diff --git a/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py b/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py +index 55d9287..6fc67c6 100644 +--- a/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py ++++ b/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py +@@ -85,14 +85,7 @@ class ResourceOwnerPasswordCredentialsGrant(GrantTypeBase): + """ + headers = self._get_default_headers() + try: +- if self.request_validator.client_authentication_required(request): +- log.debug('Authenticating client, %r.', request) +- if not self.request_validator.authenticate_client(request): +- log.debug('Client authentication failed, %r.', request) +- raise errors.InvalidClientError(request=request) +- elif not self.request_validator.authenticate_client_id(request.client_id, request): +- log.debug('Client authentication failed, %r.', request) +- raise errors.InvalidClientError(request=request) ++ self.validate_client_authentication(request) + log.debug('Validating access token request, %r.', request) + self.validate_token_request(request) + except errors.OAuth2Error as e: +diff --git a/oauthlib/oauth2/rfc8628/grant_types/device_code.py b/oauthlib/oauth2/rfc8628/grant_types/device_code.py +index 082daf0..9d23d45 100644 +--- a/oauthlib/oauth2/rfc8628/grant_types/device_code.py ++++ b/oauthlib/oauth2/rfc8628/grant_types/device_code.py +@@ -55,14 +55,12 @@ class DeviceCodeGrant(GrantTypeBase): + description=f"Duplicate {param} parameter.", request=request + ) + +- if not self.request_validator.authenticate_client(request): +- raise rfc6749_errors.InvalidClientError(request=request) +- elif not hasattr(request.client, "client_id"): +- raise NotImplementedError( +- "Authenticate client must set the " +- "request.client.client_id attribute " +- "in authenticate_client." +- ) ++ self.validate_client_authentication(request) ++ ++ if not hasattr(request.client, 'client_id'): ++ raise NotImplementedError('Authenticate client must set the ' ++ 'request.client.client_id attribute ' ++ 'in authenticate_client.') + + # Ensure client is authorized use of this grant type + self.validate_grant_type(request) +@@ -93,13 +91,7 @@ class DeviceCodeGrant(GrantTypeBase): + """ + headers = self._get_default_headers() + try: +- if self.request_validator.client_authentication_required( +- request +- ) and not self.request_validator.authenticate_client(request): +- raise rfc6749_errors.InvalidClientError(request=request) +- + self.validate_token_request(request) +- + except rfc6749_errors.OAuth2Error as e: + headers.update(e.headers) + return headers, e.json, e.status_code +diff --git a/tests/oauth2/rfc8628/grant_types/test_device_code.py b/tests/oauth2/rfc8628/grant_types/test_device_code.py +index da0592f..10b5dd6 100644 +--- a/tests/oauth2/rfc8628/grant_types/test_device_code.py ++++ b/tests/oauth2/rfc8628/grant_types/test_device_code.py +@@ -99,7 +99,7 @@ def test_create_token_response(): + validator.save_token.assert_called_once() + + +-def test_invalid_client_error(): ++def test_invalid_client_authentication_error_confidential_client(): + validator = mock.MagicMock() + request: common.Request = create_request() + request.client = mock.Mock() +@@ -107,6 +107,8 @@ def test_invalid_client_error(): + auth = DeviceCodeGrant(validator) + bearer = BearerToken(validator) + ++ # Simulate a confidential client that requires authentication ++ validator.client_authentication_required.return_value = True + validator.authenticate_client.return_value = False + + headers, body, status_code = auth.create_token_response(request, bearer) +@@ -124,6 +126,33 @@ def test_invalid_client_error(): + validator.save_token.assert_not_called() + + ++def test_invalid_client_authentication_error_public_client(): ++ validator = mock.MagicMock() ++ request: common.Request = create_request() ++ request.client = mock.Mock() ++ ++ auth = DeviceCodeGrant(validator) ++ bearer = BearerToken(validator) ++ ++ # Simulate a public client that does not require authentication ++ validator.client_authentication_required.return_value = False ++ validator.authenticate_client_id.return_value = False ++ ++ headers, body, status_code = auth.create_token_response(request, bearer) ++ body = json.loads(body) ++ ++ assert headers == { ++ "Content-Type": "application/json", ++ "Cache-Control": "no-store", ++ "Pragma": "no-cache", ++ "WWW-Authenticate": 'Bearer error="invalid_client"', ++ } ++ assert body == {"error": "invalid_client"} ++ assert status_code == 401 ++ ++ validator.save_token.assert_not_called() ++ ++ + def test_invalid_grant_type_error(): + validator = mock.MagicMock() + request: common.Request = create_request() diff --git a/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-118669.patch b/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-118669.patch new file mode 100644 index 0000000000..dd89de8a4a --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-118669.patch @@ -0,0 +1,602 @@ +From c951a1d09f99f14e3240973fa83c4f4287d4753d Mon Sep 17 00:00:00 2001 +From: Jonathan Huot +Date: Sat, 11 Jul 2026 16:25:12 +0200 +Subject: [PATCH] Organized validate_client functions for all grant to avoid + mistake in grnat implementation + +CVE: CVE-2026-118669 +Upstream-Status: Backport [https://github.com/oauthlib/oauthlib/commit/c951a1d09f99f14e3240973fa83c4f4287d4753d] + +Backport Changes: +- Omit docs/oauth2/server.rst because the 3.3.1 PyPI source archive + excludes the documentation tree. Retain the corresponding validator + contract changes in request_validator.py. +- Add defensive tests for mismatched and missing client identifiers in + both affected grants, and absent/matching/mismatching identifiers in + the confidential and public authentication helpers. + +Signed-off-by: Hetvi Thakar +--- + .../rfc6749/grant_types/authorization_code.py | 7 --- + oauthlib/oauth2/rfc6749/grant_types/base.py | 60 ++++++++++++++++------ + .../rfc6749/grant_types/client_credentials.py | 11 +--- + .../oauth2/rfc6749/grant_types/refresh_token.py | 10 +--- + .../resource_owner_password_credentials.py | 10 +--- + oauthlib/oauth2/rfc6749/request_validator.py | 14 ++--- + oauthlib/oauth2/rfc8628/grant_types/device_code.py | 6 --- + .../rfc6749/endpoints/test_error_responses.py | 2 +- + .../rfc6749/endpoints/test_scope_handling.py | 4 +- + .../rfc6749/grant_types/test_authorization_code.py | 32 +++++++++++- + .../grant_types/test_client_authentication.py | 44 ++++++++++++++++ + .../rfc6749/grant_types/test_client_credentials.py | 26 ++++++++++ + .../rfc6749/grant_types/test_refresh_token.py | 11 ++++ + .../grant_types/test_resource_owner_password.py | 25 +++++++++ + tests/oauth2/rfc6749/test_server.py | 4 +- + .../oauth2/rfc8628/grant_types/test_device_code.py | 2 + + .../connect/core/endpoints/test_claims_handling.py | 4 +- + .../connect/core/endpoints/test_refresh_token.py | 7 +++ + .../core/grant_types/test_authorization_code.py | 2 +- + 19 files changed, 212 insertions(+), 69 deletions(-) + +diff --git a/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py b/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py +index f2d6d27..1677939 100644 +--- a/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py ++++ b/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py +@@ -454,13 +454,6 @@ class AuthorizationCodeGrant(GrantTypeBase): + + self.validate_client_authentication(request) + +- if not hasattr(request.client, 'client_id'): +- raise NotImplementedError('Authenticate client must set the ' +- 'request.client.client_id attribute ' +- 'in authenticate_client.') +- +- request.client_id = request.client_id or request.client.client_id +- + # Ensure client is authorized use of this grant type + self.validate_grant_type(request) + +diff --git a/oauthlib/oauth2/rfc6749/grant_types/base.py b/oauthlib/oauth2/rfc6749/grant_types/base.py +index 0b69e54..a5e5f42 100644 +--- a/oauthlib/oauth2/rfc6749/grant_types/base.py ++++ b/oauthlib/oauth2/rfc6749/grant_types/base.py +@@ -175,26 +175,56 @@ class GrantTypeBase: + request.scopes, request.client, request): + raise errors.InvalidScopeError(request=request) + ++ def validate_client_confidential(self, request): ++ # If the client type is confidential or the client was issued client ++ # credentials (or assigned other authentication requirements), the ++ # client MUST authenticate with the authorization server as described ++ # in Section 3.2.1. ++ # https://tools.ietf.org/html/rfc6749#section-3.2.1 ++ log.debug('Authenticating confidential client, %r.', request) ++ if not self.request_validator.authenticate_client(request): ++ log.debug('Client authentication failed, %r.', request) ++ raise errors.InvalidClientError(request=request) ++ ++ if request.client is None or \ ++ not hasattr(request.client, 'client_id'): ++ raise NotImplementedError('Authenticate client must set the ' ++ 'request.client.client_id attribute ' ++ 'in authenticate_client.') ++ ++ if not request.client_id: ++ request.client_id = request.client.client_id ++ elif request.client_id != request.client.client_id: ++ raise errors.ServerError('Discrepency found between client identifier') ++ ++ def validate_client_public(self, request): ++ # REQUIRED, if the client is not authenticating with the ++ # authorization server as described in Section 3.2.1. ++ # https://tools.ietf.org/html/rfc6749#section-3.2.1 ++ log.debug('Authenticating public client, %r.', request) ++ if not self.request_validator.authenticate_client_id(request.client_id, request): ++ log.debug('Client authentication failed, %r.', request) ++ raise errors.InvalidClientError(request=request) ++ ++ if request.client is None or \ ++ not hasattr(request.client, 'client_id'): ++ raise NotImplementedError('Authenticate client must set the ' ++ 'request.client.client_id attribute ' ++ 'in authenticate_client.') ++ ++ if not request.client_id: ++ request.client_id = request.client.client_id ++ elif request.client_id != request.client.client_id: ++ raise errors.ServerError('Discrepency found between client identifier') ++ + def validate_client_authentication(self, request): + """Raise on failed client authentication.""" + # Handles confidential clients + if self.request_validator.client_authentication_required(request): +- # If the client type is confidential or the client was issued client +- # credentials (or assigned other authentication requirements), the +- # client MUST authenticate with the authorization server as described +- # in Section 3.2.1. +- # https://tools.ietf.org/html/rfc6749#section-3.2.1 +- if not self.request_validator.authenticate_client(request): +- log.debug('Client authentication failed, %r.', request) +- raise errors.InvalidClientError(request=request) +- ++ self.validate_client_confidential(request) + # Handles public clients +- elif not self.request_validator.authenticate_client_id(request.client_id, request): +- # REQUIRED, if the client is not authenticating with the +- # authorization server as described in Section 3.2.1. +- # https://tools.ietf.org/html/rfc6749#section-3.2.1 +- log.debug('Client authentication failed, %r.', request) +- raise errors.InvalidClientError(request=request) ++ else: ++ self.validate_client_public(request) + + def prepare_authorization_response(self, request, token, headers, body, status): + """Place token according to response mode. +diff --git a/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py b/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py +index 35c5440..d5a653a 100644 +--- a/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py ++++ b/oauthlib/oauth2/rfc6749/grant_types/client_credentials.py +@@ -103,18 +103,11 @@ class ClientCredentialsGrant(GrantTypeBase): + raise errors.InvalidRequestError(description='Duplicate %s parameter.' % param, + request=request) + +- log.debug('Authenticating client, %r.', request) +- if not self.request_validator.authenticate_client(request): +- log.debug('Client authentication failed, %r.', request) +- raise errors.InvalidClientError(request=request) +- elif not hasattr(request.client, 'client_id'): +- raise NotImplementedError('Authenticate client must set the ' +- 'request.client.client_id attribute ' +- 'in authenticate_client.') ++ self.validate_client_confidential(request) ++ + # Ensure client is authorized use of this grant type + self.validate_grant_type(request) + +- request.client_id = request.client_id or request.client.client_id + log.debug('Authorizing access to client %r.', request.client_id) + self.validate_scopes(request) + +diff --git a/oauthlib/oauth2/rfc6749/grant_types/refresh_token.py b/oauthlib/oauth2/rfc6749/grant_types/refresh_token.py +index f626f0c..60ec06b 100644 +--- a/oauthlib/oauth2/rfc6749/grant_types/refresh_token.py ++++ b/oauthlib/oauth2/rfc6749/grant_types/refresh_token.py +@@ -91,17 +91,9 @@ class RefreshTokenGrant(GrantTypeBase): + + # Because refresh tokens are typically long-lasting credentials used to + # request additional access tokens, the refresh token is bound to the +- # client to which it was issued. If the client type is confidential or +- # the client was issued client credentials (or assigned other +- # authentication requirements), the client MUST authenticate with the +- # authorization server as described in Section 3.2.1. +- # https://tools.ietf.org/html/rfc6749#section-3.2.1 ++ # client to which it was issued + self.validate_client_authentication(request) + +- # Ensure that request.client_id is set. +- if request.client_id is None and request.client is not None: +- request.client_id = request.client.client_id +- + # Ensure client is authorized use of this grant type + self.validate_grant_type(request) + +diff --git a/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py b/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py +index 6fc67c6..c721328 100644 +--- a/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py ++++ b/oauthlib/oauth2/rfc6749/grant_types/resource_owner_password_credentials.py +@@ -85,7 +85,6 @@ class ResourceOwnerPasswordCredentialsGrant(GrantTypeBase): + """ + headers = self._get_default_headers() + try: +- self.validate_client_authentication(request) + log.debug('Validating access token request, %r.', request) + self.validate_token_request(request) + except errors.OAuth2Error as e: +@@ -168,23 +167,18 @@ class ResourceOwnerPasswordCredentialsGrant(GrantTypeBase): + if not request.grant_type == 'password': + raise errors.UnsupportedGrantTypeError(request=request) + ++ self.validate_client_authentication(request) ++ + log.debug('Validating username %s.', request.username) + if not self.request_validator.validate_user(request.username, + request.password, request.client, request): + raise errors.InvalidGrantError( + 'Invalid credentials given.', request=request) +- elif not hasattr(request.client, 'client_id'): +- raise NotImplementedError( +- 'Validate user must set the ' +- 'request.client.client_id attribute ' +- 'in authenticate_client.') + log.debug('Authorizing access to user %r.', request.user) + + # Ensure client is authorized use of this grant type + self.validate_grant_type(request) + +- if request.client: +- request.client_id = request.client_id or request.client.client_id + self.validate_scopes(request) + + for validator in self.custom_validators.post_token: +diff --git a/oauthlib/oauth2/rfc6749/request_validator.py b/oauthlib/oauth2/rfc6749/request_validator.py +index 6d6ebaa..ce0dc98 100644 +--- a/oauthlib/oauth2/rfc6749/request_validator.py ++++ b/oauthlib/oauth2/rfc6749/request_validator.py +@@ -80,9 +80,10 @@ class RequestValidator: + A non-confidential client is one that is not required to authenticate + through other means, such as using HTTP Basic. + +- Note, while not strictly necessary it can often be very convenient +- to set request.client to the client object associated with the +- given client_id. ++ After the client identification succeeds, this method needs to set the ++ client on the request, i.e. request.client = client. A client object's ++ class must contain the 'client_id' attribute and the 'client_id' must have ++ a value. + + :param client_id: Unicode client identifier. + :param request: OAuthlib request. +@@ -419,9 +420,10 @@ class RequestValidator: + def validate_client_id(self, client_id, request, *args, **kwargs): + """Ensure client_id belong to a valid and active client. + +- Note, while not strictly necessary it can often be very convenient +- to set request.client to the client object associated with the +- given client_id. ++ After the client identification succeeds, this method needs to set the ++ client on the request, i.e. request.client = client. A client object's ++ class must contain the 'client_id' attribute and the 'client_id' must have ++ a value. + + :param client_id: Unicode client identifier. + :param request: OAuthlib request. +diff --git a/oauthlib/oauth2/rfc8628/grant_types/device_code.py b/oauthlib/oauth2/rfc8628/grant_types/device_code.py +index 9d23d45..41ee09e 100644 +--- a/oauthlib/oauth2/rfc8628/grant_types/device_code.py ++++ b/oauthlib/oauth2/rfc8628/grant_types/device_code.py +@@ -57,15 +57,9 @@ class DeviceCodeGrant(GrantTypeBase): + + self.validate_client_authentication(request) + +- if not hasattr(request.client, 'client_id'): +- raise NotImplementedError('Authenticate client must set the ' +- 'request.client.client_id attribute ' +- 'in authenticate_client.') +- + # Ensure client is authorized use of this grant type + self.validate_grant_type(request) + +- request.client_id = request.client_id or request.client.client_id + self.validate_scopes(request) + + for validator in self.custom_validators.post_token: +diff --git a/tests/oauth2/rfc6749/endpoints/test_error_responses.py b/tests/oauth2/rfc6749/endpoints/test_error_responses.py +index f61595e..5b9a929 100644 +--- a/tests/oauth2/rfc6749/endpoints/test_error_responses.py ++++ b/tests/oauth2/rfc6749/endpoints/test_error_responses.py +@@ -400,7 +400,7 @@ class ErrorResponseTest(TestCase): + self.assertEqual('invalid_client', json.loads(body)['error']) + + # Client credentials grant +- _, body, _ = self.legacy.create_token_response('https://i.b/token', ++ _, body, _ = self.backend.create_token_response('https://i.b/token', + body='grant_type=client_credentials') + self.assertEqual('invalid_client', json.loads(body)['error']) + +diff --git a/tests/oauth2/rfc6749/endpoints/test_scope_handling.py b/tests/oauth2/rfc6749/endpoints/test_scope_handling.py +index 4c87d9c..6de7641 100644 +--- a/tests/oauth2/rfc6749/endpoints/test_scope_handling.py ++++ b/tests/oauth2/rfc6749/endpoints/test_scope_handling.py +@@ -30,12 +30,12 @@ class TestScopeHandling(TestCase): + request.user = 'foo' + request.client_id = 'bar' + request.client = mock.MagicMock() +- request.client.client_id = 'mocked' ++ request.client.client_id = request.client_id + return True + + def set_client(self, request): + request.client = mock.MagicMock() +- request.client.client_id = 'mocked' ++ request.client.client_id = request.client_id + return True + + def setUp(self): +diff --git a/tests/oauth2/rfc6749/grant_types/test_authorization_code.py b/tests/oauth2/rfc6749/grant_types/test_authorization_code.py +index 77e1a81..1448646 100644 +--- a/tests/oauth2/rfc6749/grant_types/test_authorization_code.py ++++ b/tests/oauth2/rfc6749/grant_types/test_authorization_code.py +@@ -34,7 +34,7 @@ class AuthorizationCodeGrantTest(TestCase): + + def set_client(self, request): + request.client = mock.MagicMock() +- request.client.client_id = 'mocked' ++ request.client.client_id = request.client_id + return True + + def setup_validators(self): +@@ -198,6 +198,36 @@ class AuthorizationCodeGrantTest(TestCase): + self.assertRaises(errors.InvalidClientError, + self.auth.validate_token_request, self.request) + ++ def test_client_id_discrepancy(self): ++ """ServerError raised when authenticate_client sets a different client_id.""" ++ def set_mismatched_client(request): ++ request.client = mock.MagicMock() ++ request.client.client_id = 'different_from_abcdef' ++ return True ++ self.mock_validator.authenticate_client.side_effect = set_mismatched_client ++ self.assertRaises(errors.ServerError, ++ self.auth.validate_token_request, self.request) ++ ++ def test_public_client_id_missing(self): ++ """NotImplementedError raised when authenticate_client_id does not set request.client.""" ++ self.mock_validator.client_authentication_required.return_value = False ++ self.mock_validator.authenticate_client_id.return_value = True ++ self.request.client = mock.MagicMock() ++ del self.request.client.client_id ++ self.assertRaises(NotImplementedError, ++ self.auth.validate_token_request, self.request) ++ ++ def test_public_client_id_discrepancy(self): ++ """ServerError raised when authenticate_client_id sets a different client_id.""" ++ def set_mismatched_client(client_id, request): ++ request.client = mock.MagicMock() ++ request.client.client_id = 'different_from_abcdef' ++ return True ++ self.mock_validator.client_authentication_required.return_value = False ++ self.mock_validator.authenticate_client_id.side_effect = set_mismatched_client ++ self.assertRaises(errors.ServerError, ++ self.auth.validate_token_request, self.request) ++ + def test_invalid_redirect_uri(self): + self.mock_validator.confirm_redirect_uri.return_value = False + self.assertRaises(errors.MismatchingRedirectURIError, +diff --git a/tests/oauth2/rfc6749/grant_types/test_client_authentication.py b/tests/oauth2/rfc6749/grant_types/test_client_authentication.py +new file mode 100644 +index 0000000..3481cba +--- /dev/null ++++ b/tests/oauth2/rfc6749/grant_types/test_client_authentication.py +@@ -0,0 +1,44 @@ ++from types import SimpleNamespace ++from unittest import mock ++ ++from oauthlib.common import Request ++from oauthlib.oauth2.rfc6749 import errors ++from oauthlib.oauth2.rfc6749.grant_types.base import GrantTypeBase ++ ++from tests.unittest import TestCase ++ ++ ++class ClientAuthenticationIdentityTest(TestCase): ++ ++ def authenticate(self, method, client_id): ++ request = Request('https://example.test/token') ++ request.client_id = client_id ++ validator = mock.Mock() ++ ++ def attach_client(*args): ++ request.client = SimpleNamespace(client_id='test-client') ++ return True ++ ++ validator.authenticate_client.side_effect = attach_client ++ validator.authenticate_client_id.side_effect = attach_client ++ grant = GrantTypeBase(validator) ++ getattr(grant, method)(request) ++ return request, validator ++ ++ def test_missing_identifier_is_set_from_authenticated_client(self): ++ for method in ('validate_client_confidential', 'validate_client_public'): ++ with self.subTest(method=method): ++ request, _ = self.authenticate(method, None) ++ self.assertEqual(request.client_id, request.client.client_id) ++ ++ def test_matching_identifier_is_preserved(self): ++ for method in ('validate_client_confidential', 'validate_client_public'): ++ with self.subTest(method=method): ++ request, _ = self.authenticate(method, 'test-client') ++ self.assertEqual(request.client_id, 'test-client') ++ ++ def test_mismatched_identifier_is_rejected(self): ++ for method in ('validate_client_confidential', 'validate_client_public'): ++ with self.subTest(method=method): ++ with self.assertRaises(errors.ServerError): ++ self.authenticate(method, 'different-client') +diff --git a/tests/oauth2/rfc6749/grant_types/test_client_credentials.py b/tests/oauth2/rfc6749/grant_types/test_client_credentials.py +index e9559c7..10afd4f 100644 +--- a/tests/oauth2/rfc6749/grant_types/test_client_credentials.py ++++ b/tests/oauth2/rfc6749/grant_types/test_client_credentials.py +@@ -3,6 +3,7 @@ import json + from unittest import mock + + from oauthlib.common import Request ++from oauthlib.oauth2.rfc6749 import errors + from oauthlib.oauth2.rfc6749.grant_types import ClientCredentialsGrant + from oauthlib.oauth2.rfc6749.tokens import BearerToken + +@@ -74,3 +75,28 @@ class ClientCredentialsGrantTest(TestCase): + def test_validate_token_response(self): + # wrong grant type, scope + pass ++ ++ def test_client_identifier_mismatch_rejected_before_authorization(self): ++ self.request.client = mock.Mock(client_id='authenticated-client') ++ self.request.client_id = 'different-client' ++ self.mock_validator.authenticate_client.return_value = True ++ ++ with self.assertRaises(errors.ServerError): ++ self.auth.validate_token_request(self.request) ++ ++ self.mock_validator.validate_grant_type.assert_not_called() ++ self.mock_validator.validate_scopes.assert_not_called() ++ ++ def test_missing_client_identifier_set_before_authorization(self): ++ self.request.client = mock.Mock(client_id='authenticated-client') ++ self.request.client_id = None ++ self.mock_validator.authenticate_client.return_value = True ++ ++ self.auth.validate_token_request(self.request) ++ ++ self.mock_validator.validate_grant_type.assert_called_once_with( ++ 'authenticated-client', 'client_credentials', ++ self.request.client, self.request) ++ self.mock_validator.validate_scopes.assert_called_once_with( ++ 'authenticated-client', self.request.scopes, ++ self.request.client, self.request) +diff --git a/tests/oauth2/rfc6749/grant_types/test_refresh_token.py b/tests/oauth2/rfc6749/grant_types/test_refresh_token.py +index f963444..efa156a 100644 +--- a/tests/oauth2/rfc6749/grant_types/test_refresh_token.py ++++ b/tests/oauth2/rfc6749/grant_types/test_refresh_token.py +@@ -15,6 +15,7 @@ class RefreshTokenGrantTest(TestCase): + def setUp(self): + mock_client = mock.MagicMock() + mock_client.user.return_value = 'mocked user' ++ mock_client.client_id = 'abcdef' + self.request = Request('http://a.b/path') + self.request.grant_type = 'refresh_token' + self.request.refresh_token = 'lsdkfhj230' +@@ -146,6 +147,16 @@ class RefreshTokenGrantTest(TestCase): + self.auth.validate_token_request(self.request) + self.request.client_id = 'foobar' + ++ def test_client_id_discrepancy(self): ++ """ServerError raised when authenticate_client sets a different client_id.""" ++ def set_mismatched_client(request): ++ request.client = mock.MagicMock() ++ request.client.client_id = 'different_from_abcdef' ++ return True ++ self.mock_validator.authenticate_client.side_effect = set_mismatched_client ++ self.assertRaises(errors.ServerError, ++ self.auth.validate_token_request, self.request) ++ + def test_invalid_grant_type(self): + self.request.grant_type = 'wrong_type' + self.assertRaises(errors.UnsupportedGrantTypeError, +diff --git a/tests/oauth2/rfc6749/grant_types/test_resource_owner_password.py b/tests/oauth2/rfc6749/grant_types/test_resource_owner_password.py +index 294e27b..49fbb26 100644 +--- a/tests/oauth2/rfc6749/grant_types/test_resource_owner_password.py ++++ b/tests/oauth2/rfc6749/grant_types/test_resource_owner_password.py +@@ -32,6 +32,31 @@ class ResourceOwnerPasswordCredentialsGrantTest(TestCase): + request.client.client_id = 'mocked' + return True + ++ def test_client_identifier_mismatch_rejected_before_authorization(self): ++ self.request.client = mock.Mock(client_id='authenticated-client') ++ self.request.client_id = 'different-client' ++ self.mock_validator.authenticate_client.return_value = True ++ ++ with self.assertRaises(errors.ServerError): ++ self.auth.validate_token_request(self.request) ++ ++ self.mock_validator.validate_grant_type.assert_not_called() ++ self.mock_validator.validate_scopes.assert_not_called() ++ ++ def test_missing_client_identifier_set_before_authorization(self): ++ self.request.client = mock.Mock(client_id='authenticated-client') ++ self.request.client_id = None ++ self.mock_validator.authenticate_client.return_value = True ++ ++ self.auth.validate_token_request(self.request) ++ ++ self.mock_validator.validate_grant_type.assert_called_once_with( ++ 'authenticated-client', 'password', ++ self.request.client, self.request) ++ self.mock_validator.validate_scopes.assert_called_once_with( ++ 'authenticated-client', self.request.scopes, ++ self.request.client, self.request) ++ + def test_create_token_response(self): + bearer = BearerToken(self.mock_validator) + headers, body, status_code = self.auth.create_token_response( +diff --git a/tests/oauth2/rfc6749/test_server.py b/tests/oauth2/rfc6749/test_server.py +index 94af37e..1bfd3e7 100644 +--- a/tests/oauth2/rfc6749/test_server.py ++++ b/tests/oauth2/rfc6749/test_server.py +@@ -112,7 +112,7 @@ class TokenEndpointTest(TestCase): + def set_user(request): + request.user = mock.MagicMock() + request.client = mock.MagicMock() +- request.client.client_id = 'mocked_client_id' ++ request.client.client_id = request.client_id + return True + + self.mock_validator = mock.MagicMock() +@@ -219,7 +219,7 @@ class SignedTokenEndpointTest(TestCase): + def set_user(request): + request.user = mock.MagicMock() + request.client = mock.MagicMock() +- request.client.client_id = 'mocked_client_id' ++ request.client.client_id = request.client_id + return True + + self.mock_validator = mock.MagicMock() +diff --git a/tests/oauth2/rfc8628/grant_types/test_device_code.py b/tests/oauth2/rfc8628/grant_types/test_device_code.py +index 10b5dd6..3e3c002 100644 +--- a/tests/oauth2/rfc8628/grant_types/test_device_code.py ++++ b/tests/oauth2/rfc8628/grant_types/test_device_code.py +@@ -53,6 +53,7 @@ def test_custom_pre_and_post_token_validators(): + + request: common.Request = create_request() + request.client = client ++ client.client_id = request.client_id + + auth = DeviceCodeGrant(validator) + +@@ -70,6 +71,7 @@ def test_create_token_response(): + validator = mock.MagicMock() + request: common.Request = create_request() + request.client = mock.Mock() ++ request.client.client_id = request.client_id + + auth = DeviceCodeGrant(validator) + +diff --git a/tests/openid/connect/core/endpoints/test_claims_handling.py b/tests/openid/connect/core/endpoints/test_claims_handling.py +index bc70269..d47affd 100644 +--- a/tests/openid/connect/core/endpoints/test_claims_handling.py ++++ b/tests/openid/connect/core/endpoints/test_claims_handling.py +@@ -29,12 +29,12 @@ class TestClaimsHandling(TestCase): + request.user = 'foo' + request.client_id = 'bar' + request.client = mock.MagicMock() +- request.client.client_id = 'mocked' ++ request.client.client_id = request.client_id + return True + + def set_client(self, request): + request.client = mock.MagicMock() +- request.client.client_id = 'mocked' ++ request.client.client_id = request.client_id + return True + + def save_claims_with_code(self, client_id, code, request, *args, **kwargs): +diff --git a/tests/openid/connect/core/endpoints/test_refresh_token.py b/tests/openid/connect/core/endpoints/test_refresh_token.py +index 9161f5a..b083097 100644 +--- a/tests/openid/connect/core/endpoints/test_refresh_token.py ++++ b/tests/openid/connect/core/endpoints/test_refresh_token.py +@@ -19,6 +19,13 @@ class TestRefreshToken(TestCase): + self.validator = mock.MagicMock(spec=RequestValidator) + self.validator.get_id_token.return_value='id_token' + ++ def set_client(request): ++ request.client = mock.MagicMock() ++ request.client.client_id = request.client_id ++ return True ++ ++ self.validator.authenticate_client.side_effect = set_client ++ + self.server = Server(self.validator) + + def test_refresh_token_with_openid(self): +diff --git a/tests/openid/connect/core/grant_types/test_authorization_code.py b/tests/openid/connect/core/grant_types/test_authorization_code.py +index f19b5fa..b453d9d 100644 +--- a/tests/openid/connect/core/grant_types/test_authorization_code.py ++++ b/tests/openid/connect/core/grant_types/test_authorization_code.py +@@ -54,7 +54,7 @@ class OpenIDAuthCodeTest(TestCase): + + def set_client(self, request): + request.client = mock.MagicMock() +- request.client.client_id = 'mocked' ++ request.client.client_id = request.client_id + return True + + @mock.patch('oauthlib.common.generate_token') diff --git a/meta-python/recipes-devtools/python/python3-oauthlib_3.3.1.bb b/meta-python/recipes-devtools/python/python3-oauthlib_3.3.1.bb index ffb07fef30..d41eeff279 100644 --- a/meta-python/recipes-devtools/python/python3-oauthlib_3.3.1.bb +++ b/meta-python/recipes-devtools/python/python3-oauthlib_3.3.1.bb @@ -9,6 +9,8 @@ SRC_URI += " \ file://CVE-2026-49265_p2.patch \ file://CVE-2026-49264_p1.patch \ file://CVE-2026-49264_p2.patch \ + file://CVE-2026-118669-dependent.patch \ + file://CVE-2026-118669.patch \ " SRC_URI[sha256sum] = "0f0f8aa759826a193cf66c12ea1af1637f87b9b4622d46e866952bb022e538c9" From patchwork Fri Nov 20 03:46:18 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)" X-Patchwork-Id: 105017 Received: from aer-iport-4.cisco.com (aer-iport-4.cisco.com [173.38.203.54]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.4790.1795146382277774793 for ; Thu, 19 Nov 2026 19:46:24 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: message contains an insecure body length tag" header.i=@cisco.com header.s=iport01 header.b=NMeqN0Tb; spf=pass (domain: cisco.com, ip: 173.38.203.54, mailfrom: hthakar@cisco.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=48682; q=dns/txt; s=iport01; t=1795146383; x=1796355983; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=t0F7iunS9ZXAIvswDGZ1WUUeQKiTOOLDHPt7SkyeFpw=; b=NMeqN0TbpkN0YNUxiAq0WHU8ICNuNXimn7nn+gFIAlBwwbxEE4lhCmz2 O9MWX6SzZz7uTa6HJJYMksyLrfHQaly4oKezCbT0/OrFJxqbrRekHHFVA 8JnD/mAqCV3dmrbymjxXXbHqyq/gqxlFoVzre9cMPF37Jxk0Ac10yjD0i /cesemZQt/8NDOLwk75C0jzpdTBbg9Vo47tI3kef6gHt1qfdwYng6Fdaq 00TlL/k4D7+y9euVMKF6jSguSFiQrxPwy2W6rLMdmab5nZajyCI1Di1Sa SCVxJNybfc9liZszE6xrg9uGs3TXAdsKNYcxYZFbUnzEQKUPnoehgEnT+ Q==; X-CSE-ConnectionGUID: fR7e+Yo+TiWulmnK5+IfLw== X-CSE-MsgGUID: bGaBhs7XR0KWNOvPhhzAiQ== X-IPAS-Result: A0BLAgBEwP9q/9NK/pBQCoJZgld1YENJlCqCIQOBE5A9jFmBfg8BAQEPRA0EAQGEP0YCjiECJjQJDgECBAMCAwEBAQEBAQEBAQEBAQoBAQUBAQECAQcFgQ4Thk8NkBIBAgEDGgEMCwEYARsiHAMBAi8rIwgZgwIBgnQDEbk8gXkzgQGDKQE/AkNQ2zMBCxQBgTiFQogkXRgBhH0nGxuBcoEVgnR2gQWBXAEBAgGBMBWGXgSCDRWBDIFUgQIJgheJdQKBT4gmSIEeA1ksAVUTDQoLBwWBaAM1EioVbjIdgSM7F4EHGwYFgRyBHoESgQNdgSsoXiGBCIF2AoJRggACAUlBDgdFUwklQxJHJCIIEgkBExosCoEaNTwJJj8VDGcLGgVhCAINDHQ5EDAeJC8FGiY+GwqBDCcfHhsOAh8QBg0YDUgRLDcVGQQ+bgeTbIIoJBUBARYOEgEuMhMHEwEHAx8BAQQTCQEILSkbBhQZDSkBLgkNAgYWFJJDCQgKCwGSPYE1nh6BPgoog3mMJJU6GjOBBoJ+gVeSQ5JUC5h9iyeCY5U1AioICw0BAhY3hGqBaDyBRwsHcBU7gmcJShkPji4LC4NggX+DFFHIdyYyAgEIMgEBBwIHDgMLgWiQAi1vA10BAQ IronPort-Data: A9a23:zFF2u6iFZ5pAFt+Lz7SiMdjMX161NBEKZh0ujC45NGQN5FlHY01je htvXTrSbKqMMTfyedokOY62904A75bdn9IyGQQ9pSAzEHhjpJueD7x1DKtf0wB+jyHnZBg6h ynLQoCYdKjYdleF+FHwdOCn/SMhvU2xbuKUIPbePSxsThNTRi4kiBZy88Y0mYcAbeKRW2thg vus5ZeAULOZ82QsaDxNsvjb8EwHUMna4Vv0gHRvPZing3eG/5UlJMp3Db28KXL+Xr5VEoaSL 87fzKu093/u5BwkDNWoiN7TKiXmlZaLYGBiIlIPM0STqkAqSh4ai87XB9JAAatjsAhlqvgqo Dl7WTNcfi9yVkHEsLx1vxC1iEiSN4UekFPMCSDXXcB+UyQqflO0q8iCAn3aMqUWwLl6QlBJt sAZFy0Jaxag2qGXzpakH7wEasQLdKEHPasWt2slyXTSCuwrBMmbBa7L/tRfmjw3g6iiH96HO 5ZfM2czKkucJUcWYz/7C7pm9AusrnnjczRboUi9rqss6G+Vxwt0uFToGISPI4TSFJgP9qqej mjp9k75GU4qDoS89hyi7Eqshv3mnBquDer+E5X9rJaGmma7wXQeDhATX1a3rfS1z0KzRd9bA 0gV4TY1668q+UqmS9PwUxG1rDiDpBF0ZjZLO+Q38kSJj6HT+QvcXzBCRT9aY9tgv8gzLdA36 mK0cxrSLWQHmNWopbi1r994cRva1fApEFI/ IronPort-HdrOrdr: A9a23:3Cwwb6HJIR/BhPmspLqExMeALOsnbusQ8zAXPidKOHhom6Oj+f xG8M536fawskdzZJhCo6HkBED/exLhHPdOiOF7V4tKHjOW2ldAR7sM0WKN+VHd8lXFltJ15O NHb7V0DsH2ABxRiMb35xT9LvMbqeP3l5xBQYzlvg5QpcYAUdAH0ztE X-Talos-CUID: 9a23:/YX9cGAENLf4GvT6Eyddq0NXK8dmTnzi0XPVJWzlSkdnbKLAHA== X-Talos-MUID: 9a23:tru55AtJIEHmf9vbAM2njh5rHsdzvJSUUGMyt7IYg8mEJwVxAmLI X-IronPort-Anti-Spam-Filtered: true X-IronPort-AV: E=Sophos;i="6.27,222,1787011200"; d="scan'208";a="62100952" Received: from aer-l-core-10.cisco.com ([144.254.74.211]) by aer-iport-4.cisco.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 20 Nov 2026 03:46:20 +0000 Received: from sjc-ads-5245.cisco.com (sjc-ads-5245.cisco.com [10.28.23.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aer-l-core-10.cisco.com (Postfix) with ESMTPS id 9B4C9180001EF for ; Fri, 20 Nov 2026 03:46:19 +0000 (GMT) Received: by sjc-ads-5245.cisco.com (Postfix, from userid 1887505) id 4C431CBF203; Thu, 19 Nov 2026 19:46:18 -0800 (PST) From: "Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)" To: openembedded-devel@lists.openembedded.org Subject: [meta-python][wrynose][PATCH 4/4] python3-oauthlib: fix CVE-2026-49272 Date: Thu, 19 Nov 2026 19:46:18 -0800 Message-Id: <20261120034618.604880-4-hthakar@cisco.com> X-Mailer: git-send-email 2.35.6 In-Reply-To: <20261120034618.604880-1-hthakar@cisco.com> References: <20261120034618.604880-1-hthakar@cisco.com> MIME-Version: 1.0 X-Outbound-Client-TLS: ANONYMOUS;sjc-ads-5245.cisco.com [10.28.23.9];TLSv1.3;TLS_AES_256_GCM_SHA384;256 X-Outbound-SMTP-Client: 10.28.23.9, sjc-ads-5245.cisco.com X-Outbound-Node: aer-l-core-10.cisco.com List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Fri, 20 Nov 2026 03:46:25 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-devel/message/132759 From: Hetvi Thakar The RFC 8628 token endpoint can issue a bearer token for a missing or bogus device_code when the configured client validator accepts the request, without checking the device authorization state. Backport upstream fix [1], referenced by NVD [2], to OAuthLib 3.3.1. Require the provider's validate_device_code hook to verify client ownership and authorization state before a token can be issued. Include upstream scope follow-up [3] to ignore client-supplied scopes and require scopes from the stored authorization. Add a local adjustment to preserve an approved empty scope list instead of expanding it to client defaults, a remaining upstream gap reproduced on 3.3.1. Keep the validator's scope-policy check and test missing, empty and denied approved scopes. Retain the upstream device-flow regressions. Omit docs/oauth2/endpoints/device.rst because the 3.3.1 source archive excludes the documentation tree. [1] https://github.com/oauthlib/oauthlib/commit/77a5f1c8ce00da2b0b8c5f6e9cc129920085f114 [2] https://nvd.nist.gov/vuln/detail/CVE-2026-49272 [3] https://github.com/oauthlib/oauthlib/commit/5edac41fb1164485582f4bc4d2abd9c50eb6df47 Signed-off-by: Hetvi Thakar --- .../python3-oauthlib/CVE-2026-49272_p1.patch | 817 ++++++++++++++++++ .../python3-oauthlib/CVE-2026-49272_p2.patch | 263 ++++++ .../python/python3-oauthlib_3.3.1.bb | 2 + 3 files changed, 1082 insertions(+) create mode 100644 meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49272_p1.patch create mode 100644 meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49272_p2.patch diff --git a/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49272_p1.patch b/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49272_p1.patch new file mode 100644 index 0000000000..17d9d16731 --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49272_p1.patch @@ -0,0 +1,817 @@ +From 77a5f1c8ce00da2b0b8c5f6e9cc129920085f114 Mon Sep 17 00:00:00 2001 +From: Jonathan Huot +Date: Fri, 2 Oct 2026 00:30:11 +0200 +Subject: [PATCH] Merge pull request #954 from hekhuisk/improve-device-workflow + +Improve device workflow + +CVE: CVE-2026-49272 +Upstream-Status: Backport [https://github.com/oauthlib/oauthlib/commit/77a5f1c8ce00da2b0b8c5f6e9cc129920085f114] + +Backport Changes: +- Omit docs/oauth2/endpoints/device.rst because the 3.3.1 source archive + does not contain the documentation tree. Retain all production code, + regression tests and validator-contract documentation in Python files. + +Signed-off-by: Hetvi Thakar +--- + oauthlib/common.py | 1 + + oauthlib/oauth2/rfc6749/grant_types/base.py | 6 +- + .../rfc8628/endpoints/device_authorization.py | 56 ++----- + oauthlib/oauth2/rfc8628/grant_types/device_code.py | 136 ++++++++++++++++ + oauthlib/oauth2/rfc8628/request_validator.py | 38 +++++ + .../rfc8628/endpoints/test_error_responses.py | 80 ++++++---- + .../oauth2/rfc8628/grant_types/test_device_code.py | 175 ++++++++++++++++++++- + tests/oauth2/rfc8628/test_server.py | 43 ++++- + 8 files changed, 455 insertions(+), 80 deletions(-) + +diff --git a/oauthlib/common.py b/oauthlib/common.py +index dfa851798828b24f54e767a7f61a2180cd59b48c..641a0e228105aab0acbc8dd85bcf9017a1ccd45d 100644 +--- a/oauthlib/common.py ++++ b/oauthlib/common.py +@@ -366,6 +366,7 @@ class Request: + "code_challenge": None, + "code_challenge_method": None, + "code_verifier": None, ++ "device_code": None, + "extra_credentials": None, + "grant_type": None, + "redirect_uri": None, +diff --git a/oauthlib/oauth2/rfc6749/grant_types/base.py b/oauthlib/oauth2/rfc6749/grant_types/base.py +index a5e5f426a9c44e1539716e734ea8bda6f035d435..a108bf685ebe514e98c0fccb8b1750e9849d704c 100644 +--- a/oauthlib/oauth2/rfc6749/grant_types/base.py ++++ b/oauthlib/oauth2/rfc6749/grant_types/base.py +@@ -208,9 +208,9 @@ class GrantTypeBase: + + if request.client is None or \ + not hasattr(request.client, 'client_id'): +- raise NotImplementedError('Authenticate client must set the ' +- 'request.client.client_id attribute ' +- 'in authenticate_client.') ++ raise NotImplementedError('authenticate_client_id must set the ' ++ 'request.client attribute to a client ' ++ 'object with a client_id attribute.') + + if not request.client_id: + request.client_id = request.client.client_id +diff --git a/oauthlib/oauth2/rfc8628/endpoints/device_authorization.py b/oauthlib/oauth2/rfc8628/endpoints/device_authorization.py +index 3f38a540590a9d38d42e3d84a79f6acfe440cac7..81f2fe8539ec369cd401f91d16f55ee4a252baa3 100644 +--- a/oauthlib/oauth2/rfc8628/endpoints/device_authorization.py ++++ b/oauthlib/oauth2/rfc8628/endpoints/device_authorization.py +@@ -10,11 +10,12 @@ import logging + from typing import Callable + + from oauthlib.common import Request, generate_token +-from oauthlib.oauth2.rfc6749 import errors ++from oauthlib.oauth2.rfc6749 import utils + from oauthlib.oauth2.rfc6749.endpoints.base import ( + BaseEndpoint, + catch_errors_and_unavailability, + ) ++from oauthlib.oauth2.rfc8628.grant_types import DeviceCodeGrant + + log = logging.getLogger(__name__) + +@@ -52,6 +53,7 @@ class DeviceAuthorizationEndpoint(BaseEndpoint): + :param user_code_generator: a callable that returns a configurable user code + """ + self.request_validator = request_validator ++ self.device_code_grant = DeviceCodeGrant(request_validator) + self._expires_in = expires_in + self._interval = interval + self._verification_uri = verification_uri +@@ -101,44 +103,7 @@ class DeviceAuthorizationEndpoint(BaseEndpoint): + .. _`Section 3.2.1. of [RFC6749]`: https://www.rfc-editor.org/rfc/rfc6749#section-3.2.1 + .. _`Section 2.2 of [RFC6749]`: https://www.rfc-editor.org/rfc/rfc6749#section-2.2 + """ +- +- # First check duplicate parameters +- for param in ("client_id", "scope"): +- try: +- duplicate_params = request.duplicate_params +- except ValueError: +- raise errors.InvalidRequestFatalError( +- description="Unable to parse query string", request=request +- ) +- if param in duplicate_params: +- raise errors.InvalidRequestFatalError( +- description="Duplicate %s parameter." % param, request=request +- ) +- +- # the "application/x-www-form-urlencoded" format, per Appendix B of [RFC6749] +- # https://www.rfc-editor.org/rfc/rfc6749#appendix-B +- if request.headers["Content-Type"] != "application/x-www-form-urlencoded": +- raise errors.InvalidRequestError( +- "Content-Type must be application/x-www-form-urlencoded", +- request=request, +- ) +- +- # REQUIRED. The client identifier as described in Section 2.2. +- # https://tools.ietf.org/html/rfc6749#section-2.2 +- # TODO: extract client_id an helper validation function. +- if not request.client_id: +- raise errors.MissingClientIdError(request=request) +- +- if not self.request_validator.validate_client_id(request.client_id, request): +- raise errors.InvalidClientIdError(request=request) +- +- # The client authentication requirements of Section 3.2.1 of [RFC6749] +- # apply to requests on this endpoint, which means that confidential +- # clients (those that have established client credentials) authenticate +- # in the same manner as when making requests to the token endpoint, and +- # public clients provide the "client_id" parameter to identify +- # themselves. +- self._raise_on_invalid_client(request) ++ self.device_code_grant.validate_device_authorization_request(request) + + @catch_errors_and_unavailability + def create_device_authorization_response( +@@ -189,6 +154,13 @@ class DeviceAuthorizationEndpoint(BaseEndpoint): + SHOULD wait between polling requests to the token endpoint. If no + value is provided, clients MUST use 5 as the default. + ++ scope ++ **OPTIONAL.** The space delimited scopes resolved for this request, ++ either the scopes the device asked for or the ones returned by ++ ``get_default_scopes``. Not defined by RFC 8628, it is included so ++ the caller can persist the authorized scopes with the device_code. ++ Omitted when no scopes were resolved. ++ + **For example:** + + .. code-block:: http +@@ -224,6 +196,12 @@ class DeviceAuthorizationEndpoint(BaseEndpoint): + if self.interval is not None: + data["interval"] = self.interval + ++ # ``validate_device_authorization_request`` resolves request.scopes, ++ # falling back to ``get_default_scopes`` when the device omitted the ++ # ``scope`` parameter. Echo the resolved value so callers can persist it ++ # alongside the device_code/user_code without re-running the validator. ++ if request.scopes: ++ data["scope"] = utils.list_to_scope(request.scopes) + + verification_uri_complete = self.verification_uri_complete(user_code) + if verification_uri_complete: +diff --git a/oauthlib/oauth2/rfc8628/grant_types/device_code.py b/oauthlib/oauth2/rfc8628/grant_types/device_code.py +index 41ee09e263af3bfe257daa68578d8f7da5cdf6d6..f17384854c66bc10978ef457d1a9b2427ce86641 100644 +--- a/oauthlib/oauth2/rfc8628/grant_types/device_code.py ++++ b/oauthlib/oauth2/rfc8628/grant_types/device_code.py +@@ -1,5 +1,6 @@ + from __future__ import annotations + import json ++import logging + + from typing import Callable + +@@ -7,9 +8,33 @@ from oauthlib import common # noqa: TC001 + + from oauthlib.oauth2.rfc6749 import errors as rfc6749_errors + from oauthlib.oauth2.rfc6749.grant_types.base import GrantTypeBase ++from oauthlib.oauth2.rfc8628 import errors as rfc8628_errors ++ ++log = logging.getLogger(__name__) + + + class DeviceCodeGrant(GrantTypeBase): ++ #: Maps a non-authorized device code status to the RFC 8628 Section 3.5 ++ #: error it raises. The status strings are the errors' own ``error`` codes, ++ #: keeping a single source of truth. ++ _device_code_errors = { ++ cls.error: cls ++ for cls in ( ++ rfc8628_errors.AuthorizationPendingError, ++ rfc8628_errors.SlowDownError, ++ rfc8628_errors.ExpiredTokenError, ++ rfc8628_errors.AccessDenied, ++ ) ++ } ++ ++ #: Authorization statuses returned by ++ #: :meth:`RequestValidator.validate_device_code`, per RFC 8628 Section 3.5. ++ DEVICE_CODE_AUTHORIZED = "authorized" ++ DEVICE_CODE_PENDING = rfc8628_errors.AuthorizationPendingError.error ++ DEVICE_CODE_SLOW_DOWN = rfc8628_errors.SlowDownError.error ++ DEVICE_CODE_EXPIRED = rfc8628_errors.ExpiredTokenError.error ++ DEVICE_CODE_DENIED = rfc8628_errors.AccessDenied.error ++ + def create_authorization_response( + self, request: common.Request, token_handler: Callable + ) -> tuple[dict, str, int]: +@@ -33,6 +58,61 @@ class DeviceCodeGrant(GrantTypeBase): + + return self.create_token_response(request, token_handler) + ++ def validate_device_authorization_request(self, request: common.Request) -> None: ++ """Validate the device authorization request. ++ ++ The client_id is required if the client is not authenticating with the ++ authorization server as described in `Section 3.2.1. of [RFC6749]`_. ++ The client identifier as described in `Section 2.2 of [RFC6749]`_. ++ ++ :param request: OAuthlib request. ++ :type request: oauthlib.common.Request ++ ++ .. _`Section 3.2.1. of [RFC6749]`: https://www.rfc-editor.org/rfc/rfc6749#section-3.2.1 ++ .. _`Section 2.2 of [RFC6749]`: https://www.rfc-editor.org/rfc/rfc6749#section-2.2 ++ """ ++ # First check duplicate parameters ++ for param in ("client_id", "scope"): ++ try: ++ duplicate_params = request.duplicate_params ++ except ValueError: ++ raise rfc6749_errors.InvalidRequestFatalError( ++ description="Unable to parse query string", request=request ++ ) ++ if param in duplicate_params: ++ raise rfc6749_errors.InvalidRequestFatalError( ++ description="Duplicate %s parameter." % param, request=request ++ ) ++ ++ # the "application/x-www-form-urlencoded" format, per Appendix B of [RFC6749] ++ # https://www.rfc-editor.org/rfc/rfc6749#appendix-B ++ content_type = request.headers.get("Content-Type", "") ++ content_type = content_type.split(";", 1)[0].strip().lower() ++ if content_type != "application/x-www-form-urlencoded": ++ raise rfc6749_errors.InvalidRequestError( ++ "Content-Type must be application/x-www-form-urlencoded", request=request ++ ) ++ ++ # REQUIRED. The client identifier as described in Section 2.2. ++ # https://tools.ietf.org/html/rfc6749#section-2.2 ++ if not request.client_id: ++ raise rfc6749_errors.MissingClientIdError(request=request) ++ ++ if not self.request_validator.validate_client_id(request.client_id, request): ++ raise rfc6749_errors.InvalidClientIdError(request=request) ++ ++ # The client authentication requirements of Section 3.2.1 of [RFC6749] ++ # apply to requests on this endpoint, which means that confidential ++ # clients (those that have established client credentials) authenticate ++ # in the same manner as when making requests to the token endpoint, and ++ # public clients provide the "client_id" parameter to identify ++ # themselves. ++ self.validate_client_authentication(request) ++ ++ # OPTIONAL. The scope of the access request as defined by Section 3.3 ++ # of [RFC6749]. https://www.rfc-editor.org/rfc/rfc8628#section-3.1 ++ self.validate_scopes(request) ++ + def validate_token_request(self, request: common.Request) -> None: + """ + Performs the necessary check against the request to ensure +@@ -60,11 +140,67 @@ class DeviceCodeGrant(GrantTypeBase): + # Ensure client is authorized use of this grant type + self.validate_grant_type(request) + ++ # Validate the device_code first: per RFC 8628 Section 3.4 the token ++ # request carries no scope, so the validator must populate ++ # request.user and request.scopes from the stored authorization before ++ # validate_scopes runs (otherwise it would fall back to default scopes). ++ self.validate_device_code(request) ++ + self.validate_scopes(request) + + for validator in self.custom_validators.post_token: + validator(request) + ++ def validate_device_code(self, request: common.Request) -> None: ++ """Validate the ``device_code`` and its authorization status. ++ ++ Delegates to :meth:`RequestValidator.validate_device_code`, which ++ returns one of the ``DEVICE_CODE_*`` statuses, and maps it to the ++ appropriate RFC 8628 Section 3.5 error. ++ ++ :param request: OAuthlib request. ++ :type request: oauthlib.common.Request ++ """ ++ if not request.device_code: ++ raise rfc6749_errors.InvalidRequestError( ++ "Missing device_code parameter.", request=request ++ ) ++ ++ status = self.request_validator.validate_device_code( ++ request.client_id, request.device_code, request ++ ) ++ if status == self.DEVICE_CODE_AUTHORIZED: ++ # The validator is expected to populate these from the stored ++ # authorization; if it did not, validate_scopes will silently fall ++ # back to the client's default scopes. ++ if getattr(request, "user", None) is None: ++ log.debug("request.user was not set on device_code validation.") ++ if getattr(request, "scopes", None) is None and request.scope is None: ++ raise rfc6749_errors.ServerError( ++ description="validate_device_code must set request.scopes for an authorized device_code.", ++ request=request, ++ ) ++ if getattr(request, "scopes", None) is None: ++ log.debug("request.scopes was not set on device_code validation.") ++ return ++ ++ # A recognized non-authorized status maps to its RFC 8628 polling ++ # error; anything else means the device_code is unknown or invalid. ++ error_class = self._device_code_errors.get(status) ++ if error_class is not None: ++ raise error_class(request=request) ++ ++ # None is the documented "unknown/invalid device_code" return. Any ++ # other unrecognized value most likely signals a validator that did ++ # not return a DEVICE_CODE_* status, so surface it for debugging. ++ if status is not None: ++ log.warning( ++ "validate_device_code returned unrecognized status %r; treating " ++ "the device_code as invalid. Return one of the " ++ "DeviceCodeGrant.DEVICE_CODE_* constants.", status ++ ) ++ raise rfc6749_errors.InvalidGrantError(request=request) ++ + def create_token_response( + self, request: common.Request, token_handler: Callable + ) -> tuple[dict, str, int]: +diff --git a/oauthlib/oauth2/rfc8628/request_validator.py b/oauthlib/oauth2/rfc8628/request_validator.py +index 70ee7824e92dae12b5b44d073f11c708ebd07577..1afacd291113f4ffd94568ec7fb6a6fcf420c9c3 100644 +--- a/oauthlib/oauth2/rfc8628/request_validator.py ++++ b/oauthlib/oauth2/rfc8628/request_validator.py +@@ -23,3 +23,41 @@ class RequestValidator(OAuth2RequestValidator): + .. _`Section 3.1`: https://www.rfc-editor.org/rfc/rfc8628#section-3.1 + """ + return True ++ ++ def validate_device_code(self, client_id, code, request, *args, **kwargs): ++ """Validate a ``device_code`` and return its authorization status. ++ ++ Called when a device polls the token endpoint. The implementation ++ should look up the ``device_code``, confirm it was issued to the ++ authenticating client, and report where it is in the authorization ++ process described in `Section 3.5`_ by returning one of the ++ ``DeviceCodeGrant`` status constants: ++ ++ - ``DEVICE_CODE_AUTHORIZED``: the end user approved the request. ++ The implementation should also set ``request.user`` (and any ++ scopes or claims to embed) so they end up on the issued token, ++ which removes the need for a separate token validator. ++ - ``DEVICE_CODE_PENDING``: the user has not yet completed the ++ interaction; raises ``AuthorizationPendingError``. ++ - ``DEVICE_CODE_SLOW_DOWN``: as pending, but the client is polling ++ too quickly; raises ``SlowDownError``. ++ - ``DEVICE_CODE_EXPIRED``: the ``device_code`` has expired; raises ++ ``ExpiredTokenError``. ++ - ``DEVICE_CODE_DENIED``: the user denied the request; raises ++ ``AccessDenied``. ++ ++ Returning ``None`` (or any unrecognized value) is treated as an ++ unknown or invalid ``device_code`` and raises ``InvalidGrantError``. ++ ++ :param client_id: Unicode client identifier. ++ :param code: Unicode device_code. ++ :param request: OAuthlib request. ++ :type request: oauthlib.common.Request ++ :rtype: str or None ++ ++ Method is used by: ++ - Device Code Grant ++ ++ .. _`Section 3.5`: https://www.rfc-editor.org/rfc/rfc8628#section-3.5 ++ """ ++ raise NotImplementedError("Subclasses must implement this method.") +diff --git a/tests/oauth2/rfc8628/endpoints/test_error_responses.py b/tests/oauth2/rfc8628/endpoints/test_error_responses.py +index c799cc81af295715d91351d3ac75cf0bb970a6e7..75f0ef06b8fdad07d5f490c7cc217b3d9bef7bd5 100644 +--- a/tests/oauth2/rfc8628/endpoints/test_error_responses.py ++++ b/tests/oauth2/rfc8628/endpoints/test_error_responses.py +@@ -8,15 +8,23 @@ from oauthlib.oauth2.rfc8628.request_validator import RequestValidator + + + class ErrorResponseTest(TestCase): +- def set_client(self, request): ++ def set_client(self, request, *args, **kwargs): ++ """Stand in for a validator that attaches the client, as documented.""" + request.client = mock.MagicMock() +- request.client.client_id = "mocked" ++ request.client.client_id = request.client_id + return True + +- def build_request(self, uri="https://example.com/device_authorize", client_id="foo"): +- body = "" +- if client_id: +- body = f"client_id={client_id}" ++ def set_client_id(self, client_id, request, *args, **kwargs): ++ return self.set_client(request) ++ ++ def build_request( ++ self, uri="https://example.com/device_authorize", client_id="foo", body=None ++ ): ++ # The body must be passed to the constructor: Request parses it once at ++ # initialization, so assigning to request.body afterwards would leave ++ # request.scope and request.duplicate_params stale. ++ if body is None: ++ body = f"client_id={client_id}" if client_id else "" + return Request( + uri, + http_method="POST", +@@ -24,26 +32,29 @@ class ErrorResponseTest(TestCase): + headers={"Content-Type": "application/x-www-form-urlencoded"}, + ) + +- def assert_request_raises(self, error, request): ++ def assert_request_raises(self, error, request, description=None): + """Test that the request fails similarly on the validation and response endpoint.""" +- self.assertRaises( +- error, +- self.device.validate_device_authorization_request, +- request, +- ) +- self.assertRaises( +- error, +- self.device.create_device_authorization_response, +- uri=request.uri, +- http_method=request.http_method, +- body=request.body, +- headers=request.headers, +- ) ++ with self.assertRaises(error) as caught: ++ self.device.validate_device_authorization_request(request) ++ if description is not None: ++ self.assertEqual(description, caught.exception.description) ++ ++ with self.assertRaises(error) as caught: ++ self.device.create_device_authorization_response( ++ uri=request.uri, ++ http_method=request.http_method, ++ body=request.body, ++ headers=request.headers, ++ ) ++ if description is not None: ++ self.assertEqual(description, caught.exception.description) + + def setUp(self): + self.validator = mock.MagicMock(spec=RequestValidator) + self.validator.get_default_redirect_uri.return_value = None + self.validator.get_code_challenge.return_value = None ++ self.validator.authenticate_client.side_effect = self.set_client ++ self.validator.authenticate_client_id.side_effect = self.set_client_id + self.device = DeviceApplicationServer(self.validator, "https://example.com/verify") + + def test_missing_client_id(self): +@@ -69,27 +80,40 @@ class ErrorResponseTest(TestCase): + self.assert_request_raises(errors.InvalidClientIdError, request) + + def test_duplicate_client_id(self): +- request = self.build_request() +- request.body = "client_id=foo&client_id=bar" ++ request = self.build_request(body="client_id=foo&client_id=bar") + # Device code grant +- self.validator.validate_client_id.return_value = False +- self.assert_request_raises(errors.InvalidRequestFatalError, request) ++ self.assert_request_raises( ++ errors.InvalidRequestFatalError, request, "Duplicate client_id parameter." ++ ) + + def test_unauthenticated_confidential_client(self): + self.validator.client_authentication_required.return_value = True ++ self.validator.authenticate_client.side_effect = None + self.validator.authenticate_client.return_value = False + request = self.build_request() + self.assert_request_raises(errors.InvalidClientError, request) + + def test_unauthenticated_public_client(self): + self.validator.client_authentication_required.return_value = False ++ self.validator.authenticate_client_id.side_effect = None + self.validator.authenticate_client_id.return_value = False + request = self.build_request() + self.assert_request_raises(errors.InvalidClientError, request) + + def test_duplicate_scope_parameter(self): +- request = self.build_request() +- request.body = "client_id=foo&scope=foo&scope=bar" ++ request = self.build_request(body="client_id=foo&scope=foo&scope=bar") + # Device code grant +- self.validator.validate_client_id.return_value = False +- self.assert_request_raises(errors.InvalidRequestFatalError, request) ++ self.assert_request_raises( ++ errors.InvalidRequestFatalError, request, "Duplicate scope parameter." ++ ) ++ ++ def test_invalid_scope(self): ++ request = self.build_request(body="client_id=foo&scope=foo") ++ ++ # Only reject the scope requested in the body, so that the test fails if ++ # the requested scope never reaches the validator. ++ def validate_scopes(client_id, scopes, client, request): ++ return scopes != ["foo"] ++ ++ self.validator.validate_scopes.side_effect = validate_scopes ++ self.assert_request_raises(errors.InvalidScopeError, request) +diff --git a/tests/oauth2/rfc8628/grant_types/test_device_code.py b/tests/oauth2/rfc8628/grant_types/test_device_code.py +index 3e3c002b4f30e6418bcb9d8bb456b76c12734b95..952cfe4c1aaf82b03e6e9bc92be1ac46711e557a 100644 +--- a/tests/oauth2/rfc8628/grant_types/test_device_code.py ++++ b/tests/oauth2/rfc8628/grant_types/test_device_code.py +@@ -5,18 +5,24 @@ import pytest + from oauthlib import common + + from oauthlib.oauth2.rfc8628.grant_types import DeviceCodeGrant ++from oauthlib.oauth2.rfc8628.request_validator import RequestValidator + from oauthlib.oauth2.rfc6749.tokens import BearerToken + + def create_request(body: str = "") -> common.Request: + request = common.Request("http://a.b/path", body=body or None) + request.scopes = ("hello", "world") + request.expires_in = 1800 +- request.client = "batman" + request.client_id = "abcdef" ++ # Client authentication must leave request.client set to an object whose ++ # client_id matches request.client_id, otherwise validate_client_confidential ++ # /validate_client_public raise before the grant's own checks run. ++ request.client = mock.Mock() ++ request.client.client_id = request.client_id + request.code = "1234" + request.response_type = "code" + request.grant_type = "urn:ietf:params:oauth:grant-type:device_code" + request.redirect_uri = "https://a.b/" ++ request.device_code = "device_code_1234" + return request + + +@@ -54,6 +60,7 @@ def test_custom_pre_and_post_token_validators(): + request: common.Request = create_request() + request.client = client + client.client_id = request.client_id ++ validator.validate_device_code.return_value = DeviceCodeGrant.DEVICE_CODE_AUTHORIZED + + auth = DeviceCodeGrant(validator) + +@@ -70,8 +77,7 @@ def test_custom_pre_and_post_token_validators(): + def test_create_token_response(): + validator = mock.MagicMock() + request: common.Request = create_request() +- request.client = mock.Mock() +- request.client.client_id = request.client_id ++ validator.validate_device_code.return_value = DeviceCodeGrant.DEVICE_CODE_AUTHORIZED + + auth = DeviceCodeGrant(validator) + +@@ -104,7 +110,6 @@ def test_create_token_response(): + def test_invalid_client_authentication_error_confidential_client(): + validator = mock.MagicMock() + request: common.Request = create_request() +- request.client = mock.Mock() + + auth = DeviceCodeGrant(validator) + bearer = BearerToken(validator) +@@ -131,7 +136,6 @@ def test_invalid_client_authentication_error_confidential_client(): + def test_invalid_client_authentication_error_public_client(): + validator = mock.MagicMock() + request: common.Request = create_request() +- request.client = mock.Mock() + + auth = DeviceCodeGrant(validator) + bearer = BearerToken(validator) +@@ -158,7 +162,6 @@ def test_invalid_client_authentication_error_public_client(): + def test_invalid_grant_type_error(): + validator = mock.MagicMock() + request: common.Request = create_request() +- request.client = mock.Mock() + + request.grant_type = "not_device_code" + +@@ -184,7 +187,6 @@ def test_duplicate_params_error(): + request: common.Request = create_request( + "client_id=123&scope=openid&scope=openid" + ) +- request.client = mock.Mock() + + auth = DeviceCodeGrant(validator) + bearer = BearerToken(validator) +@@ -201,3 +203,162 @@ def test_duplicate_params_error(): + assert status_code == 400 + + validator.save_token.assert_not_called() ++ ++ ++@pytest.mark.parametrize( ++ ("status", "expected_error"), ++ [ ++ (DeviceCodeGrant.DEVICE_CODE_PENDING, "authorization_pending"), ++ (DeviceCodeGrant.DEVICE_CODE_SLOW_DOWN, "slow_down"), ++ (DeviceCodeGrant.DEVICE_CODE_EXPIRED, "expired_token"), ++ (DeviceCodeGrant.DEVICE_CODE_DENIED, "access_denied"), ++ ], ++) ++def test_device_code_status_errors(status, expected_error): ++ validator = mock.MagicMock() ++ request: common.Request = create_request() ++ validator.validate_device_code.return_value = status ++ ++ auth = DeviceCodeGrant(validator) ++ bearer = BearerToken(validator) ++ ++ _headers, body, status_code = auth.create_token_response(request, bearer) ++ body = json.loads(body) ++ ++ assert body == {"error": expected_error} ++ assert status_code == 400 ++ ++ validator.validate_device_code.assert_called_once_with( ++ request.client_id, request.device_code, request ++ ) ++ validator.save_token.assert_not_called() ++ ++ ++@pytest.mark.parametrize( ++ "status", ++ [ ++ None, # documented "unknown / invalid device_code" return ++ "not_a_real_status", # validator returned an unrecognized value ++ True, # validator wrongly returned a bool instead of a status ++ ], ++) ++def test_invalid_device_code(status): ++ validator = mock.MagicMock() ++ request: common.Request = create_request() ++ validator.validate_device_code.return_value = status ++ ++ auth = DeviceCodeGrant(validator) ++ bearer = BearerToken(validator) ++ ++ _headers, body, status_code = auth.create_token_response(request, bearer) ++ body = json.loads(body) ++ ++ assert body == {"error": "invalid_grant"} ++ assert status_code == 400 ++ ++ validator.save_token.assert_not_called() ++ ++ ++def test_device_code_scopes_populated_before_scope_validation(): ++ """Authorized scopes from the stored grant must be validated, not defaults. ++ ++ Per RFC 8628 Section 3.4 the device token request carries no scope, so ++ validate_device_code must populate request.scopes from the stored ++ authorization before validate_scopes runs; otherwise validate_scopes falls ++ back to get_default_scopes and the token silently receives default scopes ++ (issue #944). ++ """ ++ validator = mock.MagicMock() ++ request: common.Request = create_request() ++ # The device token request has no scope of its own. ++ request.scope = None ++ request.scopes = None ++ ++ def authorize(client_id, code, req): ++ req.scopes = ["read", "write"] ++ return DeviceCodeGrant.DEVICE_CODE_AUTHORIZED ++ ++ validator.validate_device_code.side_effect = authorize ++ ++ auth = DeviceCodeGrant(validator) ++ bearer = BearerToken(validator) ++ auth.create_token_response(request, bearer) ++ ++ validator.get_default_scopes.assert_not_called() ++ validator.validate_scopes.assert_called_once_with( ++ "abcdef", ["read", "write"], request.client, request ++ ) ++ ++ ++def test_device_code_authorized_without_scopes_fails_loudly(): ++ """An authorized device_code must not silently fall back to default scopes. ++ ++ If ``validate_device_code`` returns ``DEVICE_CODE_AUTHORIZED`` without ++ populating ``request.scopes`` (and the token request itself carries no ++ ``scope``), failing loudly with a ``server_error`` is the only safe ++ option: continuing would let ``validate_scopes`` fall back to ++ ``get_default_scopes`` and reintroduce the consent-integrity bug from ++ issue #944. ++ """ ++ validator = mock.MagicMock() ++ request: common.Request = create_request() ++ # The device token request has no scope of its own, and the validator ++ # forgets to set request.scopes on the authorized device_code. ++ request.scope = None ++ request.scopes = None ++ validator.validate_device_code.return_value = DeviceCodeGrant.DEVICE_CODE_AUTHORIZED ++ ++ auth = DeviceCodeGrant(validator) ++ bearer = BearerToken(validator) ++ ++ _headers, body, status_code = auth.create_token_response(request, bearer) ++ body = json.loads(body) ++ ++ assert body == { ++ "error": "server_error", ++ "error_description": ( ++ "validate_device_code must set request.scopes for an " ++ "authorized device_code." ++ ), ++ } ++ assert status_code == 400 ++ ++ validator.get_default_scopes.assert_not_called() ++ validator.validate_scopes.assert_not_called() ++ validator.save_token.assert_not_called() ++ ++ ++def test_validate_device_code_is_required_on_real_validator(): ++ """The hook lives on the rfc8628 RequestValidator and must be implemented. ++ ++ Guards against the gap mocks hide: a MagicMock auto-creates ++ ``validate_device_code``, so the behavior tests above pass even if the ++ method did not exist. A real validator subclass that has not implemented ++ it must fail loudly rather than silently. ++ """ ++ request: common.Request = create_request() ++ with pytest.raises(NotImplementedError): ++ RequestValidator().validate_device_code( ++ request.client_id, request.device_code, request ++ ) ++ ++ ++def test_missing_device_code(): ++ validator = mock.MagicMock() ++ request: common.Request = create_request() ++ request.device_code = None ++ ++ auth = DeviceCodeGrant(validator) ++ bearer = BearerToken(validator) ++ ++ _headers, body, status_code = auth.create_token_response(request, bearer) ++ body = json.loads(body) ++ ++ assert body == { ++ "error": "invalid_request", ++ "error_description": "Missing device_code parameter.", ++ } ++ assert status_code == 400 ++ ++ validator.validate_device_code.assert_not_called() ++ validator.save_token.assert_not_called() +diff --git a/tests/oauth2/rfc8628/test_server.py b/tests/oauth2/rfc8628/test_server.py +index 52025032849ec5cee16c4e2778802958a1ed73ea..9592d9e1eeaa6208deb8fcf7479fe06f15d9a9da 100644 +--- a/tests/oauth2/rfc8628/test_server.py ++++ b/tests/oauth2/rfc8628/test_server.py +@@ -8,11 +8,30 @@ from tests.unittest import TestCase + + + class DeviceAuthorizationEndpointTest(TestCase): ++ def _set_client(self, request, *args, **kwargs): ++ """Stand in for a validator that attaches the client, as documented.""" ++ request.client = mock.MagicMock() ++ request.client.client_id = request.client_id ++ return True ++ ++ def _build_validator(self, scopes=None): ++ validator = mock.MagicMock(spec=RequestValidator) ++ validator.authenticate_client.side_effect = self._set_client ++ validator.authenticate_client_id.side_effect = ( ++ lambda client_id, request, *a, **kw: self._set_client(request) ++ ) ++ validator.get_default_scopes.return_value = scopes ++ return validator ++ + def _configure_endpoint( +- self, interval=None, verification_uri_complete=None, user_code_generator=None ++ self, ++ interval=None, ++ verification_uri_complete=None, ++ user_code_generator=None, ++ scopes=None, + ): + self.endpoint = DeviceAuthorizationEndpoint( +- request_validator=mock.MagicMock(spec=RequestValidator), ++ request_validator=self._build_validator(scopes), + verification_uri=self.verification_uri, + interval=interval, + verification_uri_complete=verification_uri_complete, +@@ -20,7 +39,6 @@ class DeviceAuthorizationEndpointTest(TestCase): + ) + + def setUp(self): +- self.request_validator = mock.MagicMock(spec=RequestValidator) + self.verification_uri = "http://i.b/l/verify" + self.uri = "http://i.b/l" + self.http_method = "POST" +@@ -46,6 +64,25 @@ class DeviceAuthorizationEndpointTest(TestCase): + self.assertEqual(200, status_code) + self.assertEqual(body, expected_payload) + ++ @mock.patch( ++ "oauthlib.oauth2.rfc8628.endpoints.device_authorization.generate_token", ++ lambda: "abc", ++ ) ++ def test_device_authorization_grant_echoes_requested_scope(self): ++ self.body = "client_id=abc&scope=read+write" ++ _, body, _ = self.endpoint.create_device_authorization_response(*self.response_payload()) ++ self.assertEqual("read write", body["scope"]) ++ ++ @mock.patch( ++ "oauthlib.oauth2.rfc8628.endpoints.device_authorization.generate_token", ++ lambda: "abc", ++ ) ++ def test_device_authorization_grant_echoes_default_scope(self): ++ """A device that omits scope gets the resolved defaults back (issue #949).""" ++ self._configure_endpoint(scopes=["read", "write"]) ++ _, body, _ = self.endpoint.create_device_authorization_response(*self.response_payload()) ++ self.assertEqual("read write", body["scope"]) ++ + @mock.patch( + "oauthlib.oauth2.rfc8628.endpoints.device_authorization.generate_token", + lambda: "abc", diff --git a/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49272_p2.patch b/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49272_p2.patch new file mode 100644 index 0000000000..9752f0fa17 --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-oauthlib/CVE-2026-49272_p2.patch @@ -0,0 +1,263 @@ +From 5edac41fb1164485582f4bc4d2abd9c50eb6df47 Mon Sep 17 00:00:00 2001 +From: Vibe Nuage Agent +Date: Fri, 30 Oct 2026 22:44:06 +0000 +Subject: [PATCH] Ignore client-supplied scope on RFC 8628 device token + requests + +The token endpoint pre-fills request.scopes from the untrusted scope +parameter before the grant runs, which allowed a device-flow client to +obtain a token for any scope within its own registration whenever +validate_device_code did not populate request.scopes, bypassing the +issue #944 consent-integrity guard. Clear scopes on the authorized +path so the grant fails loudly unless the stored authorization +populates them. + +CVE: CVE-2026-49272 +Upstream-Status: Backport [https://github.com/oauthlib/oauthlib/commit/5edac41fb1164485582f4bc4d2abd9c50eb6df47] + +Backport Changes: +- Avoid the shared grant helper's fallback for empty approved scopes in + the device token path. This remaining upstream gap was reproduced on + 3.3.1; call the documented validator policy hook directly and keep + authorization-request defaults unchanged. +- Add regressions distinguishing missing from empty approved scopes and + rejecting denied empty scopes without issuing a token. + +Co-authored-by: JonathanHuot +Signed-off-by: Hetvi Thakar +--- + oauthlib/oauth2/rfc8628/clients/device.py | 7 +- + oauthlib/oauth2/rfc8628/grant_types/device_code.py | 18 +++- + oauthlib/oauth2/rfc8628/request_validator.py | 10 +- + .../oauth2/rfc8628/grant_types/test_device_code.py | 116 ++++++++++++++++++++- + 4 files changed, 141 insertions(+), 10 deletions(-) + +diff --git a/oauthlib/oauth2/rfc8628/clients/device.py b/oauthlib/oauth2/rfc8628/clients/device.py +index ee0ccf8d61897ac5dae0ecd9028f13a929006129..ec36c64fdbb5443728408b3bfc8a783faaebc606 100644 +--- a/oauthlib/oauth2/rfc8628/clients/device.py ++++ b/oauthlib/oauth2/rfc8628/clients/device.py +@@ -62,8 +62,11 @@ class DeviceClient(Client): + + :param body: Existing request body (URL encoded string) to embed parameters + into. This may contain extra parameters. Default ''. +- :param scope: The scope of the access request as described by +- `Section 3.3`_. ++ :param scope: Optional scope of the access request. Note that per ++ RFC 8628 Section 3.4 the token request carries no ++ scope parameter; authorization servers issue the ++ scopes approved during the device authorization, so ++ this parameter is ignored by oauthlib-based servers. + + :param include_client_id: `True` to send the `client_id` in the + body of the upstream request. This is required +diff --git a/oauthlib/oauth2/rfc8628/grant_types/device_code.py b/oauthlib/oauth2/rfc8628/grant_types/device_code.py +index f17384854c66bc10978ef457d1a9b2427ce86641..a7131e649c1107257d0f2f44241009a76cf17783 100644 +--- a/oauthlib/oauth2/rfc8628/grant_types/device_code.py ++++ b/oauthlib/oauth2/rfc8628/grant_types/device_code.py +@@ -143,10 +143,15 @@ class DeviceCodeGrant(GrantTypeBase): + # Validate the device_code first: per RFC 8628 Section 3.4 the token + # request carries no scope, so the validator must populate + # request.user and request.scopes from the stored authorization before +- # validate_scopes runs (otherwise it would fall back to default scopes). ++ # the approved scopes are checked against the client's scope policy. + self.validate_device_code(request) + +- self.validate_scopes(request) ++ # Stored approved scopes are authoritative, including an empty list. ++ # The shared grant helper would replace empty scopes with defaults. ++ if not self.request_validator.validate_scopes( ++ request.client_id, request.scopes, request.client, request ++ ): ++ raise rfc6749_errors.InvalidScopeError(request=request) + + for validator in self.custom_validators.post_token: + validator(request) +@@ -166,6 +171,13 @@ class DeviceCodeGrant(GrantTypeBase): + "Missing device_code parameter.", request=request + ) + ++ # RFC 8628 Section 3.4: the token request carries no scope. The token ++ # endpoint pre-fills request.scopes from the untrusted scope parameter, ++ # so clear it before the validator runs to guarantee only the scopes ++ # populated from the stored authorization are honored. ++ request.scopes = None ++ request.scope = None ++ + status = self.request_validator.validate_device_code( + request.client_id, request.device_code, request + ) +@@ -175,7 +187,7 @@ class DeviceCodeGrant(GrantTypeBase): + # back to the client's default scopes. + if getattr(request, "user", None) is None: + log.debug("request.user was not set on device_code validation.") +- if getattr(request, "scopes", None) is None and request.scope is None: ++ if getattr(request, "scopes", None) is None: + raise rfc6749_errors.ServerError( + description="validate_device_code must set request.scopes for an authorized device_code.", + request=request, +diff --git a/oauthlib/oauth2/rfc8628/request_validator.py b/oauthlib/oauth2/rfc8628/request_validator.py +index 1afacd291113f4ffd94568ec7fb6a6fcf420c9c3..0a8db48ecc872088a2508e03306528ef0de26dde 100644 +--- a/oauthlib/oauth2/rfc8628/request_validator.py ++++ b/oauthlib/oauth2/rfc8628/request_validator.py +@@ -34,9 +34,13 @@ class RequestValidator(OAuth2RequestValidator): + ``DeviceCodeGrant`` status constants: + + - ``DEVICE_CODE_AUTHORIZED``: the end user approved the request. +- The implementation should also set ``request.user`` (and any +- scopes or claims to embed) so they end up on the issued token, +- which removes the need for a separate token validator. ++ The implementation should also set ``request.user`` and ++ ``request.scopes`` from the scopes approved during the device ++ authorization, so they end up on the issued token. Any scope ++ parameter sent by the client on the token request is ignored, so ++ failing to set ``request.scopes`` here results in a ++ ``server_error`` rather than issuing the client's requested ++ scopes. + - ``DEVICE_CODE_PENDING``: the user has not yet completed the + interaction; raises ``AuthorizationPendingError``. + - ``DEVICE_CODE_SLOW_DOWN``: as pending, but the client is polling +diff --git a/tests/oauth2/rfc8628/grant_types/test_device_code.py b/tests/oauth2/rfc8628/grant_types/test_device_code.py +index 952cfe4c1aaf82b03e6e9bc92be1ac46711e557a..1cb5429472553f21b8263268c6f745abbef2d7f7 100644 +--- a/tests/oauth2/rfc8628/grant_types/test_device_code.py ++++ b/tests/oauth2/rfc8628/grant_types/test_device_code.py +@@ -4,6 +4,7 @@ import pytest + + from oauthlib import common + ++from oauthlib.oauth2.rfc6749 import errors as rfc6749_errors + from oauthlib.oauth2.rfc8628.grant_types import DeviceCodeGrant + from oauthlib.oauth2.rfc8628.request_validator import RequestValidator + from oauthlib.oauth2.rfc6749.tokens import BearerToken +@@ -60,7 +61,12 @@ def test_custom_pre_and_post_token_validators(): + request: common.Request = create_request() + request.client = client + client.client_id = request.client_id +- validator.validate_device_code.return_value = DeviceCodeGrant.DEVICE_CODE_AUTHORIZED ++ ++ def authorize(client_id, code, req): ++ req.scopes = ["hello", "world"] ++ return DeviceCodeGrant.DEVICE_CODE_AUTHORIZED ++ ++ validator.validate_device_code.side_effect = authorize + + auth = DeviceCodeGrant(validator) + +@@ -77,7 +83,12 @@ def test_custom_pre_and_post_token_validators(): + def test_create_token_response(): + validator = mock.MagicMock() + request: common.Request = create_request() +- validator.validate_device_code.return_value = DeviceCodeGrant.DEVICE_CODE_AUTHORIZED ++ ++ def authorize(client_id, code, req): ++ req.scopes = ["hello", "world"] ++ return DeviceCodeGrant.DEVICE_CODE_AUTHORIZED ++ ++ validator.validate_device_code.side_effect = authorize + + auth = DeviceCodeGrant(validator) + +@@ -362,3 +373,104 @@ def test_missing_device_code(): + + validator.validate_device_code.assert_not_called() + validator.save_token.assert_not_called() ++ ++ ++def test_device_code_ignores_client_supplied_scope_parameter(): ++ """A client-supplied scope parameter must not become the granted scopes. ++ ++ The token endpoint pre-fills request.scopes from the untrusted ``scope`` ++ parameter before the grant runs. Without this guard, a device-flow client ++ could obtain a token for any scope within its own registration whenever ++ validate_device_code did not populate request.scopes from the stored ++ authorization, bypassing the consent-integrity guard for issue #944. ++ """ ++ validator = mock.MagicMock() ++ request: common.Request = create_request() ++ # Simulate the token endpoint pre-filling scopes from the request ++ # parameter: the client was granted "read" but asks for "admin". ++ request.scope = "admin" ++ request.scopes = ["admin"] ++ ++ def authorize(client_id, code, req): ++ req.scopes = ["read"] ++ return DeviceCodeGrant.DEVICE_CODE_AUTHORIZED ++ ++ validator.validate_device_code.side_effect = authorize ++ ++ auth = DeviceCodeGrant(validator) ++ bearer = BearerToken(validator) ++ auth.create_token_response(request, bearer) ++ ++ validator.get_default_scopes.assert_not_called() ++ validator.validate_scopes.assert_called_once_with( ++ "abcdef", ["read"], request.client, request ++ ) ++ ++ ++@pytest.mark.parametrize("stored_scopes", [None, []]) ++@pytest.mark.parametrize("policy_allowed", [True, False]) ++def test_device_code_distinguishes_missing_and_empty_approved_scopes( ++ stored_scopes, policy_allowed ++): ++ validator = mock.MagicMock() ++ validator.get_default_scopes.return_value = ["default-admin"] ++ validator.validate_scopes.return_value = policy_allowed ++ request = create_request() ++ request.scope = "client-admin" ++ request.scopes = ["client-admin"] ++ ++ def authorize(client_id, code, req): ++ req.user = mock.Mock() ++ req.scopes = stored_scopes ++ return DeviceCodeGrant.DEVICE_CODE_AUTHORIZED ++ ++ validator.validate_device_code.side_effect = authorize ++ auth = DeviceCodeGrant(validator) ++ ++ if stored_scopes is None: ++ with pytest.raises(rfc6749_errors.ServerError): ++ auth.validate_token_request(request) ++ validator.validate_scopes.assert_not_called() ++ else: ++ if policy_allowed: ++ auth.validate_token_request(request) ++ else: ++ with pytest.raises(rfc6749_errors.InvalidScopeError): ++ auth.validate_token_request(request) ++ assert request.scopes == [] ++ validator.validate_scopes.assert_called_once_with( ++ "abcdef", [], request.client, request ++ ) ++ ++ validator.get_default_scopes.assert_not_called() ++ validator.save_token.assert_not_called() ++ ++ ++def test_device_code_empty_approved_scopes_policy_denial_does_not_issue_token(): ++ validator = mock.MagicMock() ++ validator.get_default_scopes.return_value = ["default-admin"] ++ validator.validate_scopes.return_value = False ++ request = create_request() ++ request.scope = "client-admin" ++ request.scopes = ["client-admin"] ++ ++ def authorize(client_id, code, req): ++ req.user = mock.Mock() ++ req.scopes = [] ++ return DeviceCodeGrant.DEVICE_CODE_AUTHORIZED ++ ++ validator.validate_device_code.side_effect = authorize ++ token_handler = mock.Mock() ++ auth = DeviceCodeGrant(validator) ++ ++ _, response, status = auth.create_token_response(request, token_handler) ++ ++ assert status == 400 ++ assert json.loads(response)["error"] == "invalid_scope" ++ assert request.scopes == [] ++ validator.validate_scopes.assert_called_once_with( ++ "abcdef", [], request.client, request ++ ) ++ validator.get_default_scopes.assert_not_called() ++ token_handler.create_token.assert_not_called() ++ validator.save_token.assert_not_called() diff --git a/meta-python/recipes-devtools/python/python3-oauthlib_3.3.1.bb b/meta-python/recipes-devtools/python/python3-oauthlib_3.3.1.bb index d41eeff279..ca78875fb4 100644 --- a/meta-python/recipes-devtools/python/python3-oauthlib_3.3.1.bb +++ b/meta-python/recipes-devtools/python/python3-oauthlib_3.3.1.bb @@ -11,6 +11,8 @@ SRC_URI += " \ file://CVE-2026-49264_p2.patch \ file://CVE-2026-118669-dependent.patch \ file://CVE-2026-118669.patch \ + file://CVE-2026-49272_p1.patch \ + file://CVE-2026-49272_p2.patch \ " SRC_URI[sha256sum] = "0f0f8aa759826a193cf66c12ea1af1637f87b9b4622d46e866952bb022e538c9"