diff mbox series

[meta-python,wrynose,3/5] python3-twisted: Fix CVE-2026-115774

Message ID 20261124060035.1651451-4-yurade@cisco.com
State New
Headers show
Series python3-twisted: Security fixes | expand

Commit Message

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

[1] https://github.com/twisted/twisted/commit/3d125548bcbe955007cb97f480bb699a5e074741
[2] https://github.com/twisted/twisted/commit/a97aa5babb151b5d1aebf1c14596c786cd0bf105
[3] https://nvd.nist.gov/vuln/detail/CVE-2026-115774
[4] https://github.com/twisted/twisted/pull/12764

Signed-off-by: Yogita Urade <yurade@cisco.com>
---
 .../python3-twisted/CVE-2026-115774_p1.patch  | 55 +++++++++++++++++++
 .../python3-twisted/CVE-2026-115774_p2.patch  | 26 +++++++++
 .../python/python3-twisted_25.5.0.bb          |  2 +
 3 files changed, 83 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-twisted/CVE-2026-115774_p1.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-twisted/CVE-2026-115774_p2.patch
diff mbox series

Patch

diff --git a/meta-python/recipes-devtools/python/python3-twisted/CVE-2026-115774_p1.patch b/meta-python/recipes-devtools/python/python3-twisted/CVE-2026-115774_p1.patch
new file mode 100644
index 0000000000..3b72fd4994
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-twisted/CVE-2026-115774_p1.patch
@@ -0,0 +1,55 @@ 
+From 3d125548bcbe955007cb97f480bb699a5e074741 Mon Sep 17 00:00:00 2001
+From: arkmarta <arkadiuszmarta@proton.me>
+Date: Sun, 2 Aug 2026 19:43:50 +0200
+Subject: [PATCH] mail: reject a negative IMAP literal size (Fixes #12763)
+
+CVE: CVE-2026-115774
+Upstream-Status: Backport [https://github.com/twisted/twisted/commit/3d125548bcbe955007cb97f480bb699a5e074741]
+
+Signed-off-by: Yogita Urade <yurade@cisco.com>
+---
+ src/twisted/mail/imap4.py                   | 2 ++
+ src/twisted/mail/newsfragments/12763.bugfix | 1 +
+ src/twisted/mail/test/test_imap.py          | 8 ++++++++
+ 3 files changed, 11 insertions(+)
+ create mode 100644 src/twisted/mail/newsfragments/12763.bugfix
+
+diff --git a/src/twisted/mail/imap4.py b/src/twisted/mail/imap4.py
+index f38d094f8..7aee83886 100644
+--- a/src/twisted/mail/imap4.py
++++ b/src/twisted/mail/imap4.py
+@@ -4756,6 +4756,8 @@ def parseNestedParens(s, handleLiteral=1):
+                     if end == -1:
+                         raise ValueError("Malformed literal")
+                     literalSize = int(s[i + 1 : end])
++                    if literalSize < 0:
++                        raise ValueError("Illegal literal size")
+                     contentStack[-1].append((s[end + 3 : end + 3 + literalSize],))
+                     i = end + 3 + literalSize
+                 elif c == b"(" or c == b"[":
+diff --git a/src/twisted/mail/newsfragments/12763.bugfix b/src/twisted/mail/newsfragments/12763.bugfix
+new file mode 100644
+index 000000000..929a1b53a
+--- /dev/null
++++ b/src/twisted/mail/newsfragments/12763.bugfix
+@@ -0,0 +1 @@
++twisted.mail.imap4.IMAP4Server now rejects a SEARCH command containing a literal with a negative octet count, so an authenticated client can no longer freeze the server with a crafted command.
+diff --git a/src/twisted/mail/test/test_imap.py b/src/twisted/mail/test/test_imap.py
+index d2c63eb69..43c1c03b8 100644
+--- a/src/twisted/mail/test/test_imap.py
++++ b/src/twisted/mail/test/test_imap.py
+@@ -1324,6 +1324,14 @@ class IMAP4HelperTests(TestCase):
+         for case, expected in cases:
+             self.assertEqual(imap4.parseNestedParens(case), expected)
+ 
++    def test_literalNegativeSize(self):
++        """
++        A literal with a negative octet count is rejected with L{ValueError}
++        instead of driving the parser into a non-terminating loop.
++        """
++        self.assertRaises(ValueError, imap4.parseNestedParens, b"{-1}", 1)
++        self.assertRaises(ValueError, imap4.parseNestedParens, b"foo {-100}bar", 1)
++
+     def test_queryBuilder(self):
+         inputs = [
+             imap4.Query(flagged=1),
diff --git a/meta-python/recipes-devtools/python/python3-twisted/CVE-2026-115774_p2.patch b/meta-python/recipes-devtools/python/python3-twisted/CVE-2026-115774_p2.patch
new file mode 100644
index 0000000000..254248df2a
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-twisted/CVE-2026-115774_p2.patch
@@ -0,0 +1,26 @@ 
+From a97aa5babb151b5d1aebf1c14596c786cd0bf105 Mon Sep 17 00:00:00 2001
+From: Glyph <code@glyph.im>
+Date: Tue, 4 Aug 2026 15:57:56 -0700
+Subject: [PATCH] Update src/twisted/mail/test/test_imap.py
+
+CVE: CVE-2026-115774
+Upstream-Status: Backport [https://github.com/twisted/twisted/commit/a97aa5babb151b5d1aebf1c14596c786cd0bf105]
+
+Signed-off-by: Yogita Urade <yurade@cisco.com>
+---
+ src/twisted/mail/test/test_imap.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/twisted/mail/test/test_imap.py b/src/twisted/mail/test/test_imap.py
+index 43c1c03b8..ae42caad9 100644
+--- a/src/twisted/mail/test/test_imap.py
++++ b/src/twisted/mail/test/test_imap.py
+@@ -1324,7 +1324,7 @@ class IMAP4HelperTests(TestCase):
+         for case, expected in cases:
+             self.assertEqual(imap4.parseNestedParens(case), expected)
+ 
+-    def test_literalNegativeSize(self):
++    def test_literalNegativeSize(self) -> None:
+         """
+         A literal with a negative octet count is rejected with L{ValueError}
+         instead of driving the parser into a non-terminating loop.
diff --git a/meta-python/recipes-devtools/python/python3-twisted_25.5.0.bb b/meta-python/recipes-devtools/python/python3-twisted_25.5.0.bb
index 78e74fa491..7ba179c455 100644
--- a/meta-python/recipes-devtools/python/python3-twisted_25.5.0.bb
+++ b/meta-python/recipes-devtools/python/python3-twisted_25.5.0.bb
@@ -20,6 +20,8 @@  SRC_URI += "file://CVE-2026-42304_p1.patch \
            file://CVE-2026-115877_p1.patch \
            file://CVE-2026-115877_p2.patch \
            file://CVE-2026-115877_p3.patch \
+           file://CVE-2026-115774_p1.patch \
+           file://CVE-2026-115774_p2.patch \
            "
 
 SRC_URI[sha256sum] = "1deb272358cb6be1e3e8fc6f9c8b36f78eb0fa7c2233d2dbe11ec6fee04ea316"