new file mode 100644
@@ -0,0 +1,118 @@
+From 406a4349e838b03f4c4ce4955203a0b762fa9bb3 Mon Sep 17 00:00:00 2001
+From: Sam Bull <git@sambull.org>
+Date: Mon, 5 Oct 2026 00:34:47 +0100
+Subject: [PATCH] Improve performance of domain matching (#13943) (#13945)
+
+(cherry picked from commit 766b882820da0651c84090e366a3b024b4a263c9)
+
+CVE: CVE-2026-128124
+Upstream-Status: Backport [https://github.com/aio-libs/aiohttp/commit/c6ac0e44c3c573ff9616f4a6a532992538b31e43]
+
+Backport Changes:
+- Apply fnmatch translation to the existing full domain mask and retain
+ the existing canonical pattern and case-sensitive Host matching.
+ The upstream change follows port-handling commit 1577756e9170, which
+ is absent here; importing that behavior is unnecessary for this fix.
+- Omit the port-dependent regression cases, retaining the wildcard
+ matching cases and benchmark. Add checks for the existing Host rules.
+
+Signed-off-by: Ashishkumar Parmar <asparmar@cisco.com>
+---
+ CHANGES/13943.bugfix.rst | 1 +
+ aiohttp/web_urldispatcher.py | 7 ++++---
+ tests/test_benchmarks_web_urldispatcher.py | 16 ++++++++++++++++
+ tests/test_urldispatch.py | 14 ++++++++++++++
+ 4 files changed, 35 insertions(+), 3 deletions(-)
+ create mode 100644 CHANGES/13943.bugfix.rst
+
+diff --git a/CHANGES/13943.bugfix.rst b/CHANGES/13943.bugfix.rst
+new file mode 100644
+index 0000000..d565849
+--- /dev/null
++++ b/CHANGES/13943.bugfix.rst
+@@ -0,0 +1 @@
++Improved performance in domain matching with ``Application.add_domain()`` -- by :user:`Dreamsorcerer`.
+diff --git a/aiohttp/web_urldispatcher.py b/aiohttp/web_urldispatcher.py
+index 48465b5..5893f59 100644
+--- a/aiohttp/web_urldispatcher.py
++++ b/aiohttp/web_urldispatcher.py
+@@ -1,6 +1,7 @@
+ import abc
+ import asyncio
+ import base64
++import fnmatch
+ import functools
+ import hashlib
+ import html
+@@ -866,12 +867,12 @@ class MaskDomain(Domain):
+
+ def __init__(self, domain: str) -> None:
+ super().__init__(domain)
+- mask = self._domain.replace(".", r"\.").replace("*", ".*")
+- self._mask = re.compile(mask)
++ self._pattern = self._domain.replace(".", r"\.").replace("*", ".*")
++ self._mask = re.compile(fnmatch.translate(self._domain))
+
+ @property
+ def canonical(self) -> str:
+- return self._mask.pattern
++ return self._pattern
+
+ def match_domain(self, host: str) -> bool:
+ return self._mask.fullmatch(host) is not None
+diff --git a/tests/test_benchmarks_web_urldispatcher.py b/tests/test_benchmarks_web_urldispatcher.py
+index 936ed63..b4b86b1 100644
+--- a/tests/test_benchmarks_web_urldispatcher.py
++++ b/tests/test_benchmarks_web_urldispatcher.py
+@@ -17,6 +17,7 @@ from yarl import URL
+ import aiohttp
+ from aiohttp import web
+ from aiohttp.http import HttpVersion, RawRequestMessage
++from aiohttp.web_urldispatcher import MaskDomain
+
+
+ @pytest.fixture
+@@ -573,3 +574,18 @@ def test_resolve_prefix_resources_many_prefix_many_plain(
+ @benchmark
+ def _run() -> None:
+ loop.run_until_complete(run_url_dispatcher_benchmark())
++
++
++def test_match_domain_wildcards_long_host(benchmark: BenchmarkFixture) -> None:
++ """Match a two-wildcard domain rule against the longest possible Host header."""
++ rule = MaskDomain("*.*.example.com")
++ # llhttp caps a Host header at max_field_size - len("Host") bytes, and a
++ # dotted host is the worst case for a wildcard rule.
++ host = ("a." * 4093)[:8186]
++
++ assert rule.match_domain(host) is False
++
++ @benchmark
++ def _run() -> None:
++ for _ in range(100):
++ rule.match_domain(host)
+diff --git a/tests/test_urldispatch.py b/tests/test_urldispatch.py
+index e329ea2..6cf8507 100644
+--- a/tests/test_urldispatch.py
++++ b/tests/test_urldispatch.py
+@@ -1120,6 +1120,20 @@ def test_domain_valid():
+ ("*.example.com", "jpg.example.com", True),
+ ("*.example.com", "a.example.com", True),
+ ("*.example.com", "example.com", False),
++ # A wildcard spans labels.
++ ("*.example.com", "a.b.example.com", True),
++ ("*.example.com", ".example.com", True),
++ ("*", "a:b", True),
++ # Several wildcards, including adjacent and infix ones.
++ ("*.*.example.com", "a.b.example.com", True),
++ ("*.*.example.com", "a.example.com", False),
++ ("**.example.com", "a.example.com", True),
++ ("a*b.example.com", "axxb.example.com", True),
++ ("x*x.example.com", "x.example.com", False),
++ # Preserve the existing case-sensitive, full-Host matching rules.
++ ("*.example.com", "A.EXAMPLE.COM", False),
++ ("*.example.com", "a.example.com:8080", False),
++ ("*.example.com", "a:b.example.com", True),
+ ],
+ )
+ def test_match_domain(a, b, result):
@@ -34,6 +34,7 @@ SRC_URI += " \
file://CVE-2026-111064.patch \
file://CVE-2026-123817_p1.patch \
file://CVE-2026-123817_p2.patch \
+ file://CVE-2026-128124.patch \
"
CVE_PRODUCT = "aiohttp:aiohttp"