From: Sudhir Dumbhare <[email protected]> This patch applies the upstream fix [1] and follow-up fix [2], as referenced in [3] and [4], to address an http.cookies.Morsel.js_output() flaw where inline JavaScript output escaped quotes but did not neutralize the HTML parser-sensitive </script> sequence.
[1] https://github.com/python/cpython/commit/3c59b8b53fc75c7f9578d16fb8201ceb43e8f76c [2] https://github.com/python/cpython/commit/e7d4c3ff421916986223690a8425d2383f6f3802 [3] https://github.com/python/cpython/issues/149144 [4] https://security-tracker.debian.org/tracker/CVE-2026-6019 Reference: https://nvd.nist.gov/vuln/detail/CVE-2026-6019 Signed-off-by: Sudhir Dumbhare <[email protected]> --- .../python/python3/CVE-2026-6019_p1.patch | 133 ++++++++++++++++++ .../python/python3/CVE-2026-6019_p2.patch | 129 +++++++++++++++++ .../python/python3_3.12.13.bb | 2 + 3 files changed, 264 insertions(+) create mode 100644 meta/recipes-devtools/python/python3/CVE-2026-6019_p1.patch create mode 100644 meta/recipes-devtools/python/python3/CVE-2026-6019_p2.patch diff --git a/meta/recipes-devtools/python/python3/CVE-2026-6019_p1.patch b/meta/recipes-devtools/python/python3/CVE-2026-6019_p1.patch new file mode 100644 index 0000000000..27a4160942 --- /dev/null +++ b/meta/recipes-devtools/python/python3/CVE-2026-6019_p1.patch @@ -0,0 +1,133 @@ +From be751c3f3a11d40c2133bee5fb6ab6931df31936 Mon Sep 17 00:00:00 2001 +From: "Miss Islington (bot)" + <[email protected]> +Date: Thu, 23 Apr 2026 15:05:17 +0200 +Subject: [PATCH] [3.13] gh-90309: Base64-encode cookie values embedded in + JS (GH-148888) + +CVE: CVE-2026-6019 +Upstream-Status: Backport [https://github.com/python/cpython/commit/3c59b8b53fc75c7f9578d16fb8201ceb43e8f76c] + +Backport Changes: +- This file is not present in the current version and is therefore omitted. + Misc/NEWS.d/next/Security/2026-04-21-13-46-30.gh-issue-90309.srvj9q.rst + +(cherry picked from commit 76b3923d688c0efc580658476c5f525ec8735104) + +Co-authored-by: Seth Larson <[email protected]> +(cherry picked from commit 3c59b8b53fc75c7f9578d16fb8201ceb43e8f76c) +Signed-off-by: Sudhir Dumbhare <[email protected]> +--- + Lib/http/cookies.py | 8 ++++++-- + Lib/test/test_http_cookies.py | 29 ++++++++++++++++++----------- + 2 files changed, 24 insertions(+), 13 deletions(-) + +diff --git a/Lib/http/cookies.py b/Lib/http/cookies.py +index 63d119ad46c..aebc2a163e4 100644 +--- a/Lib/http/cookies.py ++++ b/Lib/http/cookies.py +@@ -389,17 +389,21 @@ class Morsel(dict): + return '<%s: %s>' % (self.__class__.__name__, self.OutputString()) + + def js_output(self, attrs=None): ++ import base64 + # Print javascript + output_string = self.OutputString(attrs) + if _has_control_character(output_string): + raise CookieError("Control characters are not allowed in cookies") ++ # Base64-encode value to avoid template ++ # injection in cookie values. ++ output_encoded = base64.b64encode(output_string.encode('utf-8')).decode("ascii") + return """ + <script type="text/javascript"> + <!-- begin hiding +- document.cookie = \"%s\"; ++ document.cookie = atob(\"%s\"); + // end hiding --> + </script> +- """ % (output_string.replace('"', r'\"')) ++ """ % (output_encoded,) + + def OutputString(self, attrs=None): + # Build up our result +diff --git a/Lib/test/test_http_cookies.py b/Lib/test/test_http_cookies.py +index 2478a6c630f..6aa5df068f9 100644 +--- a/Lib/test/test_http_cookies.py ++++ b/Lib/test/test_http_cookies.py +@@ -1,5 +1,5 @@ + # Simple test suite for http/cookies.py +- ++import base64 + import copy + import unittest + import doctest +@@ -152,17 +152,19 @@ class CookieTests(unittest.TestCase): + + self.assertEqual(C.output(['path']), + 'Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme') +- self.assertEqual(C.js_output(), r""" ++ cookie_encoded = base64.b64encode(b'Customer="WILE_E_COYOTE"; Path=/acme; Version=1').decode('ascii') ++ self.assertEqual(C.js_output(), fr""" + <script type="text/javascript"> + <!-- begin hiding +- document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme; Version=1"; ++ document.cookie = atob("{cookie_encoded}"); + // end hiding --> + </script> + """) +- self.assertEqual(C.js_output(['path']), r""" ++ cookie_encoded = base64.b64encode(b'Customer="WILE_E_COYOTE"; Path=/acme').decode('ascii') ++ self.assertEqual(C.js_output(['path']), fr""" + <script type="text/javascript"> + <!-- begin hiding +- document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme"; ++ document.cookie = atob("{cookie_encoded}"); + // end hiding --> + </script> + """) +@@ -259,17 +261,19 @@ class CookieTests(unittest.TestCase): + + self.assertEqual(C.output(['path']), + 'Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme') +- self.assertEqual(C.js_output(), r""" ++ expected_encoded_cookie = base64.b64encode(b'Customer=\"WILE_E_COYOTE\"; Path=/acme; Version=1').decode('ascii') ++ self.assertEqual(C.js_output(), fr""" + <script type="text/javascript"> + <!-- begin hiding +- document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme; Version=1"; ++ document.cookie = atob("{expected_encoded_cookie}"); + // end hiding --> + </script> + """) +- self.assertEqual(C.js_output(['path']), r""" ++ expected_encoded_cookie = base64.b64encode(b'Customer=\"WILE_E_COYOTE\"; Path=/acme').decode('ascii') ++ self.assertEqual(C.js_output(['path']), fr""" + <script type="text/javascript"> + <!-- begin hiding +- document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme"; ++ document.cookie = atob("{expected_encoded_cookie}"); + // end hiding --> + </script> + """) +@@ -360,13 +364,16 @@ class MorselTests(unittest.TestCase): + self.assertEqual( + M.output(), + "Set-Cookie: %s=%s; Path=/foo" % (i, "%s_coded_val" % i)) ++ expected_encoded_cookie = base64.b64encode( ++ ("%s=%s; Path=/foo" % (i, "%s_coded_val" % i)).encode("ascii") ++ ).decode('ascii') + expected_js_output = """ + <script type="text/javascript"> + <!-- begin hiding +- document.cookie = "%s=%s; Path=/foo"; ++ document.cookie = atob("%s"); + // end hiding --> + </script> +- """ % (i, "%s_coded_val" % i) ++ """ % (expected_encoded_cookie,) + self.assertEqual(M.js_output(), expected_js_output) + for i in ["foo bar", "foo@bar"]: + # Try some illegal characters +-- +2.35.6 + diff --git a/meta/recipes-devtools/python/python3/CVE-2026-6019_p2.patch b/meta/recipes-devtools/python/python3/CVE-2026-6019_p2.patch new file mode 100644 index 0000000000..0646bd2133 --- /dev/null +++ b/meta/recipes-devtools/python/python3/CVE-2026-6019_p2.patch @@ -0,0 +1,129 @@ +From de449bbc6ff4ce869c17fb551dacc69de25d73a9 Mon Sep 17 00:00:00 2001 +From: Stan Ulbrych <[email protected]> +Date: Mon, 8 Jun 2026 20:15:21 +0100 +Subject: [PATCH] [3.13] gh-149144: Use `decodeURIComponent()` for UTF-8 + support in `js_output()` (GH-149157) (#150949) + +CVE: CVE-2026-6019 +Upstream-Status: Backport [https://github.com/python/cpython/commit/e7d4c3ff421916986223690a8425d2383f6f3802] + +Co-authored-by: Seth Larson <[email protected]> +(cherry picked from commit e7d4c3ff421916986223690a8425d2383f6f3802) +Signed-off-by: Sudhir Dumbhare <[email protected]> +--- + Lib/http/cookies.py | 6 +++--- + Lib/test/test_http_cookies.py | 27 ++++++++++++++------------- + 2 files changed, 17 insertions(+), 16 deletions(-) + +diff --git a/Lib/http/cookies.py b/Lib/http/cookies.py +index aebc2a163e4..2cffa2a9ad6 100644 +--- a/Lib/http/cookies.py ++++ b/Lib/http/cookies.py +@@ -389,18 +389,18 @@ class Morsel(dict): + return '<%s: %s>' % (self.__class__.__name__, self.OutputString()) + + def js_output(self, attrs=None): +- import base64 ++ import urllib.parse + # Print javascript + output_string = self.OutputString(attrs) + if _has_control_character(output_string): + raise CookieError("Control characters are not allowed in cookies") + # Base64-encode value to avoid template + # injection in cookie values. +- output_encoded = base64.b64encode(output_string.encode('utf-8')).decode("ascii") ++ output_encoded = urllib.parse.quote(output_string, safe='', encoding='utf-8') + return """ + <script type="text/javascript"> + <!-- begin hiding +- document.cookie = atob(\"%s\"); ++ document.cookie = decodeURIComponent(\"%s\"); + // end hiding --> + </script> + """ % (output_encoded,) +diff --git a/Lib/test/test_http_cookies.py b/Lib/test/test_http_cookies.py +index 6aa5df068f9..b9cc59cd1db 100644 +--- a/Lib/test/test_http_cookies.py ++++ b/Lib/test/test_http_cookies.py +@@ -1,10 +1,10 @@ + # Simple test suite for http/cookies.py +-import base64 + import copy + import unittest + import doctest + from http import cookies + import pickle ++import urllib.parse + from test import support + + +@@ -152,19 +152,19 @@ class CookieTests(unittest.TestCase): + + self.assertEqual(C.output(['path']), + 'Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme') +- cookie_encoded = base64.b64encode(b'Customer="WILE_E_COYOTE"; Path=/acme; Version=1').decode('ascii') ++ cookie_encoded = urllib.parse.quote('Customer="WILE_E_COYOTE"; Path=/acme; Version=1', safe='', encoding='utf-8') + self.assertEqual(C.js_output(), fr""" + <script type="text/javascript"> + <!-- begin hiding +- document.cookie = atob("{cookie_encoded}"); ++ document.cookie = decodeURIComponent("{cookie_encoded}"); + // end hiding --> + </script> + """) +- cookie_encoded = base64.b64encode(b'Customer="WILE_E_COYOTE"; Path=/acme').decode('ascii') ++ cookie_encoded = urllib.parse.quote('Customer="WILE_E_COYOTE"; Path=/acme', safe='', encoding='utf-8') + self.assertEqual(C.js_output(['path']), fr""" + <script type="text/javascript"> + <!-- begin hiding +- document.cookie = atob("{cookie_encoded}"); ++ document.cookie = decodeURIComponent("{cookie_encoded}"); + // end hiding --> + </script> + """) +@@ -261,19 +261,19 @@ class CookieTests(unittest.TestCase): + + self.assertEqual(C.output(['path']), + 'Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme') +- expected_encoded_cookie = base64.b64encode(b'Customer=\"WILE_E_COYOTE\"; Path=/acme; Version=1').decode('ascii') ++ expected_encoded_cookie = urllib.parse.quote('Customer=\"WILE_E_COYOTE\"; Path=/acme; Version=1', safe='', encoding='utf-8') + self.assertEqual(C.js_output(), fr""" + <script type="text/javascript"> + <!-- begin hiding +- document.cookie = atob("{expected_encoded_cookie}"); ++ document.cookie = decodeURIComponent("{expected_encoded_cookie}"); + // end hiding --> + </script> + """) +- expected_encoded_cookie = base64.b64encode(b'Customer=\"WILE_E_COYOTE\"; Path=/acme').decode('ascii') ++ expected_encoded_cookie = urllib.parse.quote('Customer=\"WILE_E_COYOTE\"; Path=/acme', safe='', encoding='utf-8') + self.assertEqual(C.js_output(['path']), fr""" + <script type="text/javascript"> + <!-- begin hiding +- document.cookie = atob("{expected_encoded_cookie}"); ++ document.cookie = decodeURIComponent("{expected_encoded_cookie}"); + // end hiding --> + </script> + """) +@@ -364,13 +364,14 @@ class MorselTests(unittest.TestCase): + self.assertEqual( + M.output(), + "Set-Cookie: %s=%s; Path=/foo" % (i, "%s_coded_val" % i)) +- expected_encoded_cookie = base64.b64encode( +- ("%s=%s; Path=/foo" % (i, "%s_coded_val" % i)).encode("ascii") +- ).decode('ascii') ++ expected_encoded_cookie = urllib.parse.quote( ++ "%s=%s; Path=/foo" % (i, "%s_coded_val" % i), ++ safe='', encoding='utf-8', ++ ) + expected_js_output = """ + <script type="text/javascript"> + <!-- begin hiding +- document.cookie = atob("%s"); ++ document.cookie = decodeURIComponent("%s"); + // end hiding --> + </script> + """ % (expected_encoded_cookie,) +-- +2.35.6 + diff --git a/meta/recipes-devtools/python/python3_3.12.13.bb b/meta/recipes-devtools/python/python3_3.12.13.bb index 6ef67e8117..da23093285 100644 --- a/meta/recipes-devtools/python/python3_3.12.13.bb +++ b/meta/recipes-devtools/python/python3_3.12.13.bb @@ -38,6 +38,8 @@ SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \ file://CVE-2026-4519_p1.patch \ file://CVE-2026-4519_p2.patch \ file://CVE-2026-4519_CVE-2026-4786.patch \ + file://CVE-2026-6019_p1.patch \ + file://CVE-2026-6019_p2.patch \ " SRC_URI:append:class-native = " \ -- 2.35.6
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#238669): https://lists.openembedded.org/g/openembedded-core/message/238669 Mute This Topic: https://lists.openembedded.org/mt/119786137/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
