new file mode 100644
@@ -0,0 +1,206 @@
+From 1ac5baa4a25023efa0856c2c4585401bf33f304b Mon Sep 17 00:00:00 2001
+From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com>
+Date: Sat, 22 Aug 2026 17:49:48 +0100
+Subject: [PATCH] [PR #13415/8c8906a1 backport][3.14] Fix oversized frames on
+ websocket messages (#13494)
+
+**This is a backport of PR #13415 as merged into master
+(8c8906a19f64e52ef6a7d44d65217eb3c5af413f).**
+
+Co-authored-by: Sam Bull <git@sambull.org>
+
+CVE: CVE-2026-128128
+Upstream-Status: Backport [https://github.com/aio-libs/aiohttp/commit/8cfbe9abe5e11b84006a10f9bdf82bf607671dab]
+
+Backport Changes:
+- Fold the frame-length range check and regression tests from upstream
+ bd89ad6704783015bc4d97dd847509023199904e so declared lengths that
+ exceed Py_ssize_t are rejected before conversion on 32-bit builds.
+- Remove decode_text arguments from the added tests because the current
+ WebSocketReader does not expose that option and always decodes text.
+- Omit CHANGES/13415.bugfix.rst, which records an upstream release note.
+
+Signed-off-by: Ashishkumar Parmar <asparmar@cisco.com>
+---
+ aiohttp/_websocket/reader_c.pxd | 4 ++
+ aiohttp/_websocket/reader_py.py | 27 ++++++++++--
+ tests/test_websocket_parser.py | 76 +++++++++++++++++++++++++++++++++
+ 3 files changed, 103 insertions(+), 4 deletions(-)
+
+diff --git a/aiohttp/_websocket/reader_c.pxd b/aiohttp/_websocket/reader_c.pxd
+index 4f8a1b2..fcb7b4d 100644
+--- a/aiohttp/_websocket/reader_c.pxd
++++ b/aiohttp/_websocket/reader_c.pxd
+@@ -8,6 +8,8 @@ cdef unsigned int READ_PAYLOAD_LENGTH
+ cdef unsigned int READ_PAYLOAD_MASK
+ cdef unsigned int READ_PAYLOAD
+
++cdef unsigned long long MAX_PAYLOAD_LEN
++
+ cdef int OP_CODE_NOT_SET
+ cdef int OP_CODE_CONTINUATION
+ cdef int OP_CODE_TEXT
+@@ -107,6 +109,8 @@ cdef class WebSocketReader:
+ has_mask=bint,
+ fin=bint,
+ had_fragments=Py_ssize_t,
++ partial_len=Py_ssize_t,
++ frame_len="unsigned long long",
+ payload_bytearray=bytearray,
+ )
+ cpdef void _feed_data(self, bytes data) except *
+diff --git a/aiohttp/_websocket/reader_py.py b/aiohttp/_websocket/reader_py.py
+index 6499fa7..e9472bd 100644
+--- a/aiohttp/_websocket/reader_py.py
++++ b/aiohttp/_websocket/reader_py.py
+@@ -2,6 +2,7 @@
+
+ import asyncio
+ import builtins
++import sys
+ from collections import deque
+ from typing import Deque, Final, Optional, Set, Tuple, Union
+
+@@ -27,6 +28,12 @@ READ_PAYLOAD_LENGTH = 2
+ READ_PAYLOAD_MASK = 3
+ READ_PAYLOAD = 4
+
++# Largest declared payload length the reader can represent: the compiled
++# reader stores it in a Py_ssize_t, which holds 2**31-1 on the 32-bit builds
++# (the win32 and armv7l wheels) and 2**63-1 everywhere else.
++# TODO: Remove when we drop 32 bit support (and from reader_c.pxd).
++MAX_PAYLOAD_LEN = sys.maxsize
++
+ WS_MSG_TYPE_BINARY = WSMsgType.BINARY
+ WS_MSG_TYPE_TEXT = WSMsgType.TEXT
+
+@@ -413,7 +420,16 @@ class WebSocketReader:
+ elif len_flag > 126:
+ if data_len - start_pos < 8:
+ break
+- self._payload_bytes_to_read = UNPACK_LEN3(data, start_pos)[0]
++ # The declared length is an unsigned 64-bit integer that
++ # does not necessarily fit _payload_bytes_to_read.
++ frame_len = UNPACK_LEN3(data, start_pos)[0]
++ if frame_len > MAX_PAYLOAD_LEN:
++ raise WebSocketError(
++ WSCloseCode.MESSAGE_TOO_BIG,
++ f"Message size {int(frame_len) + len(self._partial)} "
++ f"exceeds limit {self._max_msg_size or MAX_PAYLOAD_LEN}",
++ )
++ self._payload_bytes_to_read = frame_len
+ start_pos += 8
+ else:
+ self._payload_bytes_to_read = len_flag
+@@ -426,11 +442,14 @@ class WebSocketReader:
+ OP_CODE_BINARY,
+ OP_CODE_CONTINUATION,
+ }:
+- projected_size = self._payload_bytes_to_read + len(self._partial)
+- if projected_size >= self._max_msg_size:
++ # partial_len declared in reader_c.pxd to keep it in C.
++ partial_len = len(self._partial)
++ # payload_bytes_to_read is a signed Py_ssize_t C value,
++ # use subtraction here to avoid an integer overflow.
++ if self._payload_bytes_to_read >= self._max_msg_size - partial_len:
+ raise WebSocketError(
+ WSCloseCode.MESSAGE_TOO_BIG,
+- f"Message size {projected_size} "
++ f"Message size {int(self._payload_bytes_to_read) + partial_len} "
+ f"exceeds limit {self._max_msg_size}",
+ )
+
+diff --git a/tests/test_websocket_parser.py b/tests/test_websocket_parser.py
+index abb412b..c3ec201 100644
+--- a/tests/test_websocket_parser.py
++++ b/tests/test_websocket_parser.py
+@@ -2,6 +2,7 @@ import asyncio
+ import pickle
+ import random
+ import struct
++import sys
+ from typing import Union
+ from unittest import mock
+
+@@ -698,6 +699,81 @@ def test_msg_too_large_text_after_non_fin_text(out: WebSocketDataQueue) -> None:
+ assert ctx.value.code == WSCloseCode.MESSAGE_TOO_BIG
+
+
++def test_msg_too_large_declared_length_near_ssize_t_max(
++ out: WebSocketDataQueue,
++) -> None:
++ # Regression test: the header-time size check compares
++ # `payload_bytes_to_read + len(partial)` against max_msg_size. In the
++ # compiled Cython reader payload_bytes_to_read is a signed Py_ssize_t C
++ # value, and RFC 6455 allows a declared length up to 2**63-1, so a naive
++ # addition can wrap around to a negative number and bypass the limit
++ # entirely once anything is already buffered in `partial`.
++ max_msg_size = 4 * 1024 * 1024
++ parser = WebSocketReader(out, max_msg_size, compress=False)
++
++ # Buffer one byte in `partial` via a non-fin fragment.
++ first = build_frame(b"a", WSMsgType.TEXT, is_fin=False)
++ parser._feed_data(first)
++
++ # Continuation header alone declares the largest length RFC 6455
++ # allows: 2**63-1.
++ header = PACK_LEN3(WSMsgType.CONTINUATION, 127, 2**63 - 1)
++ with pytest.raises(
++ WebSocketError,
++ match=rf"^Message size {2**63} exceeds limit {max_msg_size}$",
++ ) as ctx:
++ parser._feed_data(header)
++ assert ctx.value.code == WSCloseCode.MESSAGE_TOO_BIG
++
++
++@pytest.mark.parametrize(
++ "declared",
++ (sys.maxsize + 1, 2**64 - 1),
++ ids=("ssize_t_max_plus_one", "uint64_max"),
++)
++@pytest.mark.parametrize(
++ "max_msg_size", (4 * 1024 * 1024, 0), ids=("bounded", "unbounded")
++)
++def test_msg_too_large_declared_length_above_ssize_t_max(
++ out: WebSocketDataQueue, max_msg_size: int, declared: int
++) -> None:
++ # RFC 6455 allows an unsigned 64-bit declared length, which does not fit
++ # the signed Py_ssize_t payload_bytes_to_read of the compiled reader:
++ # anything above sys.maxsize (2**31-1 on the 32-bit builds) has to be
++ # rejected before it is stored there, or storing it raises OverflowError
++ # and escapes as an abnormal closure instead of MESSAGE_TOO_BIG. Such a
++ # frame can never be buffered, so an unlimited max_msg_size is checked
++ # too.
++ parser = WebSocketReader(out, max_msg_size, compress=False)
++
++ header = PACK_LEN3(0x80 | WSMsgType.TEXT, 127, declared)
++ with pytest.raises(
++ WebSocketError,
++ match=rf"^Message size {declared} exceeds limit {max_msg_size or sys.maxsize}$",
++ ) as ctx:
++ parser._feed_data(header)
++ assert ctx.value.code == WSCloseCode.MESSAGE_TOO_BIG
++
++
++def test_msg_too_large_above_ssize_t_max_reports_buffered_fragments(
++ out: WebSocketDataQueue,
++) -> None:
++ # The reported size adds what is already buffered, so the message reads the
++ # same whether the declared length is caught by the Py_ssize_t range check
++ # or by the max_msg_size comparison below it.
++ max_msg_size = 4 * 1024 * 1024
++ parser = WebSocketReader(out, max_msg_size, compress=False)
++
++ parser._feed_data(build_frame(b"a", WSMsgType.TEXT, is_fin=False))
++
++ header = PACK_LEN3(WSMsgType.CONTINUATION, 127, 2**64 - 1)
++ with pytest.raises(
++ WebSocketError, match=rf"^Message size {2**64} exceeds limit {max_msg_size}$"
++ ) as ctx:
++ parser._feed_data(header)
++ assert ctx.value.code == WSCloseCode.MESSAGE_TOO_BIG
++
++
+ @pytest.mark.parametrize(
+ "opcode",
+ (0x3, 0x4, 0x5, 0x6, 0x7, 0xB, 0xC, 0xD, 0xE, 0xF),
@@ -38,6 +38,7 @@ SRC_URI += " \
file://CVE-2026-128125.patch \
file://CVE-2026-128126.patch \
file://CVE-2026-128127.patch \
+ file://CVE-2026-128128.patch \
"
CVE_PRODUCT = "aiohttp:aiohttp"