new file mode 100644
@@ -0,0 +1,111 @@
+From ac90fb7b0ab73688a581fcd9a7c0577ec8ca3059 Mon Sep 17 00:00:00 2001
+From: arkmarta <arkadiuszmarta@proton.me>
+Date: Wed, 5 Aug 2026 11:14:11 +0200
+Subject: [PATCH] words: bound the IRC server line buffer (Fixes #12770)
+
+CVE: CVE-2026-115776
+Upstream-Status: Backport [https://github.com/twisted/twisted/commit/ac90fb7b0ab73688a581fcd9a7c0577ec8ca3059]
+
+Signed-off-by: Yogita Urade <yurade@cisco.com>
+---
+ src/twisted/words/newsfragments/12770.bugfix | 1 +
+ src/twisted/words/protocols/irc.py | 21 ++++++++++++++
+ src/twisted/words/test/test_irc.py | 29 ++++++++++++++++++++
+ 3 files changed, 51 insertions(+)
+ create mode 100644 src/twisted/words/newsfragments/12770.bugfix
+
+diff --git a/src/twisted/words/newsfragments/12770.bugfix b/src/twisted/words/newsfragments/12770.bugfix
+new file mode 100644
+index 000000000..6bf3a63ee
+--- /dev/null
++++ b/src/twisted/words/newsfragments/12770.bugfix
+@@ -0,0 +1 @@
++twisted.words.protocols.irc.IRC now limits the length of a single line, so a peer can no longer exhaust server memory by sending data without a line delimiter.
+diff --git a/src/twisted/words/protocols/irc.py b/src/twisted/words/protocols/irc.py
+index 2906fa562..1123cdc4a 100644
+--- a/src/twisted/words/protocols/irc.py
++++ b/src/twisted/words/protocols/irc.py
+@@ -255,6 +255,9 @@ class IRC(protocol.Protocol):
+ """
+
+ buffer = ""
++ # Longest line accepted, matching twisted.protocols.basic.LineReceiver.
++ # An unterminated line would otherwise grow self.buffer without bound.
++ MAX_LENGTH = 16384
+ hostname = None
+
+ encoding: Optional[str] = None
+@@ -415,8 +418,15 @@ class IRC(protocol.Protocol):
+ # Put the (possibly empty) element after the last LF back in the
+ # buffer
+ self.buffer = lines.pop()
++ if len(self.buffer) > self.MAX_LENGTH:
++ # An unterminated line too long to be a valid message.
++ line, self.buffer = self.buffer, ""
++ return self.lineLengthExceeded(line)
+
+ for line in lines:
++ if len(line) > self.MAX_LENGTH:
++ self.buffer = ""
++ return self.lineLengthExceeded(line)
+ if len(line) <= 2:
+ # This is a blank line, at best.
+ continue
+@@ -429,6 +439,17 @@ class IRC(protocol.Protocol):
+
+ self.handleCommand(command, prefix, params)
+
++ def lineLengthExceeded(self, line):
++ """
++ Called when a line longer than C{MAX_LENGTH} is received. The default
++ behaviour, matching L{twisted.protocols.basic.LineReceiver}, drops the
++ connection.
++
++ @param line: The line which exceeded the length limit.
++ @type line: L{str}
++ """
++ return self.transport.loseConnection()
++
+ def handleCommand(self, command, prefix, params):
+ """
+ Determine the function to call for the given command and call it with
+diff --git a/src/twisted/words/test/test_irc.py b/src/twisted/words/test/test_irc.py
+index c30cfc522..cd400f9ed 100644
+--- a/src/twisted/words/test/test_irc.py
++++ b/src/twisted/words/test/test_irc.py
+@@ -1522,6 +1522,35 @@ class BasicServerFunctionalityTests(IRCTestCase):
+ bufferValue = bufferValue.decode("utf-8")
+ self.assertEqual(bufferValue, s)
+
++ def test_dataReceivedBoundsUnterminatedLine(self) -> None:
++ """
++ A line longer than L{irc.IRC.MAX_LENGTH} that arrives without a
++ delimiter is not buffered without bound. The buffer is cleared and the
++ connection is dropped, matching L{twisted.protocols.basic.LineReceiver}.
++ """
++ self.p.dataReceived(b"A" * (self.p.MAX_LENGTH + 1))
++ self.assertEqual(self.p.buffer, "")
++ self.assertTrue(self.t.closed)
++
++ def test_dataReceivedDropsOverlongTerminatedLine(self) -> None:
++ """
++ A delimited line longer than L{irc.IRC.MAX_LENGTH} is dropped rather
++ than dispatched.
++ """
++ self.p.dataReceived(b"A" * (self.p.MAX_LENGTH + 1) + b"\n")
++ self.assertEqual(self.p.buffer, "")
++ self.assertTrue(self.t.closed)
++
++ def test_dataReceivedAcceptsBoundedInput(self) -> None:
++ """
++ Input under the length limit is buffered normally and the connection is
++ left open.
++ """
++ self.p.dataReceived(b"\r\n")
++ self.p.dataReceived(b"AB")
++ self.assertEqual(self.p.buffer, "AB")
++ self.assertFalse(self.t.closed)
++
+ def test_sendMessage(self):
+ """
+ Passing a command and parameters to L{IRC.sendMessage} results in a
new file mode 100644
@@ -0,0 +1,79 @@
+From 01f8cff7753c1edac132380b2ea939fa6bdbab30 Mon Sep 17 00:00:00 2001
+From: arkmarta <arkadiuszmarta@proton.me>
+Date: Sat, 8 Aug 2026 08:25:06 +0200
+Subject: [PATCH] bound the IRC server line length
+
+CVE: CVE-2026-115776
+Upstream-Status: Backport [https://github.com/twisted/twisted/commit/01f8cff7753c1edac132380b2ea939fa6bdbab30]
+
+Signed-off-by: Yogita Urade <yurade@cisco.com>
+---
+ src/twisted/words/newsfragments/12770.bugfix | 2 +-
+ src/twisted/words/protocols/irc.py | 19 ++++++++++++-------
+ 2 files changed, 13 insertions(+), 8 deletions(-)
+
+diff --git a/src/twisted/words/newsfragments/12770.bugfix b/src/twisted/words/newsfragments/12770.bugfix
+index 6bf3a63ee..2a62e440f 100644
+--- a/src/twisted/words/newsfragments/12770.bugfix
++++ b/src/twisted/words/newsfragments/12770.bugfix
+@@ -1 +1 @@
+-twisted.words.protocols.irc.IRC now limits the length of a single line, so a peer can no longer exhaust server memory by sending data without a line delimiter.
++twisted.words.protocols.irc.IRC.dataReceived now limits the length of a single line, so a peer can no longer exhaust server memory by sending data without a line delimiter.
+diff --git a/src/twisted/words/protocols/irc.py b/src/twisted/words/protocols/irc.py
+index 1123cdc4a..2249edd99 100644
+--- a/src/twisted/words/protocols/irc.py
++++ b/src/twisted/words/protocols/irc.py
+@@ -252,11 +252,14 @@ def parseModes(modes, params, paramModes=("", "")):
+ class IRC(protocol.Protocol):
+ """
+ Internet Relay Chat server protocol.
++
++ @cvar MAX_LENGTH: The maximum length of a line to allow. A received line
++ longer than this drops the connection, matching
++ L{twisted.protocols.basic.LineReceiver}, so an unterminated line cannot
++ grow the buffer without bound. Default is 16384.
+ """
+
+ buffer = ""
+- # Longest line accepted, matching twisted.protocols.basic.LineReceiver.
+- # An unterminated line would otherwise grow self.buffer without bound.
+ MAX_LENGTH = 16384
+ hostname = None
+
+@@ -421,12 +424,14 @@ class IRC(protocol.Protocol):
+ if len(self.buffer) > self.MAX_LENGTH:
+ # An unterminated line too long to be a valid message.
+ line, self.buffer = self.buffer, ""
+- return self.lineLengthExceeded(line)
++ self.lineLengthExceeded(line)
++ return
+
+ for line in lines:
+ if len(line) > self.MAX_LENGTH:
+ self.buffer = ""
+- return self.lineLengthExceeded(line)
++ self.lineLengthExceeded(line)
++ return
+ if len(line) <= 2:
+ # This is a blank line, at best.
+ continue
+@@ -439,16 +444,16 @@ class IRC(protocol.Protocol):
+
+ self.handleCommand(command, prefix, params)
+
+- def lineLengthExceeded(self, line):
++ def lineLengthExceeded(self, line: str) -> None:
+ """
+ Called when a line longer than C{MAX_LENGTH} is received. The default
+ behaviour, matching L{twisted.protocols.basic.LineReceiver}, drops the
+ connection.
+
+ @param line: The line which exceeded the length limit.
+- @type line: L{str}
+ """
+- return self.transport.loseConnection()
++ assert self.transport is not None
++ self.transport.loseConnection()
+
+ def handleCommand(self, command, prefix, params):
+ """
@@ -22,6 +22,8 @@ SRC_URI += "file://CVE-2026-42304_p1.patch \
file://CVE-2026-115877_p3.patch \
file://CVE-2026-115774_p1.patch \
file://CVE-2026-115774_p2.patch \
+ file://CVE-2026-115776_p1.patch \
+ file://CVE-2026-115776_p2.patch \
"
SRC_URI[sha256sum] = "1deb272358cb6be1e3e8fc6f9c8b36f78eb0fa7c2233d2dbe11ec6fee04ea316"
This patch applies the upstream fix as referenced in [3], using the commit shown in [1]. [1] https://github.com/twisted/twisted/commit/ac90fb7b0ab73688a581fcd9a7c0577ec8ca3059 [2] https://github.com/twisted/twisted/commit/01f8cff7753c1edac132380b2ea939fa6bdbab30 [3] https://nvd.nist.gov/vuln/detail/CVE-2026-115776 Signed-off-by: Yogita Urade <yurade@cisco.com> --- .../python3-twisted/CVE-2026-115776_p1.patch | 111 ++++++++++++++++++ .../python3-twisted/CVE-2026-115776_p2.patch | 79 +++++++++++++ .../python/python3-twisted_25.5.0.bb | 2 + 3 files changed, 192 insertions(+) create mode 100644 meta-python/recipes-devtools/python/python3-twisted/CVE-2026-115776_p1.patch create mode 100644 meta-python/recipes-devtools/python/python3-twisted/CVE-2026-115776_p2.patch