Skip to contentSkip to conversation

python3-aiohttp: Security fixes

PATCH New Darsh Kelaiya -X (dkelaiya - E INFOCHIPS PRIVATE LIMITED at Cisco) 1 participant 8 messages Nov 6

lore
Share & tools
lore
#0 lore raw

cover python3-aiohttp: Security fixes

From: Darsh Kelaiya <[email protected]>

Backport seven aiohttp security fixes to the 3.13.5 recipe on Wrynose. The series follows the upstream fix order. The fixes and included corrections are present in upstream 3.14.4.

The fixes cover multipart descriptor exhaustion, HEAD request body framing, host-only cookie scope, Max-Age overflow and response cleanup, request-scheme spoofing, Secure shared-cookie leakage, and the initial idle-connection deadline.

Include the upstream descriptor-test, authority-validation and trusted-origin corrections with their corresponding CVE fixes.

Darsh Kelaiya (7):
python3-aiohttp: fix CVE-2026-111066
python3-aiohttp: fix CVE-2026-111750
python3-aiohttp: fix CVE-2026-111749
python3-aiohttp: fix CVE-2026-111065
python3-aiohttp: fix CVE-2026-111748
python3-aiohttp: fix CVE-2026-111063
python3-aiohttp: fix CVE-2026-111064

 .../python3-aiohttp/CVE-2026-111063_p1.patch       | 137 +++++++
 .../python3-aiohttp/CVE-2026-111063_p2.patch       | 244 +++++++++++++
 .../python/python3-aiohttp/CVE-2026-111064.patch   | 285 +++++++++++++++
 .../python/python3-aiohttp/CVE-2026-111065.patch   | 176 +++++++++
 .../python3-aiohttp/CVE-2026-111066_p1.patch       | 400 +++++++++++++++++++++
 .../python3-aiohttp/CVE-2026-111066_p2.patch       |  57 +++
 .../python3-aiohttp/CVE-2026-111748_p1.patch       | 376 +++++++++++++++++++
 .../python3-aiohttp/CVE-2026-111748_p2.patch       | 282 +++++++++++++++
 .../python/python3-aiohttp/CVE-2026-111749.patch   | 205 +++++++++++
 .../python/python3-aiohttp/CVE-2026-111750.patch   |  83 +++++
 .../python/python3-aiohttp_3.13.5.bb               |  10 +
 11 files changed, 2255 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111063_p1.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111063_p2.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111064.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111065.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111066_p1.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111066_p2.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111748_p1.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111748_p2.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111749.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111750.patch
Signature · 1 line
2.35.6
#1 lore raw

PATCH 1/7 python3-aiohttp: fix CVE-2026-111066

From: Darsh Kelaiya <[email protected]>

Backport the multipart descriptor-exhaustion fix [1] to aiohttp 3.13.5. Spool small file parts in memory and count raw multipart bytes, including headers, against client_max_size.

Include the upstream descriptor-test correction [2] so unrelated file descriptors do not make the regression test unreliable. Adapt the HTTP 413 constructor and retain the existing read size. The vulnerability and fixed release are documented in [3].

[1] https://github.com/aio-libs/aiohttp/commit/2d94633b7f1b4c1ba07d647b629a8440652b2d09
[2] https://github.com/aio-libs/aiohttp/commit/011c08204197beba8281911907b59ffcecea1413
[3] https://github.com/aio-libs/aiohttp/security/advisories/GHSA-9xw5-w5jj-pvcg

---
 .../python3-aiohttp/CVE-2026-111066_p1.patch  | 400 ++++++++++++++++++
 .../python3-aiohttp/CVE-2026-111066_p2.patch  |  57 +++
 .../python/python3-aiohttp_3.13.5.bb          |   2 +
 3 files changed, 459 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111066_p1.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111066_p2.patch
meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111066_p1.patch new file +400 -0
new file mode 100644
index 0000000000..8b6e29bbfb
@@ -0,0 +1,400 @@
+From 2d94633b7f1b4c1ba07d647b629a8440652b2d09 Mon Sep 17 00:00:00 2001
+From: Sam Bull <[email protected]>
+Date: Tue, 18 Aug 2026 21:54:45 +0100
+Subject: [PATCH] Reduce number of file descriptors needed in multipart
+ messages (#13426) (#13475)
+
+(cherry picked from commit c92ed4c48dafd40d5ed4c86587af9e081ac7d971)
+
+CVE: CVE-2026-111066
+Upstream-Status: Backport [https://github.com/aio-libs/aiohttp/commit/2d94633b7f1b4c1ba07d647b629a8440652b2d09]
+
+Backport Changes:
+- Pass the raw payload size to the older HTTP 413 constructor and
+  update the existing test to match upstream's size-limit assertion.
+- Keep the existing type annotations and surrounding test signatures.
+
+Signed-off-by: Darsh Kelaiya <[email protected]>
+---
+ CHANGES/13426.bugfix.rst     |   1 +
+ aiohttp/web_request.py       |  96 +++++++++++++++-----
+ tests/test_web_functional.py | 167 ++++++++++++++++++++++++++++++++++-
+ 3 files changed, 237 insertions(+), 27 deletions(-)
+ create mode 100644 CHANGES/13426.bugfix.rst
+
+diff --git a/CHANGES/13426.bugfix.rst b/CHANGES/13426.bugfix.rst
+new file mode 100644
+index 0000000..8b9ee29
+--- /dev/null
++++ b/CHANGES/13426.bugfix.rst
+@@ -0,0 +1 @@
++Switched multipart handling to use spooled temporary files to reduce number of file descriptors needed -- by :user:`Dreamsorcerer`.
+diff --git a/aiohttp/web_request.py b/aiohttp/web_request.py
+index f2d4c51..e978b2a 100644
+--- a/aiohttp/web_request.py
++++ b/aiohttp/web_request.py
+@@ -4,11 +4,12 @@ import io
+ import re
+ import socket
+ import string
+-import tempfile
++import sys
+ import types
+ import warnings
+ from types import MappingProxyType
+ from typing import (
++    IO,
+     TYPE_CHECKING,
+     Any,
+     Dict,
+@@ -64,6 +65,30 @@ from .typedefs import (
+ from .web_exceptions import HTTPRequestEntityTooLarge
+ from .web_response import StreamResponse
+ 
++if sys.version_info >= (3, 11):
++    from tempfile import SpooledTemporaryFile
++else:
++    import tempfile
++
++    class SpooledTemporaryFile(tempfile.SpooledTemporaryFile[bytes], io.IOBase):
++        """Make the spooled file satisfy the documented `FileField.file` type.
++
++        `tempfile.SpooledTemporaryFile` only became an `io.IOBase` subclass in
++        3.11 (python/cpython#70363), and never grew the three capability
++        predicates before then. Both underlying files (`io.BytesIO` before
++        rollover, a `w+b` temp file after) are readable, writable and seekable.
++        """
++
++        def readable(self) -> bool:
++            return True
++
++        def writable(self) -> bool:
++            return True
++
++        def seekable(self) -> bool:
++            return True
++
++
+ __all__ = ("BaseRequest", "FileField", "Request")
+ 
+ 
+@@ -73,11 +98,18 @@ if TYPE_CHECKING:
+     from .web_urldispatcher import UrlMappingMatchInfo
+ 
+ 
++# Multipart file parts are buffered in memory and only spilled to a temporary
++# file once they outgrow this size. A temp file per part would let a body made
++# of many tiny parts exhaust the process's file descriptors; spooling bounds
++# that at ``client_max_size // _FILE_SPOOL_MAX_SIZE`` descriptors per request.
++_FILE_SPOOL_MAX_SIZE: Final[int] = 1024**2
++
++
+ @attr.s(auto_attribs=True, frozen=True, slots=True)
+ class FileField:
+     name: str
+     filename: str
+-    file: io.BufferedReader
++    file: IO[bytes]
+     content_type: str
+     headers: CIMultiDictProxy[str]
+ 
+@@ -726,8 +758,15 @@ class BaseRequest(MutableMapping[str, Any], HeadersMixin):
+             multipart = await self.multipart()
+             max_size = self._client_max_size
+ 
+-            size = 0
++            payload = self._payload
+             while (field := await multipart.next()) is not None:
++                # This check is needed for empty payloads, which still add
++                # overhead without entering the loop and the check below.
++                if 0 < max_size < payload.total_bytes:
++                    raise HTTPRequestEntityTooLarge(
++                        max_size=max_size, actual_size=payload.total_bytes
++                    )
++
+                 field_ct = field.headers.get(hdrs.CONTENT_TYPE)
+ 
+                 if isinstance(field, BodyPartReader):
+@@ -739,22 +778,37 @@ class BaseRequest(MutableMapping[str, Any], HeadersMixin):
+                     # present.
+                     # https://tools.ietf.org/html/rfc7578#section-4.4
+                     if field.filename:
+-                        # store file in temp file
+-                        tmp = await self._loop.run_in_executor(
+-                            None, tempfile.TemporaryFile
+-                        )
++                        tmp = SpooledTemporaryFile(_FILE_SPOOL_MAX_SIZE)
++                        # rolled means the temp file now uses the disk, at
++                        # which point we want to run in the executor.
++                        rolled = False
+                         while chunk := await field.read_chunk(size=2**18):
++                            # Bounds one part, mid-read.
++                            if 0 < max_size < payload.total_bytes:
++                                if rolled:
++                                    await self._loop.run_in_executor(None, tmp.close)
++                                else:
++                                    tmp.close()
++                                raise HTTPRequestEntityTooLarge(
++                                    max_size=max_size, actual_size=payload.total_bytes
++                                )
+                             async for decoded_chunk in field.decode_iter(chunk):
+-                                await self._loop.run_in_executor(
+-                                    None, tmp.write, decoded_chunk
++                                # Update before writing, so we know if next
++                                # write is going to hit the disk.
++                                rolled = rolled or (
++                                    tmp.tell() + len(decoded_chunk)
++                                    > _FILE_SPOOL_MAX_SIZE
+                                 )
+-                                size += len(decoded_chunk)
+-                                if 0 < max_size < size:
+-                                    await self._loop.run_in_executor(None, tmp.close)
+-                                    raise HTTPRequestEntityTooLarge(
+-                                        max_size=max_size, actual_size=size
++                                if rolled:
++                                    await self._loop.run_in_executor(
++                                        None, tmp.write, decoded_chunk
+                                     )
+-                        await self._loop.run_in_executor(None, tmp.seek, 0)
++                                else:
++                                    tmp.write(decoded_chunk)
++                        if rolled:
++                            await self._loop.run_in_executor(None, tmp.seek, 0)
++                        else:
++                            tmp.seek(0)
+ 
+                         if field_ct is None:
+                             field_ct = "application/octet-stream"
+@@ -762,7 +816,7 @@ class BaseRequest(MutableMapping[str, Any], HeadersMixin):
+                         ff = FileField(
+                             field.name,
+                             field.filename,
+-                            cast(io.BufferedReader, tmp),
++                            tmp,
+                             field_ct,
+                             field.headers,
+                         )
+@@ -771,10 +825,9 @@ class BaseRequest(MutableMapping[str, Any], HeadersMixin):
+                         # deal with ordinary data
+                         raw_data = bytearray()
+                         while chunk := await field.read_chunk():
+-                            size += len(chunk)
+-                            if 0 < max_size < size:
++                            if 0 < max_size < payload.total_bytes:
+                                 raise HTTPRequestEntityTooLarge(
+-                                    max_size=max_size, actual_size=size
++                                    max_size=max_size, actual_size=payload.total_bytes
+                                 )
+                             raw_data.extend(chunk)
+ 
+@@ -843,10 +896,7 @@ class BaseRequest(MutableMapping[str, Any], HeadersMixin):
+         if self._post is None or self.content_type != "multipart/form-data":
+             return
+ 
+-        # NOTE: Release file descriptors for the
+-        # NOTE: `tempfile.Temporaryfile`-created `_io.BufferedRandom`
+-        # NOTE: instances of files sent within multipart request body
+-        # NOTE: via HTTP POST request.
++        # Release the temp files created within multipart request body.
+         for file_name, file_field_object in self._post.items():
+             if isinstance(file_field_object, FileField):
+                 file_field_object.file.close()
+diff --git a/tests/test_web_functional.py b/tests/test_web_functional.py
+index 0d2824a..a314d9b 100644
+--- a/tests/test_web_functional.py
++++ b/tests/test_web_functional.py
+@@ -1,6 +1,8 @@
+ import asyncio
++import base64
+ import io
+ import json
++import os
+ import pathlib
+ import socket
+ import sys
+@@ -29,6 +31,7 @@ from aiohttp.pytest_plugin import AiohttpClient, AiohttpServer
+ from aiohttp.streams import StreamReader
+ from aiohttp.typedefs import Handler
+ from aiohttp.web_protocol import MAX_MSG_QUEUE_SIZE, RequestHandler
++from aiohttp.web_request import _FILE_SPOOL_MAX_SIZE
+ 
+ try:
+     import brotlicffi as brotli
+@@ -2023,10 +2026,7 @@ async def test_post_max_client_size(aiohttp_client) -> None:
+ 
+         assert 413 == resp.status
+         resp_text = await resp.text()
+-        assert (
+-            "Maximum request body size 10 exceeded, "
+-            "actual body size 1024" in resp_text
+-        )
++        assert "Maximum request body size 10 exceeded" in resp_text
+         data["file"].close()
+ 
+         await resp.release()
+@@ -2050,6 +2050,165 @@ async def test_post_max_client_size_for_file(aiohttp_client) -> None:
+     await resp.release()
+ 
+ 
++def _multipart_file_parts(count: int, body: bytes = b"") -> bytes:
++    """Raw multipart/form-data body of ``count`` file parts, boundary ``b``."""
++    return (
++        b"".join(
++            b'--b\r\nContent-Disposition: form-data; name="f%d"; '
++            b'filename="x"\r\n\r\n' % index + body + b"\r\n"
++            for index in range(count)
++        )
++        + b"--b--\r\n"
++    )
++
++
++async def test_post_max_client_size_counts_multipart_headers(
++    aiohttp_client: AiohttpClient,
++) -> None:
++    async def handler(request: web.Request) -> NoReturn:
++        await request.post()
++        assert False
++
++    app = web.Application(client_max_size=1)
++    app.router.add_post("/", handler)
++    client = await aiohttp_client(app)
++
++    body = _multipart_file_parts(55)
++    assert len(body) > 1
++    async with client.post(
++        "/", data=body, headers={CONTENT_TYPE: "multipart/form-data; boundary=b"}
++    ) as resp:
++        assert resp.status == 413
++
++
[email protected](
++    "max_size",
++    (_FILE_SPOOL_MAX_SIZE, 2 * _FILE_SPOOL_MAX_SIZE),
++    ids=("spooled", "rolled-over"),
++)
++async def test_post_max_client_size_within_single_part(
++    aiohttp_client: AiohttpClient, max_size: int
++) -> None:
++    async def handler(request: web.Request) -> NoReturn:
++        await request.post()
++        assert False
++
++    app = web.Application(client_max_size=max_size)
++    app.router.add_post("/", handler)
++    client = await aiohttp_client(app)
++
++    # A sole oversized part is never followed by a boundary, so only the
++    # per-chunk check can reject it, and it must do so before buffering. The
++    # larger limit lets the part reach the disk first, so the spool is then
++    # closed off the event loop too.
++    data = FormData()
++    with io.BytesIO(b"x" * (3 * _FILE_SPOOL_MAX_SIZE)) as file_handle:
++        data.add_field("file", file_handle, filename="x.bin")
++        async with client.post("/", data=data) as resp:
++            assert resp.status == 413
++
++
[email protected]("filename", (b"", b'; filename="x"'), ids=("field", "file"))
++async def test_post_max_client_size_counts_undecoded_bytes(
++    aiohttp_client: AiohttpClient, filename: bytes
++) -> None:
++    async def handler(request: web.Request) -> NoReturn:
++        await request.post()
++        assert False
++
++    limit = 64 * 1024
++    app = web.Application(client_max_size=limit)
++    app.router.add_post("/", handler)
++    client = await aiohttp_client(app)
++
++    # base64 decodes to exactly the limit but arrives 4/3 larger. The limit is
++    # on the request body, so both kinds of part must reject it alike.
++    encoded = base64.b64encode(b"A" * limit)
++    assert len(encoded) > limit
++    body = (
++        b'--b\r\nContent-Disposition: form-data; name="f"' + filename + b"\r\n"
++        b"Content-Transfer-Encoding: base64\r\n\r\n" + encoded + b"\r\n--b--\r\n"
++    )
++    async with client.post(
++        "/", data=body, headers={CONTENT_TYPE: "multipart/form-data; boundary=b"}
++    ) as resp:
++        assert resp.status == 413
++
++
[email protected](not os.path.isdir("/dev/fd"), reason="needs /dev/fd to count fds")
[email protected](
++    ("parts", "part_body", "expected_fds"),
++    (
++        (55, b"payload", 0),
++        (1, b"x" * (_FILE_SPOOL_MAX_SIZE + 1), 1),
++    ),
++    ids=("many-small-parts", "one-oversized-part"),
++)
++async def test_post_file_fields_descriptor_cost(
++    aiohttp_client: AiohttpClient, parts: int, part_body: bytes, expected_fds: int
++) -> None:
++    """Only a part past the spool size may cost a descriptor."""
++
++    async def handler(request: web.Request) -> web.Response:
++        before = set(await asyncio.to_thread(os.listdir, "/dev/fd"))
++        data = await request.post()
++        after = set(await asyncio.to_thread(os.listdir, "/dev/fd"))
++        assert len(data) == parts
++        return web.Response(text=str(len(after - before)))
++
++    app = web.Application(client_max_size=8 * 1024**2)
++    app.router.add_post("/", handler)
++    client = await aiohttp_client(app)
++
++    with io.BytesIO(_multipart_file_parts(parts, part_body)) as body:
++        async with client.post(
++            "/",
++            data=body,
++            headers={CONTENT_TYPE: "multipart/form-data; boundary=b"},
++        ) as resp:
++            assert resp.status == 200
++            assert await resp.text() == str(expected_fds)
++
++
[email protected](
++    "size",
++    (
++        0,
++        1,
++        _FILE_SPOOL_MAX_SIZE - 1,
++        _FILE_SPOOL_MAX_SIZE,
++        _FILE_SPOOL_MAX_SIZE + 1,
++    ),
++)
++async def test_post_file_field_spool_rollover(
++    aiohttp_client: AiohttpClient, size: int
++) -> None:
++    """A part is byte-identical either side of the spool/temp-file boundary."""
++    payload = (b"0123456789abcdef" * (size // 16 + 1))[:size]
++
++    async def handler(request: web.Request) -> web.Response:
++        field = (await request.post())["file"]
++        assert isinstance(field, aiohttp.web_request.FileField)
++        assert isinstance(field.file, io.IOBase)
++        assert field.file.readable()
++        assert field.file.writable()
++        assert field.file.seekable()
++        content = await asyncio.to_thread(field.file.read)
++        assert len(content) == size
++        assert content == payload
++        return web.Response()
++
++    app = web.Application(client_max_size=8 * 1024**2)
++    app.router.add_post("/", handler)
++    client = await aiohttp_client(app)
++
++    data = FormData()
++    with io.BytesIO(payload) as file_handle:
++        data.add_field("file", file_handle, filename="x.bin")
++        async with client.post("/", data=data) as resp:
++            assert resp.status == 200
++
++
+ async def test_response_with_bodypart(aiohttp_client) -> None:
+     async def handler(request):
+         reader = await request.multipart()
meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111066_p2.patch new file +57 -0

57 lines not on this page · raw message

meta-python/recipes-devtools/python/python3-aiohttp_3.13.5.bb +2 -0
index bd5b5fe4d9..917405c715 100644
@@ -22,6 +22,8 @@ SRC_URI += " \
     file://CVE-2026-59881.patch \
     file://CVE-2026-69243.patch \
     file://CVE-2026-69244.patch \
+    file://CVE-2026-111066_p1.patch \
+    file://CVE-2026-111066_p2.patch \
 "
 
 CVE_PRODUCT = "aiohttp:aiohttp"
Signature · 1 line
2.35.6
#2 lore raw

PATCH 2/7 python3-aiohttp: fix CVE-2026-111750

In reply to Darsh Kelaiya -X (dkelaiya - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Darsh Kelaiya <[email protected]>

Backport the upstream HEAD request parsing fix [1] to aiohttp 3.13.5, as identified by [2]. Only responses to HEAD may skip their body; incoming HEAD requests must consume the declared request body.

Retain the upstream regression that embeds a request in a HEAD body and verifies that the following request remains correctly framed. The pure-Python parser remains available with extensions installed.

[1] https://github.com/aio-libs/aiohttp/commit/9b27347e61454d9f8ca2055f4c67a37dee336e83
[2] https://github.com/aio-libs/aiohttp/security/advisories/GHSA-pqxq-w44r-73xw

---
 .../python3-aiohttp/CVE-2026-111750.patch     | 83 +++++++++++++++++++
 .../python/python3-aiohttp_3.13.5.bb          |  1 +
 2 files changed, 84 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111750.patch
meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111750.patch new file +83 -0
new file mode 100644
index 0000000000..61498e09f3
@@ -0,0 +1,83 @@
+From 9b27347e61454d9f8ca2055f4c67a37dee336e83 Mon Sep 17 00:00:00 2001
+From: Sam Bull <[email protected]>
+Date: Wed, 9 Sep 2026 01:25:13 +0100
+Subject: [PATCH] Fix head request parsing (#13671) (#13673)
+
+(cherry picked from commit 5789546e37fe35af27d0a2f840870b22bc15bfc4)
+
+CVE: CVE-2026-111750
+Upstream-Status: Backport [https://github.com/aio-libs/aiohttp/commit/9b27347e61454d9f8ca2055f4c67a37dee336e83]
+
+Signed-off-by: Darsh Kelaiya <[email protected]>
+---
+ CHANGES/13671.bugfix.rst  |  1 +
+ aiohttp/http_parser.py    |  6 +++++-
+ tests/test_http_parser.py | 27 ++++++++++++++++++++++++++-
+ 3 files changed, 32 insertions(+), 2 deletions(-)
+ create mode 100644 CHANGES/13671.bugfix.rst
+
+diff --git a/CHANGES/13671.bugfix.rst b/CHANGES/13671.bugfix.rst
+new file mode 100644
+index 0000000..e6fbc70
+--- /dev/null
++++ b/CHANGES/13671.bugfix.rst
+@@ -0,0 +1 @@
++Fixed pure-Python request parser not reading a body in a ``HEAD`` request -- by :user:`Dreamsorcerer`.
+diff --git a/aiohttp/http_parser.py b/aiohttp/http_parser.py
+index f4458dc..ce15764 100644
+--- a/aiohttp/http_parser.py
++++ b/aiohttp/http_parser.py
+@@ -426,8 +426,12 @@ class HttpParser(abc.ABC, Generic[_MsgT]):
+ 
+                         assert self.protocol is not None
+                         # calculate payload
++                        # https://www.rfc-editor.org/info/rfc9112/#name-message-body-length
++                        # https://www.rfc-editor.org/info/rfc9110/#section-9.3.1-6
++                        # EMPTY_BODY_METHODS should only apply to responses.
++                        # self.method is None on request parser.
+                         empty_body = code in EMPTY_BODY_STATUS_CODES or bool(
+-                            method and method in EMPTY_BODY_METHODS
++                            self.method and self.method in EMPTY_BODY_METHODS
+                         )
+                         if not empty_body and (
+                             (length is not None and length > 0) or msg.chunked
+diff --git a/tests/test_http_parser.py b/tests/test_http_parser.py
+index 4cdd94c..4255f4d 100644
+--- a/tests/test_http_parser.py
++++ b/tests/test_http_parser.py
+@@ -1781,7 +1781,32 @@ def test_http_request_chunked_payload_and_next_message(parser) -> None:
+     assert not payload2.is_eof()
+ 
+ 
+-def test_http_request_chunked_payload_chunks(parser) -> None:
++def test_http_request_parser_head_with_content_length_payload(
++    parser: HttpRequestParser,
++) -> None:
++    smuggled = b"GET /smuggled HTTP/1.1\r\nHost: a\r\n\r\n"
++    text = (
++        b"HEAD /test HTTP/1.1\r\nHost: a\r\nContent-Length: %d\r\n\r\n" % len(smuggled)
++        + smuggled
++        + b"POST /next HTTP/1.1\r\nHost: a\r\nContent-Length: 0\r\n\r\n"
++    )
++    messages, upgraded, tail = parser.feed_data(text)
++
++    assert len(messages) == 2
++    msg, payload = messages[0]
++    assert msg.method == "HEAD"
++    assert b"".join(payload._buffer) == smuggled
++    assert payload.is_eof()
++
++    msg2, payload2 = messages[1]
++    assert msg2.method == "POST"
++    assert msg2.path == "/next"
++    assert payload2.is_eof()
++    assert not upgraded
++    assert not tail
++
++
++def test_http_request_chunked_payload_chunks(parser: HttpRequestParser) -> None:
+     text = b"GET /test HTTP/1.1\r\ntransfer-encoding: chunked\r\n\r\n"
+     msg, payload = parser.feed_data(text)[0][0]
+ 
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-aiohttp_3.13.5.bb +1 -0
index 917405c715..40ac847c01 100644
@@ -24,6 +24,7 @@ SRC_URI += " \
     file://CVE-2026-69244.patch \
     file://CVE-2026-111066_p1.patch \
     file://CVE-2026-111066_p2.patch \
+    file://CVE-2026-111750.patch \
 "
 
 CVE_PRODUCT = "aiohttp:aiohttp"
Signature · 1 line
2.35.6
#3 lore raw

PATCH 3/7 python3-aiohttp: fix CVE-2026-111749

In reply to Darsh Kelaiya -X (dkelaiya - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Darsh Kelaiya <[email protected]>

Backport the upstream host-only cookie state fix [1] to aiohttp 3.13.5, as identified by [2]. Track host-only state by domain, path and name so expiring another cookie cannot widen its domain scope.

Preserve this identity during filtering, replacement and JSON persistence. Adapt regression assertions to the existing private state because 3.13.5 lacks the newer public inspection property.

[1] https://github.com/aio-libs/aiohttp/commit/6a07c171ef9f3be583e2907dcd1931372efca8d6
[2] https://github.com/aio-libs/aiohttp/security/advisories/GHSA-gx76-c99x-2c96

---
 .../python3-aiohttp/CVE-2026-111749.patch     | 205 ++++++++++++++++++
 .../python/python3-aiohttp_3.13.5.bb          |   1 +
 2 files changed, 206 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111749.patch
meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111749.patch new file +205 -0
new file mode 100644
index 0000000000..475229e180
@@ -0,0 +1,205 @@
+From 6a07c171ef9f3be583e2907dcd1931372efca8d6 Mon Sep 17 00:00:00 2001
+From: Sam Bull <[email protected]>
+Date: Wed, 9 Sep 2026 02:21:06 +0100
+Subject: [PATCH] Fix host-only state on cookie expiration (#13674) (#13676)
+
+(cherry picked from commit 9332972cfcb0f5a2b6677e7307819ab8f13b5d09)
+
+CVE: CVE-2026-111749
+Upstream-Status: Backport [https://github.com/aio-libs/aiohttp/commit/6a07c171ef9f3be583e2907dcd1931372efca8d6]
+
+Backport Changes:
+- Refresh the runtime hunks for aiohttp 3.13.5 and its existing
+  JSON cookie persistence backport; retain Set/Tuple type spelling.
+- Omit annotation changes for the public host_only_cookies property
+  in CookieJar, DummyCookieJar, AbstractCookieJar and the test jar.
+  That property and its documentation were introduced in 3.14.
+- Omit the absent public-property test update and use private
+  _host_only_cookies assertions in the regression and JSON tests.
+  Adapt both existing JSON scope assertions to the private state.
+
+Signed-off-by: Darsh Kelaiya <[email protected]>
+---
+ CHANGES/13674.bugfix.rst |  1 +
+ aiohttp/cookiejar.py     | 25 +++++++++-------
+ tests/test_cookiejar.py  | 64 ++++++++++++++++++++++++++++++++++++++--
+ 3 files changed, 77 insertions(+), 13 deletions(-)
+ create mode 100644 CHANGES/13674.bugfix.rst
+
+diff --git a/CHANGES/13674.bugfix.rst b/CHANGES/13674.bugfix.rst
+new file mode 100644
+index 0000000..5152bce
+--- /dev/null
++++ b/CHANGES/13674.bugfix.rst
+@@ -0,0 +1 @@
++Fixed host-only cookie state being lost on expiration -- by :user:`Dreamsorcerer`.
+diff --git a/aiohttp/cookiejar.py b/aiohttp/cookiejar.py
+index b07d1fd..c5e5b09 100644
+--- a/aiohttp/cookiejar.py
++++ b/aiohttp/cookiejar.py
+@@ -139,7 +139,8 @@ class CookieJar(AbstractCookieJar):
+         self._morsel_cache: DefaultDict[Tuple[str, str], Dict[str, Morsel[str]]] = (
+             defaultdict(dict)
+         )
+-        self._host_only_cookies: Set[Tuple[str, str]] = set()
++        # Cookie identity is (domain, path, name).
++        self._host_only_cookies: Set[Tuple[str, str, str]] = set()
+         self._unsafe = unsafe
+         self._quote_cookie = quote_cookie
+         if treat_as_secure_origin is None:
+@@ -186,7 +187,7 @@ class CookieJar(AbstractCookieJar):
+                     if attr_val:
+                         morsel_data[attr] = attr_val
+                 # Persist or it reloads as a domain cookie and leaks to subdomains.
+-                if (domain, name) in self._host_only_cookies:
++                if (domain, path, name) in self._host_only_cookies:
+                     morsel_data["host_only"] = True
+                 if (exp := self._expirations.get((domain, path, name))) is not None:
+                     morsel_data["expires_timestamp"] = exp
+@@ -340,7 +341,7 @@ class CookieJar(AbstractCookieJar):
+ 
+     def _delete_cookies(self, to_del: List[Tuple[str, str, str]]) -> None:
+         for domain, path, name in to_del:
+-            self._host_only_cookies.discard((domain, name))
++            self._host_only_cookies.discard((domain, path, name))
+             self._cookies[(domain, path)].pop(name, None)
+             self._morsel_cache[(domain, path)].pop(name, None)
+             self._expirations.pop((domain, path, name), None)
+@@ -377,18 +378,12 @@ class CookieJar(AbstractCookieJar):
+                 domain = ""
+                 del cookie["domain"]
+ 
+-            if not domain and hostname is not None:
+-                # Set the cookie's domain to the response hostname
+-                # and set its host-only-flag
+-                self._host_only_cookies.add((hostname, name))
+-                domain = cookie["domain"] = hostname
+-
+             if domain and domain[0] == ".":
+                 # Remove leading dot
+                 domain = domain[1:]
+                 cookie["domain"] = domain
+ 
+-            if hostname and not self._is_domain_match(domain, hostname):
++            if domain and hostname and not self._is_domain_match(domain, hostname):
+                 # Setting cookies for different domains is not allowed
+                 continue
+ 
+@@ -404,6 +399,14 @@ class CookieJar(AbstractCookieJar):
+                 cookie["path"] = path
+             path = path.rstrip("/")
+ 
++            if not domain and hostname is not None:
++                self._host_only_cookies.add((hostname, path, name))
++                domain = cookie["domain"] = hostname
++            else:
++                # A cookie with an explicit Domain attribute replaces any
++                # host-only cookie with the same (domain, path, name) identity.
++                self._host_only_cookies.discard((domain, path, name))
++
+             if max_age := cookie["max-age"]:
+                 try:
+                     delta_seconds = int(max_age)
+@@ -493,7 +496,7 @@ class CookieJar(AbstractCookieJar):
+             for name, cookie in self._cookies[p].items():
+                 domain = cookie["domain"]
+ 
+-                if (domain, name) in self._host_only_cookies and domain != hostname:
++                if domain != hostname and p + (name,) in self._host_only_cookies:
+                     continue
+ 
+                 # Skip edge case when the cookie has a trailing slash but request doesn't.
+diff --git a/tests/test_cookiejar.py b/tests/test_cookiejar.py
+index ba7ee32..f82861e 100644
+--- a/tests/test_cookiejar.py
++++ b/tests/test_cookiejar.py
+@@ -1625,6 +1625,44 @@ async def test_shared_cookie_with_multiple_domains() -> None:
+     assert "universal" in jar._morsel_cache[("", "")]
+ 
+ 
++async def test_host_only_marker_survives_same_name_expiry_on_other_path() -> None:
++    """Expiring a same-name cookie on another path must not clear host-only state."""
++    jar = CookieJar()
++    origin = URL("http://auth.example.com/")
++    subdomain = URL("http://evil.auth.example.com/")
++
++    jar.update_cookies_from_headers(["sid=secret; Path=/"], origin)
++    assert "sid" not in jar.filter_cookies(subdomain)
++
++    # Attacker-controlled descendant expires a same-name cookie on its own path.
++    jar.update_cookies_from_headers(
++        ["sid=gone; Domain=auth.example.com; Path=/attacker; Max-Age=0"],
++        subdomain,
++    )
++
++    assert ("auth.example.com", "", "sid") in jar._host_only_cookies
++    assert "sid" not in jar.filter_cookies(subdomain)
++    assert jar.filter_cookies(origin)["sid"].value == "secret"
++
++
++async def test_explicit_domain_replacement_clears_host_only_marker() -> None:
++    """A replacing cookie with an explicit Domain is a domain cookie."""
++    jar = CookieJar()
++    origin = URL("http://example.com/")
++    subdomain = URL("http://sub.example.com/")
++
++    jar.update_cookies_from_headers(["sid=hostonly; Path=/"], origin)
++    assert ("example.com", "", "sid") in jar._host_only_cookies
++    assert "sid" not in jar.filter_cookies(subdomain)
++
++    jar.update_cookies_from_headers(
++        ["sid=domainwide; Domain=example.com; Path=/"], origin
++    )
++
++    assert jar._host_only_cookies == set()
++    assert jar.filter_cookies(subdomain)["sid"].value == "domainwide"
++
++
+ # === Security tests for restricted unpickler and JSON save/load ===
+ 
+ 
+@@ -1775,7 +1813,7 @@ async def test_save_load_json_preserves_host_only_scope(tmp_path: Path) -> None:
+     jar_load = CookieJar()
+     jar_load.load(file_path=file_path)
+ 
+-    assert jar_load.host_only_cookies == frozenset({("auth.example.com", "sid")})
++    assert jar_load._host_only_cookies == {("auth.example.com", "", "sid")}
+     assert "sid" not in jar_load.filter_cookies(subdomain)
+     assert "sid" in jar_load.filter_cookies(issuer)
+ 
+@@ -1796,10 +1834,32 @@ async def test_save_load_json_domain_cookie_still_matches_subdomain(
+     jar_load = CookieJar()
+     jar_load.load(file_path=file_path)
+ 
+-    assert jar_load.host_only_cookies == frozenset()
++    assert jar_load._host_only_cookies == set()
+     assert "sid" in jar_load.filter_cookies(subdomain)
+ 
+ 
++async def test_save_load_json_host_only_per_path(tmp_path: Path) -> None:
++    """Verify save/load keeps host-only state per (domain, path, name)."""
++    file_path = tmp_path / "per_path.json"
++    origin = URL("https://example.com/")
++    subdomain = URL("https://sub.example.com/")
++
++    jar_save = CookieJar()
++    jar_save.update_cookies_from_headers(
++        ["sid=hostonly; Path=/", "sid=domainwide; Domain=example.com; Path=/api"],
++        origin,
++    )
++    jar_save.save(file_path=file_path)
++
++    jar_load = CookieJar()
++    jar_load.load(file_path=file_path)
++
++    assert jar_load._host_only_cookies == {("example.com", "", "sid")}
++    assert "sid" not in jar_load.filter_cookies(subdomain)
++    filtered = jar_load.filter_cookies(URL("https://sub.example.com/api/x"))
++    assert filtered["sid"].value == "domainwide"
++
++
+ async def test_save_load_json_preserves_max_age_deadline(tmp_path: Path) -> None:
+     """Verify save/load restores the absolute deadline without resetting it."""
+     file_path = tmp_path / "max_age.json"
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-aiohttp_3.13.5.bb +1 -0
index 40ac847c01..17398ab323 100644
@@ -25,6 +25,7 @@ SRC_URI += " \
     file://CVE-2026-111066_p1.patch \
     file://CVE-2026-111066_p2.patch \
     file://CVE-2026-111750.patch \
+    file://CVE-2026-111749.patch \
 "
 
 CVE_PRODUCT = "aiohttp:aiohttp"
Signature · 1 line
2.35.6
#4 lore raw

PATCH 4/7 python3-aiohttp: fix CVE-2026-111065

In reply to Darsh Kelaiya -X (dkelaiya - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Darsh Kelaiya <[email protected]>

Backport the upstream cookie overflow and response cleanup fix [1] to aiohttp 3.13.5, as identified by [2]. Clamp positive Max-Age values before float conversion and expire nonpositive values immediately.

Close a received response if subsequent processing fails so a malformed cookie cannot exhaust the connection pool. Include the upstream extreme Max-Age and connection-release regression tests. Adapt the response annotation and imports to the existing code.

[1] https://github.com/aio-libs/aiohttp/commit/9dd8eaf4e31f1237ef2c1574a8c82a739fca5805
[2] https://github.com/aio-libs/aiohttp/security/advisories/GHSA-6cjc-53gc-5rqm

---
 .../python3-aiohttp/CVE-2026-111065.patch     | 176 ++++++++++++++++++
 .../python/python3-aiohttp_3.13.5.bb          |   1 +
 2 files changed, 177 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111065.patch
meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111065.patch new file +176 -0
new file mode 100644
index 0000000000..5ee6a44dff
@@ -0,0 +1,176 @@
+From 9dd8eaf4e31f1237ef2c1574a8c82a739fca5805 Mon Sep 17 00:00:00 2001
+From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com>
+Date: Wed, 9 Sep 2026 14:43:30 +0100
+Subject: [PATCH] [PR #13677/9e08ba02 backport][3.14] Fix cookie overflow
+ (#13679)
+
+**This is a backport of PR #13677 as merged into master
+(9e08ba02abe573ce9e4cc541d4e3c3646adb43a7).**
+
+---------
+
+Co-authored-by: Sam Bull <[email protected]>
+
+CVE: CVE-2026-111065
+Upstream-Status: Backport [https://github.com/aio-libs/aiohttp/commit/9dd8eaf4e31f1237ef2c1574a8c82a739fca5805]
+
+Backport Changes:
+- Use the existing Optional type spelling for the response variable.
+- Add Sequence to the existing typing imports for the regression test.
+
+Signed-off-by: Darsh Kelaiya <[email protected]>
+---
+ CHANGES/13677.bugfix.rst        |  1 +
+ aiohttp/client.py               |  5 ++++
+ aiohttp/cookiejar.py            | 10 +++++++-
+ tests/test_client_functional.py | 45 +++++++++++++++++++++++++++++++++
+ tests/test_cookiejar.py         | 22 ++++++++++++++++
+ 5 files changed, 82 insertions(+), 1 deletion(-)
+ create mode 100644 CHANGES/13677.bugfix.rst
+
+diff --git a/CHANGES/13677.bugfix.rst b/CHANGES/13677.bugfix.rst
+new file mode 100644
+index 0000000..bea67cb
+--- /dev/null
++++ b/CHANGES/13677.bugfix.rst
+@@ -0,0 +1 @@
++Fixed a possible ``OverflowError`` on cookies and a connection not being closed properly -- by :user:`Dreamsorcerer`.
+diff --git a/aiohttp/client.py b/aiohttp/client.py
+index 8cd9add..f404b55 100644
+--- a/aiohttp/client.py
++++ b/aiohttp/client.py
+@@ -628,6 +628,7 @@ class ClientSession:
+             await trace.send_request_start(method, url.update_query(params), headers)
+ 
+         timer = tm.timer()
++        resp: Optional[ClientResponse] = None
+         try:
+             with timer:
+                 # https://www.rfc-editor.org/rfc/rfc9112.html#name-retrying-requests
+@@ -939,6 +940,10 @@ class ClientSession:
+                 handle.cancel()
+                 handle = None
+ 
++            if resp is not None:
++                # A failure occurred after the response was received.
++                resp.close()
++
+             for trace in traces:
+                 await trace.send_request_exception(
+                     method, url.update_query(params), headers, e
+diff --git a/aiohttp/cookiejar.py b/aiohttp/cookiejar.py
+index c5e5b09..6712b90 100644
+--- a/aiohttp/cookiejar.py
++++ b/aiohttp/cookiejar.py
+@@ -410,7 +410,15 @@ class CookieJar(AbstractCookieJar):
+             if max_age := cookie["max-age"]:
+                 try:
+                     delta_seconds = int(max_age)
+-                    max_age_expiration = min(time.time() + delta_seconds, self.MAX_TIME)
++                    # https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.2
++                    if delta_seconds <= 0:
++                        max_age_expiration = 0.0
++                    else:
++                        # Cap first to protect against OverflowError on next line.
++                        delta_seconds = min(delta_seconds, self.MAX_TIME)
++                        max_age_expiration = min(
++                            time.time() + delta_seconds, self.MAX_TIME
++                        )
+                     self._expire_cookie(max_age_expiration, domain, path, name)
+                 except ValueError:
+                     cookie["max-age"] = ""
+diff --git a/tests/test_client_functional.py b/tests/test_client_functional.py
+index 60caf6e..3415b83 100644
+--- a/tests/test_client_functional.py
++++ b/tests/test_client_functional.py
+@@ -23,6 +23,7 @@ from typing import (
+     List,
+     NoReturn,
+     Optional,
++    Sequence,
+     Type,
+ )
+ from unittest import mock
+@@ -2978,6 +2979,50 @@ async def test_set_cookies_max_age_overflow(aiohttp_client) -> None:
+                 assert int(cookie["max-age"]) == int(overflow)
+ 
+ 
++async def test_connection_released_when_cookie_processing_fails(
++    aiohttp_client: AiohttpClient,
++) -> None:
++    class EvilJar(aiohttp.CookieJar):
++        def update_cookies_from_headers(
++            self, headers: Sequence[str], response_url: URL
++        ) -> None:
++            raise RuntimeError("boom")
++
++    hold = asyncio.Event()
++
++    async def hostile(request: web.Request) -> web.StreamResponse:
++        ret = web.StreamResponse()
++        ret.content_length = 2
++        ret.set_cookie("sid", "x")
++        await ret.prepare(request)
++        await ret.write(b"x")
++        await hold.wait()
++        assert False
++
++    async def clean(request: web.Request) -> web.Response:
++        return web.Response()
++
++    app = web.Application()
++    app.router.add_get("/hostile", hostile)
++    app.router.add_get("/clean", clean)
++    connector = aiohttp.TCPConnector(limit=1)
++    client = await aiohttp_client(app, connector=connector, cookie_jar=EvilJar())
++
++    try:
++        for _ in range(2):
++            with pytest.raises(RuntimeError, match="boom") as excinfo:
++                await client.get("/hostile")
++            assert not connector._acquired
++            del excinfo
++
++        # The single connector slot is free again: an unaffected request
++        # succeeds instead of waiting forever for a connection.
++        async with client.get("/clean") as resp:
++            assert resp.status == 200
++    finally:
++        hold.set()
++
++
+ async def test_request_conn_error() -> None:
+     client = aiohttp.ClientSession()
+     with pytest.raises(aiohttp.ClientConnectionError):
+diff --git a/tests/test_cookiejar.py b/tests/test_cookiejar.py
+index 5779df9..f3719a7 100644
+--- a/tests/test_cookiejar.py
++++ b/tests/test_cookiejar.py
+@@ -2005,3 +2005,25 @@ async def test_save_load_json_secure_cookies(tmp_path: Path) -> None:
+     assert cookie["secure"] is True
+     assert cookie["httponly"] is True
+     assert cookie["domain"] == "example.com"
++
++
++async def test_update_cookies_max_age_beyond_float_range_is_clamped() -> None:
++    """A hostile Max-Age larger than float max must clamp, not raise OverflowError."""
++    url = URL("https://example.com/")
++    jar = CookieJar()
++
++    jar.update_cookies_from_headers([f"sid=x; Max-Age={'9' * 309}"], url)
++
++    assert "sid" in jar.filter_cookies(url)
++    assert jar._expirations[("example.com", "", "sid")] == CookieJar.MAX_TIME
++
++
++async def test_update_cookies_negative_max_age_beyond_float_range_expires() -> None:
++    """A negative Max-Age below float min must expire the cookie, not raise."""
++    url = URL("https://example.com/")
++    jar = CookieJar()
++
++    jar.update_cookies_from_headers([f"sid=x; Max-Age=-{'9' * 309}"], url)
++
++    assert "sid" not in jar.filter_cookies(url)
++    assert len(jar) == 0
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-aiohttp_3.13.5.bb +1 -0
index 17398ab323..e2ac1eda3a 100644
@@ -26,6 +26,7 @@ SRC_URI += " \
     file://CVE-2026-111066_p2.patch \
     file://CVE-2026-111750.patch \
     file://CVE-2026-111749.patch \
+    file://CVE-2026-111065.patch \
 "
 
 CVE_PRODUCT = "aiohttp:aiohttp"
Signature · 1 line
2.35.6
#5 lore raw

PATCH 5/7 python3-aiohttp: fix CVE-2026-111748

In reply to Darsh Kelaiya -X (dkelaiya - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Darsh Kelaiya <[email protected]>

Backport the protocol-scheme fix [1] to aiohttp 3.13.5, as identified by [3]. Derive Request.scheme from the transport rather than the untrusted scheme in an absolute-form request target.

Include the authority-validation correction [2] to reject malformed targets before URL parsing, independently of yarl normalization. Retain the upstream parser and request regressions, adapted to the existing transport-test interface. The recipe regenerates the C parser from the patched Cython source.

[1] https://github.com/aio-libs/aiohttp/commit/6d4e7b01f9b951aa084a75d7356e907d4ee80411
[2] https://github.com/aio-libs/aiohttp/commit/186065caf37d5999e91fd3d4ddfd03b43eb08801
[3] https://github.com/aio-libs/aiohttp/security/advisories/GHSA-f9xw-jh8m-3mwq

---
 .../python3-aiohttp/CVE-2026-111748_p1.patch  | 376 ++++++++++++++++++
 .../python3-aiohttp/CVE-2026-111748_p2.patch  | 282 +++++++++++++
 .../python/python3-aiohttp_3.13.5.bb          |   2 +
 3 files changed, 660 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111748_p1.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111748_p2.patch
meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111748_p1.patch new file +376 -0
new file mode 100644
index 0000000000..30dd8e2b48
@@ -0,0 +1,376 @@
+From 6d4e7b01f9b951aa084a75d7356e907d4ee80411 Mon Sep 17 00:00:00 2001
+From: Sam Bull <[email protected]>
+Date: Sun, 27 Sep 2026 18:11:00 +0100
+Subject: [PATCH] Use protocol scheme for absolute-form requests (#13821)
+ (#13827) (#13828)
+
+(cherry picked from commit a921cfd0fec28d5a9e5bf8d6f4372b8fa63c49df)
+(cherry picked from commit 93d91e37e7c6035d09e89646b3de737735ed91b5)
+
+CVE: CVE-2026-111748
+Upstream-Status: Backport [https://github.com/aio-libs/aiohttp/commit/6d4e7b01f9b951aa084a75d7356e907d4ee80411]
+
+Backport Changes:
+- Omit the enum declaration hunk: HTTP_OPTIONS is already declared.
+- Adapt the request-test imports and constructor helper to 3.13.5;
+  omit newer transport mock attributes absent from RequestHandler.
+- Retain the existing surrounding parser-test type annotation.
+
+Signed-off-by: Darsh Kelaiya <[email protected]>
+---
+ CHANGES/13821.bugfix.rst     |  1 +
+ aiohttp/_http_parser.pyx     | 29 +++++++++++++++---
+ aiohttp/http_parser.py       | 26 +++++++++++++---
+ aiohttp/web_request.py       |  7 ++++-
+ tests/test_http_parser.py    | 59 ++++++++++++++++++++++++++++++++++++
+ tests/test_web_functional.py | 46 ++++++++++++++++++++++++++--
+ tests/test_web_request.py    | 43 +++++++++++++++++++-------
+ 7 files changed, 189 insertions(+), 22 deletions(-)
+ create mode 100644 CHANGES/13821.bugfix.rst
+
+diff --git a/CHANGES/13821.bugfix.rst b/CHANGES/13821.bugfix.rst
+new file mode 100644
+index 0000000..f35418d
+--- /dev/null
++++ b/CHANGES/13821.bugfix.rst
+@@ -0,0 +1 @@
++Fixed the web server trusting the scheme of an absolute-form request-target -- by :user:`Dreamsorcerer`.
+diff --git a/aiohttp/_http_parser.pyx b/aiohttp/_http_parser.pyx
+index ffbd53f..4390253 100644
+--- a/aiohttp/_http_parser.pyx
++++ b/aiohttp/_http_parser.pyx
+@@ -669,12 +669,20 @@ cdef class HttpRequestParser(HttpParser):
+             return
+         self._path = self._buf.decode('utf-8', 'surrogateescape')
+         try:
+-            idx3 = len(self._path)
+             if self._cparser.method == cparser.HTTP_CONNECT:
+                 # authority-form,
+                 # https://datatracker.ietf.org/doc/html/rfc7230#section-5.3.3
+-                self._url = URL.build(authority=self._path, encoded=True)
+-            elif idx3 > 1 and self._path[0] == '/':
++                try:
++                    self._url = URL.build(authority=self._path, encoded=True)
++                    host = self._url.raw_host
++                except ValueError:
++                    host = None
++                if host is None:
++                    raise InvalidURLError(
++                        self._path.encode(errors="surrogateescape")
++                        .decode("latin1")
++                    )
++            elif self._path[0] == '/':
+                 # origin-form,
+                 # https://datatracker.ietf.org/doc/html/rfc7230#section-5.3.1
+                 idx1 = self._path.find("?")
+@@ -705,10 +713,23 @@ cdef class HttpRequestParser(HttpParser):
+                     fragment=fragment,
+                     encoded=True,
+                 )
++            elif self._path == '*' and self._cparser.method == cparser.HTTP_OPTIONS:
++                # asterisk-form,
++                self._url = URL(self._path, encoded=True)
+             else:
+                 # absolute-form for proxy maybe,
+                 # https://datatracker.ietf.org/doc/html/rfc7230#section-5.3.2
+-                self._url = URL(self._path, encoded=True)
++                try:
++                    self._url = URL(self._path, encoded=True)
++                    host = self._url.raw_host
++                except ValueError:
++                    host = None
++                # https://www.rfc-editor.org/rfc/rfc9110#section-4.2.1-4
++                if host is None:
++                    raise InvalidURLError(
++                        self._path.encode(errors="surrogateescape")
++                        .decode("latin1")
++                    )
+         finally:
+             PyByteArray_Resize(self._buf, 0)
+ 
+diff --git a/aiohttp/http_parser.py b/aiohttp/http_parser.py
+index ce15764..1c0650a 100644
+--- a/aiohttp/http_parser.py
++++ b/aiohttp/http_parser.py
+@@ -665,7 +665,18 @@ class HttpRequestParser(HttpParser[RawRequestMessage]):
+         if method == "CONNECT":
+             # authority-form,
+             # https://datatracker.ietf.org/doc/html/rfc7230#section-5.3.3
+-            url = URL.build(authority=path, encoded=True)
++            try:
++                url = URL.build(authority=path, encoded=True)
++                host = url.raw_host
++            except ValueError:
++                # Duplicated so mypy understands that url must be defined below.
++                raise InvalidURLError(
++                    path.encode(errors="surrogateescape").decode("latin1")
++                )
++            if host is None:
++                raise InvalidURLError(
++                    path.encode(errors="surrogateescape").decode("latin1")
++                )
+         elif path.startswith("/"):
+             # origin-form,
+             # https://datatracker.ietf.org/doc/html/rfc7230#section-5.3.1
+@@ -688,9 +699,16 @@ class HttpRequestParser(HttpParser[RawRequestMessage]):
+         else:
+             # absolute-form for proxy maybe,
+             # https://datatracker.ietf.org/doc/html/rfc7230#section-5.3.2
+-            url = URL(path, encoded=True)
+-            if url.scheme == "":
+-                # not absolute-form
++            try:
++                url = URL(path, encoded=True)
++                host = url.raw_host
++            except ValueError:
++                # Duplicated so mypy understands that url must be defined below.
++                raise InvalidURLError(
++                    path.encode(errors="surrogateescape").decode("latin1")
++                )
++            # https://www.rfc-editor.org/rfc/rfc9110#section-4.2.1-4
++            if host is None:
+                 raise InvalidURLError(
+                     path.encode(errors="surrogateescape").decode("latin1")
+                 )
+diff --git a/aiohttp/web_request.py b/aiohttp/web_request.py
+index e978b2a..6e9de9a 100644
+--- a/aiohttp/web_request.py
++++ b/aiohttp/web_request.py
+@@ -207,8 +207,14 @@ class BaseRequest(MutableMapping[str, Any], HeadersMixin):
+         self._cache: Dict[str, Any] = {}
+         url = message.url
+         if url.absolute:
++            if scheme is None and url.scheme:
++                # Absolute URL is peer-controlled, use the protocol.
++                scheme = "https" if protocol.ssl_context else "http"
+             if scheme is not None:
++                # Authority-form (CONNECT) has no scheme: leave the target
++                # unchanged unless clone(scheme=...) overrides it.
+                 url = url.with_scheme(scheme)
++                self._cache["scheme"] = scheme
+             if host is not None:
+                 url = url.with_host(host)
+             # absolute URL is given,
+@@ -216,7 +222,6 @@ class BaseRequest(MutableMapping[str, Any], HeadersMixin):
+             # all other properties should be good
+             self._cache["url"] = url
+             self._cache["host"] = url.host
+-            self._cache["scheme"] = url.scheme
+             self._rel_url = url.relative()
+         else:
+             self._rel_url = url
+diff --git a/tests/test_http_parser.py b/tests/test_http_parser.py
+index 4255f4d..610b77e 100644
+--- a/tests/test_http_parser.py
++++ b/tests/test_http_parser.py
+@@ -900,6 +900,65 @@ def test_url_absolute(parser: Any) -> None:
+     assert msg.url == URL("https://www.google.com/path/to.html")
+ 
+ 
++def test_url_authority_form_only_connect(parser: HttpRequestParser) -> None:
++    # https://www.rfc-editor.org/info/rfc9112/#section-3.2.3-1
++    with pytest.raises(http_exceptions.InvalidURLError):
++        parser.feed_data(b"GET www.google.com:443 HTTP/1.1\r\nHost: a\r\n\r\n")
++
++
[email protected](
++    "target",
++    (
++        b"https:///protected",
++        b"https:////protected",
++        b"https://:80/protected",
++        b"https://user@/protected",
++    ),
++    ids=("empty-host", "empty-host-extra-slash", "port-only", "userinfo-only"),
++)
++def test_url_absolute_form_empty_host_rejected(
++    parser: HttpRequestParser, target: bytes
++) -> None:
++    # https://www.rfc-editor.org/rfc/rfc9110#section-4.2.2-4
++    with pytest.raises(http_exceptions.InvalidURLError):
++        parser.feed_data(b"GET " + target + b" HTTP/1.1\r\nHost: a\r\n\r\n")
++
++
++def test_url_absolute_form_invalid_port_rejected(parser: HttpRequestParser) -> None:
++    # yarl raises ValueError for an out-of-range port; that must surface as
++    # a 400, not escape the parser as a bare ValueError.
++    with pytest.raises(http_exceptions.InvalidURLError):
++        parser.feed_data(b"GET http://example.com:65536/x HTTP/1.1\r\nHost: a\r\n\r\n")
++
++
++def test_url_connect_invalid_port_rejected(parser: HttpRequestParser) -> None:
++    with pytest.raises(http_exceptions.InvalidURLError):
++        parser.feed_data(b"CONNECT example.com:65536 HTTP/1.1\r\nHost: a\r\n\r\n")
++
++
++def test_url_connect_empty_host_rejected(parser: HttpRequestParser) -> None:
++    with pytest.raises(http_exceptions.InvalidURLError):
++        parser.feed_data(b"CONNECT :80 HTTP/1.1\r\nHost: a\r\n\r\n")
++
++
++def test_url_origin_form_bare_slash(parser: HttpRequestParser) -> None:
++    messages, upgrade, tail = parser.feed_data(b"GET / HTTP/1.1\r\nHost: a\r\n\r\n")
++    assert messages[0][0].url == URL("/")
++
++
++def test_url_asterisk_form_options(parser: HttpRequestParser) -> None:
++    # https://www.rfc-editor.org/rfc/rfc9112#section-3.2.4
++    messages, upgrade, tail = parser.feed_data(b"OPTIONS * HTTP/1.1\r\nHost: a\r\n\r\n")
++    assert messages[0][0].url == URL("*")
++
++
++def test_url_asterisk_form_only_options(parser: HttpRequestParser) -> None:
++    # asterisk-form is only valid for OPTIONS; for other methods "*" is
++    # neither origin-form nor a valid absolute-form target.
++    with pytest.raises(http_exceptions.InvalidURLError):
++        parser.feed_data(b"GET * HTTP/1.1\r\nHost: a\r\n\r\n")
++
++
+ def test_headers_old_websocket_key1(parser: Any) -> None:
+     text = b"GET /test HTTP/1.1\r\nSEC-WEBSOCKET-KEY1: line\r\n\r\n"
+ 
+diff --git a/tests/test_web_functional.py b/tests/test_web_functional.py
+index 9fafd52..ffb2b95 100644
+--- a/tests/test_web_functional.py
++++ b/tests/test_web_functional.py
+@@ -1929,8 +1929,50 @@ async def test_unread_compressed_body_drain_is_bounded(
+     assert max(drain_reads) < decompressed_size
+ 
+ 
+-async def test_app_max_client_size(aiohttp_client) -> None:
+-    async def handler(request):
++async def test_absolute_form_target_does_not_spoof_scheme(
++    aiohttp_server: AiohttpServer,
++) -> None:
++    """A plaintext absolute-form target with https must not look secure."""
++
++    async def handler(request: web.Request) -> web.Response:
++        return web.json_response(
++            {
++                "scheme": request.scheme,
++                "secure": request.secure,
++                "url": str(request.url),
++                "host": request.host,
++            }
++        )
++
++    app = web.Application()
++    app.router.add_get("/probe", handler)
++    server = await aiohttp_server(app)
++
++    reader, writer = await asyncio.open_connection(server.host, server.port)
++    try:
++        writer.write(
++            b"GET https://trusted.example/probe HTTP/1.1\r\n"
++            b"Host: trusted.example\r\n"
++            b"Connection: close\r\n\r\n"
++        )
++        await writer.drain()
++        raw = await asyncio.wait_for(reader.read(), 5)
++    finally:
++        writer.close()
++        with suppress(ConnectionResetError, BrokenPipeError):
++            await writer.wait_closed()
++
++    assert raw.startswith(b"HTTP/1.1 200 ")
++    assert json.loads(raw.split(b"\r\n\r\n", 1)[1]) == {
++        "scheme": "http",
++        "secure": False,
++        "url": "http://trusted.example/probe",
++        "host": "trusted.example",
++    }
++
++
++async def test_app_max_client_size(aiohttp_client: AiohttpClient) -> None:
++    async def handler(request: web.Request) -> NoReturn:
+         await request.post()
+         return web.Response(body=b"ok")
+ 
+diff --git a/tests/test_web_request.py b/tests/test_web_request.py
+index 7778128..44bf7a3 100644
+--- a/tests/test_web_request.py
++++ b/tests/test_web_request.py
+@@ -11,13 +11,15 @@ import pytest
+ from multidict import CIMultiDict, CIMultiDictProxy, MultiDict
+ from yarl import URL
+ 
+-from aiohttp import HttpVersion
++from aiohttp import HttpVersion, web
++from aiohttp.abc import AbstractStreamWriter
+ from aiohttp.base_protocol import BaseProtocol
+ from aiohttp.http_exceptions import BadHttpMessage, LineTooLong
+ from aiohttp.http_parser import RawRequestMessage
+ from aiohttp.streams import StreamReader
+ from aiohttp.test_utils import make_mocked_request
+-from aiohttp.web import BaseRequest, HTTPRequestEntityTooLarge
++from aiohttp.web import HTTPRequestEntityTooLarge
++from aiohttp.web_protocol import RequestHandler
+ from aiohttp.web_request import _FORWARDED_PAIR_RE, ETag
+ 
+ 
+@@ -26,6 +28,19 @@ def protocol():
+     return mock.Mock(_reading_paused=False)
+ 
+ 
++def make_base_request(
++    message: RawRequestMessage, protocol: RequestHandler
++) -> web.BaseRequest:
++    return web.BaseRequest(
++        message,
++        mock.create_autospec(StreamReader, spec_set=True, instance=True),
++        protocol,
++        mock.create_autospec(AbstractStreamWriter, spec_set=True, instance=True),
++        mock.create_autospec(asyncio.Task, spec_set=True, instance=True),
++        mock.create_autospec(asyncio.AbstractEventLoop, spec_set=True, instance=True),
++    )
++
++
+ def test_base_ctor() -> None:
+     message = RawRequestMessage(
+         "GET",
+@@ -40,9 +55,9 @@ def test_base_ctor() -> None:
+         URL("/path/to?a=1&b=2"),
+     )
+ 
+-    req = BaseRequest(
+-        message, mock.Mock(), mock.Mock(), mock.Mock(), mock.Mock(), mock.Mock()
+-    )
++    protocol = mock.create_autospec(RequestHandler, spec_set=True, instance=True)
++    protocol.ssl_context = None
++    req = make_base_request(message, protocol)
+ 
+     assert "GET" == req.method
+     assert HttpVersion(1, 1) == req.version
+@@ -167,18 +182,24 @@ def test_non_ascii_raw_path() -> None:
+ 
+ def test_absolute_url() -> None:
+     req = make_mocked_request("GET", "https://example.com/path/to?a=1")
+-    assert req.url == URL("https://example.com/path/to?a=1")
+-    assert req.scheme == "https"
++    assert req.url == URL("http://example.com/path/to?a=1")
++    # The scheme of an absolute-form target is peer-controlled and must not
++    # override the transport-derived scheme.
++    assert req.scheme == "http"
++    assert not req.secure
+     assert req.host == "example.com"
+     assert req.rel_url == URL.build(path="/path/to", query={"a": "1"})
+ 
+ 
+ def test_clone_absolute_scheme() -> None:
+     req = make_mocked_request("GET", "https://example.com/path/to?a=1")
+-    assert req.scheme == "https"
+-    req2 = req.clone(scheme="http")
+-    assert req2.scheme == "http"
+-    assert req2.url.scheme == "http"
++    assert req.scheme == "http"
++    req2 = req.clone(scheme="https")
++    assert req2.scheme == "https"
++    assert req2.url.scheme == "https"
++    req3 = req2.clone(scheme="http")
++    assert req3.scheme == "http"
++    assert req3.url.scheme == "http"
+ 
+ 
+ def test_clone_absolute_host() -> None:
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111748_p2.patch new file +282 -0

282 lines not on this page · raw message

meta-python/recipes-devtools/python/python3-aiohttp_3.13.5.bb +2 -0
index e2ac1eda3a..10817e6f34 100644
@@ -27,6 +27,8 @@ SRC_URI += " \
     file://CVE-2026-111750.patch \
     file://CVE-2026-111749.patch \
     file://CVE-2026-111065.patch \
+    file://CVE-2026-111748_p1.patch \
+    file://CVE-2026-111748_p2.patch \
 "
 
 CVE_PRODUCT = "aiohttp:aiohttp"
Signature · 1 line
2.35.6
#6 lore raw

PATCH 6/7 python3-aiohttp: fix CVE-2026-111063

In reply to Darsh Kelaiya -X (dkelaiya - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Darsh Kelaiya <[email protected]>

Backport the Secure shared-cookie fix [1] to aiohttp 3.13.5, as identified by [3]. Apply the Secure check before looking up cached shared morsels so an earlier HTTPS request cannot bypass it.

Include the upstream trusted-origin correction [2] so per-request cookies retain the session jar's treat_as_secure_origin policy. The default property keeps existing custom cookie jars compatible. Include the upstream cookie and client regression tests.

[1] https://github.com/aio-libs/aiohttp/commit/999c356d61e966faffa97b06ab0d0455226d36c5
[2] https://github.com/aio-libs/aiohttp/commit/95081f8a353be2873643ab6dd74904ca413e45e0
[3] https://github.com/aio-libs/aiohttp/security/advisories/GHSA-494j-54xm-rwp3

---
 .../python3-aiohttp/CVE-2026-111063_p1.patch  | 137 ++++++++++
 .../python3-aiohttp/CVE-2026-111063_p2.patch  | 244 ++++++++++++++++++
 .../python/python3-aiohttp_3.13.5.bb          |   2 +
 3 files changed, 383 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111063_p1.patch
 create mode 100644 meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111063_p2.patch
meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111063_p1.patch new file +137 -0
new file mode 100644
index 0000000000..f66cdf7d53
@@ -0,0 +1,137 @@
+From 999c356d61e966faffa97b06ab0d0455226d36c5 Mon Sep 17 00:00:00 2001
+From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com>
+Date: Sun, 27 Sep 2026 21:27:34 +0100
+Subject: [PATCH] [PR #13830/e11d2836 backport][3.14] Fix secure shared cookie
+ (#13832)
+
+**This is a backport of PR #13830 as merged into master
+(e11d2836203a21bec59095498e578d37801027e7).**
+
+Co-authored-by: Sam Bull <[email protected]>
+
+CVE: CVE-2026-111063
+Upstream-Status: Backport [https://github.com/aio-libs/aiohttp/commit/999c356d61e966faffa97b06ab0d0455226d36c5]
+
+Signed-off-by: Darsh Kelaiya <[email protected]>
+---
+ CHANGES/13830.bugfix.rst        |  1 +
+ aiohttp/cookiejar.py            |  3 +++
+ docs/client_reference.rst       |  3 ++-
+ docs/spelling_wordlist.txt      |  1 +
+ tests/test_client_functional.py |  9 +++++++--
+ tests/test_cookiejar.py         | 28 ++++++++++++++++++++++++++++
+ 6 files changed, 42 insertions(+), 3 deletions(-)
+ create mode 100644 CHANGES/13830.bugfix.rst
+
+diff --git a/CHANGES/13830.bugfix.rst b/CHANGES/13830.bugfix.rst
+new file mode 100644
+index 0000000..2a39769
+--- /dev/null
++++ b/CHANGES/13830.bugfix.rst
+@@ -0,0 +1 @@
++Fixed ``CookieJar.filter_cookies()`` sending shared cookies (cookies without a ``Domain`` attribute) marked ``Secure`` over unencrypted connections -- by :user:`Dreamsorcerer`.
+diff --git a/aiohttp/cookiejar.py b/aiohttp/cookiejar.py
+index 6712b90..78630b5 100644
+--- a/aiohttp/cookiejar.py
++++ b/aiohttp/cookiejar.py
+@@ -471,6 +471,9 @@ class CookieJar(AbstractCookieJar):
+         # Send shared cookie
+         key = ("", "")
+         for c in self._cookies[key].values():
++            if is_not_secure and c["secure"]:
++                continue
++
+             # Check cache first
+             if c.key in self._morsel_cache[key]:
+                 filtered[c.key] = self._morsel_cache[key][c.key]
+diff --git a/docs/client_reference.rst b/docs/client_reference.rst
+index 63ee375..24f9088 100644
+--- a/docs/client_reference.rst
++++ b/docs/client_reference.rst
+@@ -2464,7 +2464,8 @@ Utilities
+       :param ~yarl.URL response_url: URL of response, ``None`` for *shared
+          cookies*.  Regular cookies are coupled with server's URL and
+          are sent only to this server, shared ones are sent in every
+-         client request.
++         client request (except that shared cookies marked ``Secure``
++         are only sent over encrypted connections).
+ 
+    .. method:: filter_cookies(request_url)
+ 
+diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt
+index e429f8c..e04017c 100644
+--- a/docs/spelling_wordlist.txt
++++ b/docs/spelling_wordlist.txt
+@@ -350,6 +350,7 @@ un
+ unawaited
+ unclosed
+ undercounting
++unencrypted
+ unescaped
+ unhandled
+ unicode
+diff --git a/tests/test_client_functional.py b/tests/test_client_functional.py
+index 3415b83..a92d008 100644
+--- a/tests/test_client_functional.py
++++ b/tests/test_client_functional.py
+@@ -2843,12 +2843,17 @@ async def test_morsel_with_attributes(aiohttp_client) -> None:
+     c = http.cookies.Morsel()
+     c.set("test3", "456", "456")
+     c["httponly"] = True
+-    c["secure"] = True
+     c["max-age"] = 1000
+ 
++    # A Secure shared cookie must be withheld entirely: the test server
++    # is plain http, so it must not reach the handler at all.
++    c2: http.cookies.Morsel[str] = http.cookies.Morsel()
++    c2.set("test4", "789", "789")
++    c2["secure"] = True
++
+     app = web.Application()
+     app.router.add_get("/", handler)
+-    client = await aiohttp_client(app, cookies={"test2": c})
++    client = await aiohttp_client(app, cookies={"test2": c, "test4": c2})
+ 
+     async with client.get("/") as resp:
+         assert 200 == resp.status
+diff --git a/tests/test_cookiejar.py b/tests/test_cookiejar.py
+index 9a061a3..d4bfdcc 100644
+--- a/tests/test_cookiejar.py
++++ b/tests/test_cookiejar.py
+@@ -1155,6 +1155,34 @@ async def test_treat_as_secure_origin() -> None:
+     assert len(filtered_cookies) == 1
+ 
+ 
++async def test_treat_as_secure_origin_sends_secure_shared_cookie() -> None:
++    endpoint = URL("http://127.0.0.1/")
++
++    jar = CookieJar(unsafe=True, treat_as_secure_origin=[endpoint])
++    jar.update_cookies(SimpleCookie("shared-secure-cookie=first; Secure;"))
++
++    filtered_cookies = jar.filter_cookies(request_url=endpoint)
++    assert "shared-secure-cookie" in filtered_cookies
++
++
++async def test_filter_cookies_with_secure_shared_cookie() -> None:
++    """Secure shared cookies (no Domain attribute) must not be sent over cleartext."""
++    jar = CookieJar()
++    jar.update_cookies(
++        SimpleCookie("shared-secure-cookie=first; Secure; shared-cookie=second;")
++    )
++
++    filtered = jar.filter_cookies(URL("http://example.com/"))
++    assert set(filtered.keys()) == {"shared-cookie"}
++
++    filtered = jar.filter_cookies(URL("https://example.com/"))
++    assert set(filtered.keys()) == {"shared-cookie", "shared-secure-cookie"}
++
++    # The morsel cached by the https request must not bypass the Secure check.
++    filtered = jar.filter_cookies(URL("http://example.com/"))
++    assert set(filtered.keys()) == {"shared-cookie"}
++
++
+ async def test_filter_cookies_does_not_leak_memory() -> None:
+     """Test that filter_cookies doesn't create empty cookie entries.
+ 
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111063_p2.patch new file +244 -0

244 lines not on this page · raw message

meta-python/recipes-devtools/python/python3-aiohttp_3.13.5.bb +2 -0
index 10817e6f34..c6167ef607 100644
@@ -29,6 +29,8 @@ SRC_URI += " \
     file://CVE-2026-111065.patch \
     file://CVE-2026-111748_p1.patch \
     file://CVE-2026-111748_p2.patch \
+    file://CVE-2026-111063_p1.patch \
+    file://CVE-2026-111063_p2.patch \
 "
 
 CVE_PRODUCT = "aiohttp:aiohttp"
Signature · 1 line
2.35.6
#7 lore raw

PATCH 7/7 python3-aiohttp: fix CVE-2026-111064

In reply to Darsh Kelaiya -X (dkelaiya - E INFOCHIPS PRIVATE LIMITED at Cisco)

From: Darsh Kelaiya <[email protected]>

Backport the initial idle-connection timeout fix [1] to aiohttp 3.13.5, as identified by [2]. Start the keepalive deadline when the connection is established so peers that send no request or trickle incomplete headers cannot keep it open indefinitely.

Retain the existing timeout default and the upstream regressions for idle peers, trickled headers, disabled deadlines, slow handlers and WebSocket keepalive cleanup.

[1] https://github.com/aio-libs/aiohttp/commit/be846822b4b3a5a54b6163e794b42dc06fba54a3
[2] https://github.com/aio-libs/aiohttp/security/advisories/GHSA-5wr8-gcqf-gqf3

---
 .../python3-aiohttp/CVE-2026-111064.patch     | 285 ++++++++++++++++++
 .../python/python3-aiohttp_3.13.5.bb          |   1 +
 2 files changed, 286 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111064.patch
meta-python/recipes-devtools/python/python3-aiohttp/CVE-2026-111064.patch new file +285 -0
new file mode 100644
index 0000000000..9962a22ecb
@@ -0,0 +1,285 @@
+From be846822b4b3a5a54b6163e794b42dc06fba54a3 Mon Sep 17 00:00:00 2001
+From: Sam Bull <[email protected]>
+Date: Tue, 29 Sep 2026 00:08:22 +0100
+Subject: [PATCH] Close idle connections (#13681) (#13838)
+
+(cherry picked from commit e07684ef9056183bbefba1ae3f717a23f243631e)
+
+CVE: CVE-2026-111064
+Upstream-Status: Backport [https://github.com/aio-libs/aiohttp/commit/be846822b4b3a5a54b6163e794b42dc06fba54a3]
+
+Backport Changes:
+- Retain aiohttp 3.13.5's documented keepalive_timeout=3630 default
+  instead of changing it to the newer branch's 75-second default.
+- Import Any and AiohttpServer from existing modules for the
+  upstream server and WebSocket regression tests.
+
+Signed-off-by: Darsh Kelaiya <[email protected]>
+---
+ CHANGES/13681.bugfix.rst               |   1 +
+ aiohttp/web_protocol.py                |  12 ++-
+ docs/web_reference.rst                 |   9 ++
+ tests/test_web_server.py               | 118 ++++++++++++++++++++++++-
+ tests/test_web_websocket_functional.py |  34 ++++++-
+ 5 files changed, 167 insertions(+), 7 deletions(-)
+ create mode 100644 CHANGES/13681.bugfix.rst
+
+diff --git a/CHANGES/13681.bugfix.rst b/CHANGES/13681.bugfix.rst
+new file mode 100644
+index 0000000..e39b73a
+--- /dev/null
++++ b/CHANGES/13681.bugfix.rst
+@@ -0,0 +1 @@
++Fixed idle connections not being closed if no request was received -- by :user:`Dreamsorcerer`.
+diff --git a/aiohttp/web_protocol.py b/aiohttp/web_protocol.py
+index d9843f9..c04aa10 100644
+--- a/aiohttp/web_protocol.py
++++ b/aiohttp/web_protocol.py
+@@ -117,8 +117,7 @@ class RequestHandler(BaseProtocol):
+     status line, bad headers or incomplete payload. If any error occurs,
+     connection gets closed.
+ 
+-    keepalive_timeout -- number of seconds before closing
+-                         keep-alive connection
++    keepalive_timeout -- number of seconds before closing an idle connection.
+ 
+     tcp_keepalive -- TCP keep-alive is on, default is on
+ 
+@@ -215,7 +214,7 @@ class RequestHandler(BaseProtocol):
+ 
+         # _request_count is the number of requests processed with the same connection.
+         self._request_count = 0
+-        self._keepalive = False
++        self._keepalive = True
+         self._current_request: Optional[BaseRequest] = None
+         self._manager: Optional[Server] = manager
+         self._request_handler: Optional[_RequestHandler] = manager.request_handler
+@@ -367,6 +366,13 @@ class RequestHandler(BaseProtocol):
+         self._manager.connection_made(self, real_transport)
+ 
+         loop = self._loop
++        # Need to enable keepalive timeout at start of connection, as there's no other
++        # protection against a dead connection that doesn't send a request at all.
++        if self._keepalive_timeout > 0:
++            close_time = loop.time() + self._keepalive_timeout
++            self._next_keepalive_close_time = close_time
++            self._keepalive_handle = loop.call_at(close_time, self._process_keepalive)
++
+         if sys.version_info >= (3, 12):
+             task = asyncio.Task(self.start(), loop=loop, eager_start=True)
+         else:
+diff --git a/docs/web_reference.rst b/docs/web_reference.rst
+index 83a9c7f..ddb43e8 100644
+--- a/docs/web_reference.rst
++++ b/docs/web_reference.rst
+@@ -3135,6 +3135,10 @@ Utilities
+    :param float keepalive_timeout: a delay before a TCP connection is
+                                    closed after a HTTP request. The delay
+                                    allows for reuse of a TCP connection.
++                                   The same delay bounds how long a newly
++                                   accepted connection may take to deliver
++                                   its first complete request; connections
++                                   that stay idle or incomplete are closed.
+ 
+                                    When deployed behind a reverse proxy
+                                    it's important for this value to be
+@@ -3144,6 +3148,11 @@ Utilities
+ 
+       .. versionadded:: 3.8
+ 
++      .. versionchanged:: 3.14.4
++
++         The timeout is now also applied while waiting for the first
++         request, closing connections that never send a complete request.
++
+    :param ssl_context: :class:`ssl.SSLContext` for HTTPS server,
+                        ``None`` for HTTP connection.
+ 
+diff --git a/tests/test_web_server.py b/tests/test_web_server.py
+index 09b7d0b..7595aec 100644
+--- a/tests/test_web_server.py
++++ b/tests/test_web_server.py
+@@ -1,7 +1,7 @@
+ import asyncio
+ import socket
+ from contextlib import suppress
+-from typing import NoReturn
++from typing import Any, NoReturn
+ from unittest import mock
+ 
+ import pytest
+@@ -417,3 +417,119 @@ async def test_no_handler_cancellation(unused_port_socket: socket.socket) -> Non
+         assert done_event.is_set()
+     finally:
+         await asyncio.gather(runner.shutdown(), site.stop())
++
++
++async def test_idle_connection_closed_before_first_request(
++    aiohttp_raw_server: AiohttpRawServer,
++) -> None:
++    """A connection that never sends a request must not be held open forever."""
++
++    async def handler(request: web.BaseRequest) -> web.Response:
++        assert False
++
++    server = await aiohttp_raw_server(handler, keepalive_timeout=0.2)
++
++    reader, writer = await asyncio.open_connection(server.host, server.port)
++    try:
++        # The server must close the connection once keepalive_timeout
++        # expires without a complete request having arrived.
++        assert await asyncio.wait_for(reader.read(), timeout=5) == b""
++    finally:
++        writer.close()
++        await writer.wait_closed()
++
++
++async def test_trickled_headers_closed_at_first_request_deadline(
++    aiohttp_raw_server: AiohttpRawServer, monkeypatch: pytest.MonkeyPatch
++) -> None:
++    """Partial header bytes must not extend the first-request deadline."""
++
++    async def handler(request: web.BaseRequest) -> web.Response:
++        assert False
++
++    server = await aiohttp_raw_server(handler, keepalive_timeout=0.4)
++    runner = server.runner
++    assert runner is not None
++    server_impl = runner.server
++    assert server_impl is not None
++
++    disconnected = asyncio.Event()
++    original_connection_lost = server_impl.connection_lost
++
++    def connection_lost(protocol: Any, exc: BaseException | None = None) -> None:
++        original_connection_lost(protocol, exc)
++        disconnected.set()
++
++    monkeypatch.setattr(server_impl, "connection_lost", connection_lost)
++
++    _, writer = await asyncio.open_connection(server.host, server.port)
++
++    async def trickle_until_closed() -> None:
++        writer.write(b"GET / HTTP/1.1\r\nHost: example.com\r\nX-Slow: ")
++        # asyncio's drain() raises a ConnectionError once the connection is
++        # lost; uvloop's write() raises RuntimeError on the closed transport.
++        with pytest.raises((ConnectionError, RuntimeError)):
++            while True:
++                await writer.drain()
++                await asyncio.sleep(0.05)
++                writer.write(b"a")
++
++    try:
++        # The deadline must fire despite the steady trickle of bytes.
++        await asyncio.wait_for(trickle_until_closed(), timeout=5)
++        await asyncio.wait_for(disconnected.wait(), timeout=5)
++        assert not server_impl.connections
++        assert server_impl.requests_count == 0
++    finally:
++        writer.close()
++        with suppress(ConnectionError, RuntimeError):
++            await writer.wait_closed()
++
++
++async def test_keepalive_timeout_zero_no_first_request_deadline(
++    aiohttp_raw_server: AiohttpRawServer,
++) -> None:
++    """keepalive_timeout=0 must not impose a deadline on the first request."""
++
++    async def handler(request: web.BaseRequest) -> web.Response:
++        return web.Response(text="ok")
++
++    server = await aiohttp_raw_server(handler, keepalive_timeout=0)
++
++    reader, writer = await asyncio.open_connection(server.host, server.port)
++    try:
++        # A zero timeout must not arm a deadline that fires at accept time:
++        # the connection has to survive an idle pause and serve the request.
++        await asyncio.sleep(0.1)
++        writer.write(b"GET / HTTP/1.1\r\nHost: example.com\r\n\r\n")
++        await writer.drain()
++        head = await asyncio.wait_for(reader.readuntil(b"\r\n\r\n"), timeout=5)
++        assert head.startswith(b"HTTP/1.1 200 ")
++        # Between requests a zero timeout still closes the idle connection
++        # right after the response, so the body is followed by EOF.
++        assert await asyncio.wait_for(reader.read(), timeout=5) == b"ok"
++    finally:
++        writer.close()
++        await writer.wait_closed()
++
++
++async def test_handler_slower_than_first_request_deadline(
++    aiohttp_raw_server: AiohttpRawServer,
++) -> None:
++    """A parsed request being handled is not subject to the idle deadline."""
++
++    async def handler(request: web.BaseRequest) -> web.Response:
++        await asyncio.sleep(0.4)  # Longer than keepalive_timeout.
++        return web.Response(text="ok")
++
++    server = await aiohttp_raw_server(handler, keepalive_timeout=0.2)
++
++    reader, writer = await asyncio.open_connection(server.host, server.port)
++    try:
++        writer.write(b"GET / HTTP/1.1\r\nHost: example.com\r\n\r\n")
++        await writer.drain()
++        head = await asyncio.wait_for(reader.readuntil(b"\r\n\r\n"), timeout=5)
++        assert head.startswith(b"HTTP/1.1 200 ")
++    finally:
++        writer.close()
++        await writer.wait_closed()
+diff --git a/tests/test_web_websocket_functional.py b/tests/test_web_websocket_functional.py
+index f7f5c31..871987e 100644
+--- a/tests/test_web_websocket_functional.py
++++ b/tests/test_web_websocket_functional.py
+@@ -12,7 +12,7 @@ import pytest
+ import aiohttp
+ from aiohttp import web
+ from aiohttp.http import WSCloseCode, WSMsgType
+-from aiohttp.pytest_plugin import AiohttpClient
++from aiohttp.pytest_plugin import AiohttpClient, AiohttpServer
+ 
+ 
+ async def test_websocket_can_prepare(loop, aiohttp_client) -> None:
+@@ -953,9 +953,37 @@ async def test_websocket_disable_keepalive(loop, aiohttp_client) -> None:
+     assert data == "OK"
+ 
+ 
+-async def test_receive_str_nonstring(
+-    loop: asyncio.AbstractEventLoop, aiohttp_client: AiohttpClient
++async def test_websocket_disable_keepalive_no_armed_handle(
++    aiohttp_server: AiohttpServer, aiohttp_client: AiohttpClient
+ ) -> None:
++    """keep_alive(False) when no keepalive timer was armed (keepalive_timeout=0)."""
++
++    async def handler(request: web.Request) -> web.StreamResponse:
++        ws = web.WebSocketResponse()
++        assert ws.can_prepare(request)
++        # A zero timeout arms no deadline at connection_made().
++        assert request.protocol._keepalive_handle is None
++        await ws.prepare(request)
++        assert not request.protocol._keepalive
++        assert request.protocol._keepalive_handle is None
++
++        await ws.send_str("OK")
++        await ws.close()
++        return ws
++
++    app = web.Application()
++    app.router.add_route("GET", "/", handler)
++    server = await aiohttp_server(app, keepalive_timeout=0)
++    client = await aiohttp_client(server)  # type: ignore[var-annotated]
++
++    ws = await client.ws_connect("/")
++    data = await ws.receive_str()
++    assert data == "OK"
++
++    await ws.receive()  # Handle close
++
++
++async def test_receive_str_nonstring(aiohttp_client: AiohttpClient) -> None:
+     async def handler(request: web.Request) -> web.WebSocketResponse:
+         ws = web.WebSocketResponse()
+         assert ws.can_prepare(request)
+-- 
+2.35.6
meta-python/recipes-devtools/python/python3-aiohttp_3.13.5.bb +1 -0
index c6167ef607..98fd4bdba3 100644
@@ -31,6 +31,7 @@ SRC_URI += " \
     file://CVE-2026-111748_p2.patch \
     file://CVE-2026-111063_p1.patch \
     file://CVE-2026-111063_p2.patch \
+    file://CVE-2026-111064.patch \
 "
 
 CVE_PRODUCT = "aiohttp:aiohttp"
Signature · 1 line
2.35.6