summaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python/python3-aiohttp/CVE-2023-49082.patch
diff options
context:
space:
mode:
authorJiaying Song <jiaying.song.cn@windriver.com>2024-12-02 16:49:23 +0800
committerArmin Kuster <akuster808@gmail.com>2024-12-08 15:04:29 -0500
commitc5c647ba6acdf14644890d6e4e2b7c7705624143 (patch)
tree007d7260a9c2333db8568d897e82e5ef3c7f6c20 /meta-python/recipes-devtools/python/python3-aiohttp/CVE-2023-49082.patch
parentf17b6e36fc2eef7f24d08885c50732d62f2754e5 (diff)
downloadmeta-openembedded-c5c647ba6acdf14644890d6e4e2b7c7705624143.tar.gz
python3-aiohttp: fix CVE-2023-49081/CVE-2024-30251/CVE-2024-52304/CVE-2023-49082/CVE-2024-27306
CVE-2023-49081: aiohttp is an asynchronous HTTP client/server framework for asyncio and Python. Improper validation made it possible for an attacker to modify the HTTP request (e.g. to insert a new header) or create a new HTTP request if the attacker controls the HTTP version. The vulnerability only occurs if the attacker can control the HTTP version of the request. This issue has been patched in version 3.9.0. References: https://nvd.nist.gov/vuln/detail/CVE-2023-49081 Upstream patches: https://github.com/aio-libs/aiohttp/commit/1e86b777e61cf4eefc7d92fa57fa19dcc676013b CVE-2024-30251: aiohttp is an asynchronous HTTP client/server framework for asyncio and Python. In affected versions an attacker can send a specially crafted POST (multipart/form-data) request. When the aiohttp server processes it, the server will enter an infinite loop and be unable to process any further requests. An attacker can stop the application from serving requests after sending a single request. This issue has been addressed in version 3.9.4. Users are advised to upgrade. Users unable to upgrade may manually apply a patch to their systems. Please see the linked GHSA for instructions. References: https://nvd.nist.gov/vuln/detail/CVE-2024-30251 Upstream patches: https://github.com/aio-libs/aiohttp/commit/cebe526b9c34dc3a3da9140409db63014bc4cf19 https://github.com/aio-libs/aiohttp/commit/7eecdff163ccf029fbb1ddc9de4169d4aaeb6597 https://github.com/aio-libs/aiohttp/commit/f21c6f2ca512a026ce7f0f6c6311f62d6a638866 CVE-2024-52304: aiohttp is an asynchronous HTTP client/server framework for asyncio and Python. Prior to version 3.10.11, the Python parser parses newlines in chunk extensions incorrectly which can lead to request smuggling vulnerabilities under certain conditions. If a pure Python version of aiohttp is installed (i.e. without the usual C extensions) or `AIOHTTP_NO_EXTENSIONS` is enabled, then an attacker may be able to execute a request smuggling attack to bypass certain firewalls or proxy protections. Version 3.10.11 fixes the issue. References: https://nvd.nist.gov/vuln/detail/CVE-2024-52304 Upstream patches: https://github.com/aio-libs/aiohttp/commit/259edc369075de63e6f3a4eaade058c62af0df71 CVE-2023-49082: aiohttp is an asynchronous HTTP client/server framework for asyncio and Python. Improper validation makes it possible for an attacker to modify the HTTP request (e.g. insert a new header) or even create a new HTTP request if the attacker controls the HTTP method. The vulnerability occurs only if the attacker can control the HTTP method (GET, POST etc.) of the request. If the attacker can control the HTTP version of the request it will be able to modify the request (request smuggling). This issue has been patched in version 3.9.0. References: https://nvd.nist.gov/vuln/detail/CVE-2023-49082 Upstream patches: https://github.com/aio-libs/aiohttp/pull/7806/commits/a43bc1779892e7014b7723c59d08fb37a000955e CVE-2024-27306: aiohttp is an asynchronous HTTP client/server framework for asyncio and Python. A XSS vulnerability exists on index pages for static file handling. This vulnerability is fixed in 3.9.4. We have always recommended using a reverse proxy server (e.g. nginx) for serving static files. Users following the recommendation are unaffected. Other users can disable `show_index` if unable to upgrade. References: https://nvd.nist.gov/vuln/detail/CVE-2024-27306 Upstream patches: https://github.com/aio-libs/aiohttp/commit/28335525d1eac015a7e7584137678cbb6ff19397 Signed-off-by: Jiaying Song <jiaying.song.cn@windriver.com> Signed-off-by: Armin Kuster <akuster808@gmail.com>
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-aiohttp/CVE-2023-49082.patch')
-rw-r--r--meta-python/recipes-devtools/python/python3-aiohttp/CVE-2023-49082.patch105
1 files changed, 105 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-aiohttp/CVE-2023-49082.patch b/meta-python/recipes-devtools/python/python3-aiohttp/CVE-2023-49082.patch
new file mode 100644
index 0000000000..cfcb980317
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-aiohttp/CVE-2023-49082.patch
@@ -0,0 +1,105 @@
1From a2200dc43d9fe0ee19b9185b30749c204a4dfd45 Mon Sep 17 00:00:00 2001
2From: Sam Bull <git@sambull.org>
3Date: Wed, 8 Nov 2023 19:25:05 +0000
4Subject: [PATCH] Add HTTP method validation (#6533) (#7806)
5
6(cherry picked from commit 75fca0b00b4297d0a30c51ae97a65428336eb2c1)
7
8Upstream-Status: Backport
9[https://github.com/aio-libs/aiohttp/pull/7806/commits/a43bc1779892e7014b7723c59d08fb37a000955e]
10
11CVE: CVE-2023-49082
12
13Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
14Signed-off-by: Jiaying Song <jiaying.song.cn@windriver.com>
15---
16 CHANGES/6533.feature | 1 +
17 aiohttp/client_reqrep.py | 9 ++++++++-
18 tests/test_client_request.py | 5 +++++
19 tests/test_web_request.py | 9 +++++++--
20 4 files changed, 21 insertions(+), 3 deletions(-)
21 create mode 100644 CHANGES/6533.feature
22
23diff --git a/CHANGES/6533.feature b/CHANGES/6533.feature
24new file mode 100644
25index 0000000..36bcbeb
26--- /dev/null
27+++ b/CHANGES/6533.feature
28@@ -0,0 +1 @@
29+Add HTTP method validation.
30diff --git a/aiohttp/client_reqrep.py b/aiohttp/client_reqrep.py
31index d3cd77e..a8135b2 100644
32--- a/aiohttp/client_reqrep.py
33+++ b/aiohttp/client_reqrep.py
34@@ -78,6 +78,7 @@ if TYPE_CHECKING: # pragma: no cover
35 from .tracing import Trace
36
37
38+_CONTAINS_CONTROL_CHAR_RE = re.compile(r"[^-!#$%&'*+.^_`|~0-9a-zA-Z]")
39 json_re = re.compile(r"^application/(?:[\w.+-]+?\+)?json")
40
41
42@@ -266,10 +267,16 @@ class ClientRequest:
43 proxy_headers: Optional[LooseHeaders] = None,
44 traces: Optional[List["Trace"]] = None,
45 ):
46-
47 if loop is None:
48 loop = asyncio.get_event_loop()
49
50+ match = _CONTAINS_CONTROL_CHAR_RE.search(method)
51+ if match:
52+ raise ValueError(
53+ f"Method cannot contain non-token characters {method!r} "
54+ "(found at least {match.group()!r})"
55+ )
56+
57 assert isinstance(url, URL), url
58 assert isinstance(proxy, (URL, type(None))), proxy
59 # FIXME: session is None in tests only, need to fix tests
60diff --git a/tests/test_client_request.py b/tests/test_client_request.py
61index 009f1a0..d0f208b 100644
62--- a/tests/test_client_request.py
63+++ b/tests/test_client_request.py
64@@ -89,6 +89,11 @@ def test_method3(make_request) -> None:
65 assert req.method == "HEAD"
66
67
68+def test_method_invalid(make_request) -> None:
69+ with pytest.raises(ValueError, match="Method cannot contain non-token characters"):
70+ make_request("METHOD WITH\nWHITESPACES", "http://python.org/")
71+
72+
73 def test_version_1_0(make_request) -> None:
74 req = make_request("get", "http://python.org/", version="1.0")
75 assert req.version == (1, 0)
76diff --git a/tests/test_web_request.py b/tests/test_web_request.py
77index c6aeaf8..2bb0cd5 100644
78--- a/tests/test_web_request.py
79+++ b/tests/test_web_request.py
80@@ -43,7 +43,10 @@ def test_base_ctor() -> None:
81
82 assert "GET" == req.method
83 assert HttpVersion(1, 1) == req.version
84- assert req.host == socket.getfqdn()
85+ # MacOS may return CamelCased host name, need .lower()
86+ # FQDN can be wider than host, e.g.
87+ # 'fv-az397-495' in 'fv-az397-495.internal.cloudapp.net'
88+ assert req.host.lower() in socket.getfqdn().lower()
89 assert "/path/to?a=1&b=2" == req.path_qs
90 assert "/path/to" == req.path
91 assert "a=1&b=2" == req.query_string
92@@ -66,7 +69,9 @@ def test_ctor() -> None:
93 assert "GET" == req.method
94 assert HttpVersion(1, 1) == req.version
95 # MacOS may return CamelCased host name, need .lower()
96- assert req.host.lower() == socket.getfqdn().lower()
97+ # FQDN can be wider than host, e.g.
98+ # 'fv-az397-495' in 'fv-az397-495.internal.cloudapp.net'
99+ assert req.host.lower() in socket.getfqdn().lower()
100 assert "/path/to?a=1&b=2" == req.path_qs
101 assert "/path/to" == req.path
102 assert "a=1&b=2" == req.query_string
103--
1042.25.1
105