public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/python3.9] rawhide: Security fix for CVE-2026-15308
@ 2026-10-26 10:59 
  0 siblings, 0 replies; only message in thread
From:  @ 2026-10-26 10:59 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/python3.9
            Branch : rawhide
            Commit : 146ccdd7d992b654dcdb700d253fd41378fbd5aa
            Author : Lukáš Zachar <lzachar@redhat.com>
            Date   : 2026-09-23T14:50:25+02:00
            Stats  : +127/-1 in 2 file(s)
            URL    : https://src.fedoraproject.org/rpms/python3.9/c/146ccdd7d992b654dcdb700d253fd41378fbd5aa?branch=rawhide

            Log:
            Security fix for CVE-2026-15308

Resolves: rhbz#2498693
(cherry picked from c9s commit 0ad244b12d3adcc81d14e6c9dc974351dc77d2a4)

---
diff --git a/00490-cve-2026-15308.patch b/00490-cve-2026-15308.patch
new file mode 100644
index 0000000..77abf51
--- /dev/null
+++ b/00490-cve-2026-15308.patch
@@ -0,0 +1,113 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Serhiy Storchaka <storchaka@gmail.com>
+Date: Sat, 4 Jul 2026 20:40:22 +0300
+Subject: 0490: gh-153030: Fix quadratic complexity in incremental parsing in
+ HTMLParser (GH-153031)
+
+When an unterminated construct (e.g. a tag or comment) spanned many
+feed() calls, rescanning the growing buffer and concatenating new data
+onto it were both quadratic.  New data is now accumulated in a list and
+only joined and parsed once enough has piled up.
+
+Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
+(cherry picked from commit bcf98ddbc40ec9b3ee87da0124a5660b19b7e606)
+---
+ Lib/html/parser.py                            | 32 +++++++++++++++++--
+ Lib/test/test_htmlparser.py                   | 20 ++++++++++++
+ ...-07-04-17-00-00.gh-issue-153030.RovkP6.rst |  3 ++
+ 3 files changed, 53 insertions(+), 2 deletions(-)
+ create mode 100644 Misc/NEWS.d/next/Security/2026-07-04-17-00-00.gh-issue-153030.RovkP6.rst
+
+diff --git a/Lib/html/parser.py b/Lib/html/parser.py
+index 62134d376e..a11e50982b 100644
+--- a/Lib/html/parser.py
++++ b/Lib/html/parser.py
+@@ -137,6 +137,9 @@ class HTMLParser(_markupbase.ParserBase):
+         self.cdata_elem = None
+         self._support_cdata = True
+         self._escapable = True
++        self._pending = []
++        self._pending_len = 0
++        self._parse_threshold = 1
+         _markupbase.ParserBase.reset(self)
+ 
+     def feed(self, data):
+@@ -145,11 +148,36 @@ class HTMLParser(_markupbase.ParserBase):
+         Call this as often as you want, with as little or as much text
+         as you want (may include '\n').
+         """
+-        self.rawdata = self.rawdata + data
+-        self.goahead(0)
++        # Accumulate new data in a list and only join and parse it once
++        # enough has piled up.  Rescanning an unparsed buffer (e.g. an
++        # unterminated tag) and concatenating onto it on every call would
++        # both be quadratic in the input size.
++        self._pending_len += len(data)
++        if self._pending_len < self._parse_threshold:
++            self._pending.append(data)
++        else:
++            if not self._pending:
++                self.rawdata += data
++            else:
++                self._pending.append(data)
++                self.rawdata += ''.join(self._pending)
++                self._pending.clear()
++            self._pending_len = 0
++            n = len(self.rawdata)
++            self.goahead(0)
++            if len(self.rawdata) < n:
++                # Some data was parsed; resume on the next call.
++                self._parse_threshold = 1
++            else:
++                # Nothing was parsed; wait until the buffer doubles.
++                self._parse_threshold = len(self.rawdata)
+ 
+     def close(self):
+         """Handle any buffered data."""
++        if self._pending:
++            self.rawdata += ''.join(self._pending)
++            self._pending.clear()
++            self._pending_len = 0
+         self.goahead(1)
+ 
+     __starttag_text = None
+diff --git a/Lib/test/test_htmlparser.py b/Lib/test/test_htmlparser.py
+index ea5eb9fd7f..e8e0af364b 100644
+--- a/Lib/test/test_htmlparser.py
++++ b/Lib/test/test_htmlparser.py
+@@ -929,6 +929,26 @@ text
+         check("<![CDATA[" * 9 * n)
+         check("<!doctype" * 35 * n)
+ 
++    @support.requires_resource('cpu')
++    def test_incremental_no_quadratic_complexity(self):
++        # An unterminated construct fed in many small chunks used to take
++        # quadratic time, both to rescan and to concatenate the buffer.
++        # Now it takes a fraction of a second.
++        def check(prefix, chunk, suffix):
++            parser = html.parser.HTMLParser()
++            parser.feed(prefix)
++            for _ in range(200_000):
++                parser.feed(chunk)
++            parser.feed(suffix)
++            parser.close()
++        chunk = "a" * 64
++        check("<!--", chunk, "-->")       # comment
++        check("<?", chunk, ">")           # processing instruction
++        check("<!doctype ", chunk, ">")   # doctype
++        check("<![CDATA[", chunk, "]]>")  # CDATA section
++        check("<a href='", chunk, "'>")   # start tag
++        check("<script>", chunk, "</script>")  # RAWTEXT element
++
+ 
+ class AttributesTestCase(TestCaseBase):
+ 
+diff --git a/Misc/NEWS.d/next/Security/2026-07-04-17-00-00.gh-issue-153030.RovkP6.rst b/Misc/NEWS.d/next/Security/2026-07-04-17-00-00.gh-issue-153030.RovkP6.rst
+new file mode 100644
+index 0000000000..d1d60593f4
+--- /dev/null
++++ b/Misc/NEWS.d/next/Security/2026-07-04-17-00-00.gh-issue-153030.RovkP6.rst
+@@ -0,0 +1,3 @@
++Fixed quadratic complexity in incremental parsing of long unterminated
++constructs (such as tags or comments) in :class:`html.parser.HTMLParser`,
++which could be exploited for a denial of service.

diff --git a/python3.9.spec b/python3.9.spec
index 1aae14d..ad822db 100644
--- a/python3.9.spec
+++ b/python3.9.spec
@@ -26,7 +26,7 @@ URL: https://www.python.org/
 #global prerel ...
 %global upstream_version %{general_version}%{?prerel}
 Version: %{general_version}%{?prerel:~%{prerel}}
-Release: 13%{?dist}
+Release: 14%{?dist}
 # Python is Python-2.0.1
 # pip is MIT and bundles:
 #   CacheControl: Apache-2.0
@@ -577,6 +577,15 @@ Patch482: 00482-cve-2026-6100.patch
 # (cherry-picked from commit acfe02f3b05436658d92add6b168538b30f357f0)
 Patch489: 00489-openssl-3.5.7.patch
 
+# 00490 # 4d6b26beb70a9404047984320a87560e9b188ab2
+# gh-153030: Fix quadratic complexity in incremental parsing in HTMLParser (GH-153031)
+#
+# When an unterminated construct (e.g. a tag or comment) spanned many
+# feed() calls, rescanning the growing buffer and concatenating new data
+# onto it were both quadratic.  New data is now accumulated in a list and
+# only joined and parsed once enough has piled up.
+Patch490: 00490-cve-2026-15308.patch
+
 # 00491 # ac14737379922303720216b61803474c84f291ef
 # gh-149776: Skip UDP Lite tests if it's not supported
 #
@@ -2071,6 +2080,10 @@ CheckPython optimized
 # ======================================================
 
 %changelog
+* Wed Sep 23 2026 Lukáš Zachar <lzachar@redhat.com> - 3.9.25-14
+- Security fix for CVE-2026-15308
+Resolves: rhbz#2498693
+
 * Thu Jul 30 2026 Miro Hrončok <mhroncok@redhat.com> - 3.9.25-13
  - Skip UDP Lite tests if it's not supported
  - Fixes FTBFS on Linux kernel 7.1 and newer

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-26 10:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-26 10:59 [rpms/python3.9] rawhide: Security fix for CVE-2026-15308 

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox