Security fixes for CVE-2026-0865, CVE-2025-15366, CVE-2025-15367 and CVE-2026-1299
Resolves: RHEL-143117 Resolves: RHEL-143174 Resolves: RHEL-144897
This commit is contained in:
parent
98145171c1
commit
6a22d96b0b
90
00473-cve-2026-0865.patch
Normal file
90
00473-cve-2026-0865.patch
Normal file
@ -0,0 +1,90 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Seth Michael Larson <seth@python.org>
|
||||
Date: Sat, 17 Jan 2026 11:46:21 -0600
|
||||
Subject: 00473: CVE-2026-0865
|
||||
|
||||
gh-143916: Reject control characters in wsgiref.headers.Headers (GH-143917)
|
||||
|
||||
* Add 'test.support' fixture for C0 control characters
|
||||
* gh-143916: Reject control characters in wsgiref.headers.Headers
|
||||
---
|
||||
Lib/test/support/__init__.py | 7 +++++++
|
||||
Lib/test/test_wsgiref.py | 12 +++++++++++-
|
||||
Lib/wsgiref/headers.py | 3 +++
|
||||
.../2026-01-16-11-07-36.gh-issue-143916.dpWeOD.rst | 2 ++
|
||||
4 files changed, 23 insertions(+), 1 deletion(-)
|
||||
create mode 100644 Misc/NEWS.d/next/Security/2026-01-16-11-07-36.gh-issue-143916.dpWeOD.rst
|
||||
|
||||
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
|
||||
index e991426bd3..94446da6c9 100644
|
||||
--- a/Lib/test/support/__init__.py
|
||||
+++ b/Lib/test/support/__init__.py
|
||||
@@ -3340,3 +3340,10 @@ def adjust_int_max_str_digits(max_digits):
|
||||
yield
|
||||
finally:
|
||||
sys.set_int_max_str_digits(current)
|
||||
+
|
||||
+
|
||||
+def control_characters_c0() -> list[str]:
|
||||
+ """Returns a list of C0 control characters as strings.
|
||||
+ C0 control characters defined as the byte range 0x00-0x1F, and 0x7F.
|
||||
+ """
|
||||
+ return [chr(c) for c in range(0x00, 0x20)] + ["\x7F"]
|
||||
diff --git a/Lib/test/test_wsgiref.py b/Lib/test/test_wsgiref.py
|
||||
index 3e76e01c65..d5d3f650a1 100644
|
||||
--- a/Lib/test/test_wsgiref.py
|
||||
+++ b/Lib/test/test_wsgiref.py
|
||||
@@ -1,6 +1,6 @@
|
||||
from unittest import mock
|
||||
from test import support
|
||||
-from test.support import socket_helper
|
||||
+from test.support import socket_helper, control_characters_c0
|
||||
from test.test_httpservers import NoLogRequestHandler
|
||||
from unittest import TestCase
|
||||
from wsgiref.util import setup_testing_defaults
|
||||
@@ -526,6 +526,16 @@ class HeaderTests(TestCase):
|
||||
'\r\n'
|
||||
)
|
||||
|
||||
+ def testRaisesControlCharacters(self):
|
||||
+ headers = Headers()
|
||||
+ for c0 in control_characters_c0():
|
||||
+ self.assertRaises(ValueError, headers.__setitem__, f"key{c0}", "val")
|
||||
+ self.assertRaises(ValueError, headers.__setitem__, "key", f"val{c0}")
|
||||
+ self.assertRaises(ValueError, headers.add_header, f"key{c0}", "val", param="param")
|
||||
+ self.assertRaises(ValueError, headers.add_header, "key", f"val{c0}", param="param")
|
||||
+ self.assertRaises(ValueError, headers.add_header, "key", "val", param=f"param{c0}")
|
||||
+
|
||||
+
|
||||
class ErrorHandler(BaseCGIHandler):
|
||||
"""Simple handler subclass for testing BaseHandler"""
|
||||
|
||||
diff --git a/Lib/wsgiref/headers.py b/Lib/wsgiref/headers.py
|
||||
index fab851c5a4..fd98e85d75 100644
|
||||
--- a/Lib/wsgiref/headers.py
|
||||
+++ b/Lib/wsgiref/headers.py
|
||||
@@ -9,6 +9,7 @@ written by Barry Warsaw.
|
||||
# existence of which force quoting of the parameter value.
|
||||
import re
|
||||
tspecials = re.compile(r'[ \(\)<>@,;:\\"/\[\]\?=]')
|
||||
+_control_chars_re = re.compile(r'[\x00-\x1F\x7F]')
|
||||
|
||||
def _formatparam(param, value=None, quote=1):
|
||||
"""Convenience function to format and return a key=value pair.
|
||||
@@ -41,6 +42,8 @@ class Headers:
|
||||
def _convert_string_type(self, value):
|
||||
"""Convert/check value type."""
|
||||
if type(value) is str:
|
||||
+ if _control_chars_re.search(value):
|
||||
+ raise ValueError("Control characters not allowed in headers")
|
||||
return value
|
||||
raise AssertionError("Header names/values must be"
|
||||
" of type str (got {0})".format(repr(value)))
|
||||
diff --git a/Misc/NEWS.d/next/Security/2026-01-16-11-07-36.gh-issue-143916.dpWeOD.rst b/Misc/NEWS.d/next/Security/2026-01-16-11-07-36.gh-issue-143916.dpWeOD.rst
|
||||
new file mode 100644
|
||||
index 0000000000..44bd0b2705
|
||||
--- /dev/null
|
||||
+++ b/Misc/NEWS.d/next/Security/2026-01-16-11-07-36.gh-issue-143916.dpWeOD.rst
|
||||
@@ -0,0 +1,2 @@
|
||||
+Reject C0 control characters within wsgiref.headers.Headers fields, values,
|
||||
+and parameters.
|
||||
61
00474-cve-2025-15366.patch
Normal file
61
00474-cve-2025-15366.patch
Normal file
@ -0,0 +1,61 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Seth Michael Larson <seth@python.org>
|
||||
Date: Tue, 20 Jan 2026 14:45:42 -0600
|
||||
Subject: 00474: CVE-2025-15366
|
||||
|
||||
gh-143921: Reject control characters in IMAP commands
|
||||
|
||||
(cherry-picked from commit 6262704b134db2a4ba12e85ecfbd968534f28b45)
|
||||
---
|
||||
Lib/imaplib.py | 4 +++-
|
||||
Lib/test/test_imaplib.py | 6 ++++++
|
||||
.../Security/2026-01-16-11-41-06.gh-issue-143921.AeCOor.rst | 1 +
|
||||
3 files changed, 10 insertions(+), 1 deletion(-)
|
||||
create mode 100644 Misc/NEWS.d/next/Security/2026-01-16-11-41-06.gh-issue-143921.AeCOor.rst
|
||||
|
||||
diff --git a/Lib/imaplib.py b/Lib/imaplib.py
|
||||
index ced7203e0c..be2fcb3c05 100644
|
||||
--- a/Lib/imaplib.py
|
||||
+++ b/Lib/imaplib.py
|
||||
@@ -132,7 +132,7 @@ Untagged_status = re.compile(
|
||||
# We compile these in _mode_xxx.
|
||||
_Literal = br'.*{(?P<size>\d+)}$'
|
||||
_Untagged_status = br'\* (?P<data>\d+) (?P<type>[A-Z-]+)( (?P<data2>.*))?'
|
||||
-
|
||||
+_control_chars = re.compile(b'[\x00-\x1F\x7F]')
|
||||
|
||||
|
||||
class IMAP4:
|
||||
@@ -994,6 +994,8 @@ class IMAP4:
|
||||
if arg is None: continue
|
||||
if isinstance(arg, str):
|
||||
arg = bytes(arg, self._encoding)
|
||||
+ if _control_chars.search(arg):
|
||||
+ raise ValueError("Control characters not allowed in commands")
|
||||
data = data + b' ' + arg
|
||||
|
||||
literal = self.literal
|
||||
diff --git a/Lib/test/test_imaplib.py b/Lib/test/test_imaplib.py
|
||||
index 057e4e65f0..471325de1d 100644
|
||||
--- a/Lib/test/test_imaplib.py
|
||||
+++ b/Lib/test/test_imaplib.py
|
||||
@@ -503,6 +503,12 @@ class NewIMAPTestsMixin():
|
||||
self.assertEqual(data[0], b'LOGIN completed')
|
||||
self.assertEqual(client.state, 'AUTH')
|
||||
|
||||
+ def test_control_characters(self):
|
||||
+ client, _ = self._setup(SimpleIMAPHandler)
|
||||
+ for c0 in support.control_characters_c0():
|
||||
+ with self.assertRaises(ValueError):
|
||||
+ client.login(f'user{c0}', 'pass')
|
||||
+
|
||||
def test_logout(self):
|
||||
client, _ = self._setup(SimpleIMAPHandler)
|
||||
typ, data = client.login('user', 'pass')
|
||||
diff --git a/Misc/NEWS.d/next/Security/2026-01-16-11-41-06.gh-issue-143921.AeCOor.rst b/Misc/NEWS.d/next/Security/2026-01-16-11-41-06.gh-issue-143921.AeCOor.rst
|
||||
new file mode 100644
|
||||
index 0000000000..4e13fe92bc
|
||||
--- /dev/null
|
||||
+++ b/Misc/NEWS.d/next/Security/2026-01-16-11-41-06.gh-issue-143921.AeCOor.rst
|
||||
@@ -0,0 +1 @@
|
||||
+Reject control characters in IMAP commands.
|
||||
61
00475-cve-2025-15367.patch
Normal file
61
00475-cve-2025-15367.patch
Normal file
@ -0,0 +1,61 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Seth Michael Larson <seth@python.org>
|
||||
Date: Tue, 20 Jan 2026 14:46:32 -0600
|
||||
Subject: 00475: CVE-2025-15367
|
||||
|
||||
gh-143923: Reject control characters in POP3 commands
|
||||
|
||||
(cherry-picked from commit b234a2b67539f787e191d2ef19a7cbdce32874e7)
|
||||
---
|
||||
Lib/poplib.py | 2 ++
|
||||
Lib/test/test_poplib.py | 8 ++++++++
|
||||
.../2026-01-16-11-43-47.gh-issue-143923.DuytMe.rst | 1 +
|
||||
3 files changed, 11 insertions(+)
|
||||
create mode 100644 Misc/NEWS.d/next/Security/2026-01-16-11-43-47.gh-issue-143923.DuytMe.rst
|
||||
|
||||
diff --git a/Lib/poplib.py b/Lib/poplib.py
|
||||
index 0f8587317c..f563030f7f 100644
|
||||
--- a/Lib/poplib.py
|
||||
+++ b/Lib/poplib.py
|
||||
@@ -122,6 +122,8 @@ class POP3:
|
||||
def _putcmd(self, line):
|
||||
if self._debugging: print('*cmd*', repr(line))
|
||||
line = bytes(line, self.encoding)
|
||||
+ if re.search(b'[\x00-\x1F\x7F]', line):
|
||||
+ raise ValueError('Control characters not allowed in commands')
|
||||
self._putline(line)
|
||||
|
||||
|
||||
diff --git a/Lib/test/test_poplib.py b/Lib/test/test_poplib.py
|
||||
index 5d9f557eef..7a0313f35a 100644
|
||||
--- a/Lib/test/test_poplib.py
|
||||
+++ b/Lib/test/test_poplib.py
|
||||
@@ -14,6 +14,7 @@ import threading
|
||||
import unittest
|
||||
from unittest import TestCase, skipUnless
|
||||
from test import support as test_support
|
||||
+from test.support import control_characters_c0
|
||||
from test.support import hashlib_helper
|
||||
from test.support import socket_helper
|
||||
|
||||
@@ -360,6 +361,13 @@ class TestPOP3Class(TestCase):
|
||||
self.assertIsNone(self.client.sock)
|
||||
self.assertIsNone(self.client.file)
|
||||
|
||||
+ def test_control_characters(self):
|
||||
+ for c0 in control_characters_c0():
|
||||
+ with self.assertRaises(ValueError):
|
||||
+ self.client.user(f'user{c0}')
|
||||
+ with self.assertRaises(ValueError):
|
||||
+ self.client.pass_(f'{c0}pass')
|
||||
+
|
||||
@requires_ssl
|
||||
def test_stls_capa(self):
|
||||
capa = self.client.capa()
|
||||
diff --git a/Misc/NEWS.d/next/Security/2026-01-16-11-43-47.gh-issue-143923.DuytMe.rst b/Misc/NEWS.d/next/Security/2026-01-16-11-43-47.gh-issue-143923.DuytMe.rst
|
||||
new file mode 100644
|
||||
index 0000000000..3cde4df3e0
|
||||
--- /dev/null
|
||||
+++ b/Misc/NEWS.d/next/Security/2026-01-16-11-43-47.gh-issue-143923.DuytMe.rst
|
||||
@@ -0,0 +1 @@
|
||||
+Reject control characters in POP3 commands.
|
||||
108
00476-cve-2026-1299.patch
Normal file
108
00476-cve-2026-1299.patch
Normal file
@ -0,0 +1,108 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Miss Islington (bot)"
|
||||
<31488909+miss-islington@users.noreply.github.com>
|
||||
Date: Sun, 25 Jan 2026 18:10:00 +0100
|
||||
Subject: 00476: CVE-2026-1299
|
||||
|
||||
gh-144125: email: verify headers are sound in BytesGenerator
|
||||
(cherry picked from commit 052e55e7d44718fe46cbba0ca995cb8fcc359413)
|
||||
|
||||
Co-authored-by: Seth Michael Larson <seth@python.org>
|
||||
Co-authored-by: Denis Ledoux <dle@odoo.com>
|
||||
Co-authored-by: Denis Ledoux <5822488+beledouxdenis@users.noreply.github.com>
|
||||
Co-authored-by: Petr Viktorin <302922+encukou@users.noreply.github.com>
|
||||
Co-authored-by: Bas Bloemsaat <1586868+basbloemsaat@users.noreply.github.com>
|
||||
---
|
||||
Lib/email/generator.py | 12 +++++++++++-
|
||||
Lib/test/test_email/test_generator.py | 4 +++-
|
||||
Lib/test/test_email/test_policy.py | 6 +++++-
|
||||
.../2026-01-21-12-34-05.gh-issue-144125.TAz5uo.rst | 4 ++++
|
||||
4 files changed, 23 insertions(+), 3 deletions(-)
|
||||
create mode 100644 Misc/NEWS.d/next/Security/2026-01-21-12-34-05.gh-issue-144125.TAz5uo.rst
|
||||
|
||||
diff --git a/Lib/email/generator.py b/Lib/email/generator.py
|
||||
index 89224ae41c..98cc4a09c9 100644
|
||||
--- a/Lib/email/generator.py
|
||||
+++ b/Lib/email/generator.py
|
||||
@@ -22,6 +22,7 @@ NL = '\n' # XXX: no longer used by the code below.
|
||||
NLCRE = re.compile(r'\r\n|\r|\n')
|
||||
fcre = re.compile(r'^From ', re.MULTILINE)
|
||||
NEWLINE_WITHOUT_FWSP = re.compile(r'\r\n[^ \t]|\r[^ \n\t]|\n[^ \t]')
|
||||
+NEWLINE_WITHOUT_FWSP_BYTES = re.compile(br'\r\n[^ \t]|\r[^ \n\t]|\n[^ \t]')
|
||||
|
||||
|
||||
|
||||
@@ -430,7 +431,16 @@ class BytesGenerator(Generator):
|
||||
# This is almost the same as the string version, except for handling
|
||||
# strings with 8bit bytes.
|
||||
for h, v in msg.raw_items():
|
||||
- self._fp.write(self.policy.fold_binary(h, v))
|
||||
+ folded = self.policy.fold_binary(h, v)
|
||||
+ if self.policy.verify_generated_headers:
|
||||
+ linesep = self.policy.linesep.encode()
|
||||
+ if not folded.endswith(linesep):
|
||||
+ raise HeaderWriteError(
|
||||
+ f'folded header does not end with {linesep!r}: {folded!r}')
|
||||
+ if NEWLINE_WITHOUT_FWSP_BYTES.search(folded.removesuffix(linesep)):
|
||||
+ raise HeaderWriteError(
|
||||
+ f'folded header contains newline: {folded!r}')
|
||||
+ self._fp.write(folded)
|
||||
# A blank line always separates headers from body
|
||||
self.write(self._NL)
|
||||
|
||||
diff --git a/Lib/test/test_email/test_generator.py b/Lib/test/test_email/test_generator.py
|
||||
index d29400f0ed..a641f871dd 100644
|
||||
--- a/Lib/test/test_email/test_generator.py
|
||||
+++ b/Lib/test/test_email/test_generator.py
|
||||
@@ -264,7 +264,7 @@ class TestGenerator(TestGeneratorBase, TestEmailBase):
|
||||
typ = str
|
||||
|
||||
def test_verify_generated_headers(self):
|
||||
- """gh-121650: by default the generator prevents header injection"""
|
||||
+ # gh-121650: by default the generator prevents header injection
|
||||
class LiteralHeader(str):
|
||||
name = 'Header'
|
||||
def fold(self, **kwargs):
|
||||
@@ -285,6 +285,8 @@ class TestGenerator(TestGeneratorBase, TestEmailBase):
|
||||
|
||||
with self.assertRaises(email.errors.HeaderWriteError):
|
||||
message.as_string()
|
||||
+ with self.assertRaises(email.errors.HeaderWriteError):
|
||||
+ message.as_bytes()
|
||||
|
||||
|
||||
class TestBytesGenerator(TestGeneratorBase, TestEmailBase):
|
||||
diff --git a/Lib/test/test_email/test_policy.py b/Lib/test/test_email/test_policy.py
|
||||
index ff1ddf7d7a..d4a5eb3b59 100644
|
||||
--- a/Lib/test/test_email/test_policy.py
|
||||
+++ b/Lib/test/test_email/test_policy.py
|
||||
@@ -279,7 +279,7 @@ class PolicyAPITests(unittest.TestCase):
|
||||
policy.fold("Subject", subject)
|
||||
|
||||
def test_verify_generated_headers(self):
|
||||
- """Turning protection off allows header injection"""
|
||||
+ # Turning protection off allows header injection
|
||||
policy = email.policy.default.clone(verify_generated_headers=False)
|
||||
for text in (
|
||||
'Header: Value\r\nBad: Injection\r\n',
|
||||
@@ -302,6 +302,10 @@ class PolicyAPITests(unittest.TestCase):
|
||||
message.as_string(),
|
||||
f"{text}\nBody",
|
||||
)
|
||||
+ self.assertEqual(
|
||||
+ message.as_bytes(),
|
||||
+ f"{text}\nBody".encode(),
|
||||
+ )
|
||||
|
||||
# XXX: Need subclassing tests.
|
||||
# For adding subclassed objects, make sure the usual rules apply (subclass
|
||||
diff --git a/Misc/NEWS.d/next/Security/2026-01-21-12-34-05.gh-issue-144125.TAz5uo.rst b/Misc/NEWS.d/next/Security/2026-01-21-12-34-05.gh-issue-144125.TAz5uo.rst
|
||||
new file mode 100644
|
||||
index 0000000000..e6333e7249
|
||||
--- /dev/null
|
||||
+++ b/Misc/NEWS.d/next/Security/2026-01-21-12-34-05.gh-issue-144125.TAz5uo.rst
|
||||
@@ -0,0 +1,4 @@
|
||||
+:mod:`~email.generator.BytesGenerator` will now refuse to serialize (write) headers
|
||||
+that are unsafely folded or delimited; see
|
||||
+:attr:`~email.policy.Policy.verify_generated_headers`. (Contributed by Bas
|
||||
+Bloemsaat and Petr Viktorin in :gh:`121650`).
|
||||
@ -17,7 +17,7 @@ URL: https://www.python.org/
|
||||
#global prerel ...
|
||||
%global upstream_version %{general_version}%{?prerel}
|
||||
Version: %{general_version}%{?prerel:~%{prerel}}
|
||||
Release: 3%{?dist}
|
||||
Release: 4%{?dist}
|
||||
License: Python
|
||||
|
||||
|
||||
@ -445,6 +445,37 @@ Patch422: 00422-fix-tests-for-xmlpullparser-with-expat-2-6-0.patch
|
||||
# * gh-142754: Ensure that Element & Attr instances have the ownerDocument attribute (GH-142794)
|
||||
Patch471: 00471-cve-2025-12084.patch
|
||||
|
||||
# 00473 # 7e68b796abe391a467dba42b6641053aac726d67
|
||||
# CVE-2026-0865
|
||||
#
|
||||
# gh-143916: Reject control characters in wsgiref.headers.Headers (GH-143917)
|
||||
#
|
||||
# * Add 'test.support' fixture for C0 control characters
|
||||
# * gh-143916: Reject control characters in wsgiref.headers.Headers
|
||||
Patch473: 00473-cve-2026-0865.patch
|
||||
|
||||
# 00474 # 837ddca0372fa87ff9cee47142200caa21e77def
|
||||
# CVE-2025-15366
|
||||
#
|
||||
# gh-143921: Reject control characters in IMAP commands
|
||||
#
|
||||
# (cherry-picked from commit 6262704b134db2a4ba12e85ecfbd968534f28b45)
|
||||
Patch474: 00474-cve-2025-15366.patch
|
||||
|
||||
# 00475 # 00384c03f44af74c955a44637eee0b66f717a487
|
||||
# CVE-2025-15367
|
||||
#
|
||||
# gh-143923: Reject control characters in POP3 commands
|
||||
#
|
||||
# (cherry-picked from commit b234a2b67539f787e191d2ef19a7cbdce32874e7)
|
||||
Patch475: 00475-cve-2025-15367.patch
|
||||
|
||||
# 00476 # efbfd1798bf8c1a9845546a0ed9193f94661dd1b
|
||||
# CVE-2026-1299
|
||||
#
|
||||
# gh-144125: email: verify headers are sound in BytesGenerator
|
||||
Patch476: 00476-cve-2026-1299.patch
|
||||
|
||||
# (New patches go here ^^^)
|
||||
#
|
||||
# When adding new patches to "python" and "python3" in Fedora, EL, etc.,
|
||||
@ -1856,6 +1887,12 @@ CheckPython optimized
|
||||
# ======================================================
|
||||
|
||||
%changelog
|
||||
* Wed Feb 25 2026 Tomáš Hrnčiar <thrnciar@redhat.com> - 3.9.25-4
|
||||
- Security fixes for CVE-2026-0865, CVE-2025-15366, CVE-2025-15367 and CVE-2026-1299
|
||||
Resolves: RHEL-143117
|
||||
Resolves: RHEL-143174
|
||||
Resolves: RHEL-144897
|
||||
|
||||
* Wed Jan 14 2026 Lumír Balhar <lbalhar@redhat.com> - 3.9.25-3
|
||||
- Security fix for CVE-2025-12084
|
||||
Resolves: RHEL-135897
|
||||
|
||||
Loading…
Reference in New Issue
Block a user