summaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python/python3-aiohttp
diff options
context:
space:
mode:
authorJiaying Song <jiaying.song.cn@windriver.com>2025-06-05 17:15:50 +0800
committerArmin Kuster <akuster808@gmail.com>2025-07-02 20:36:23 -0400
commit65523c22aaed162ac4b0579bdaf44533951ccb71 (patch)
tree205d171322b060844cf0dfa3815dfc275120ae19 /meta-python/recipes-devtools/python/python3-aiohttp
parentcec6410b0c6fe85cf666543f32f8e8dc661e13a2 (diff)
downloadmeta-openembedded-65523c22aaed162ac4b0579bdaf44533951ccb71.tar.gz
python3-aiohttp: fix CVE-2024-42367
aiohttp is an asynchronous HTTP client/server framework for asyncio and Python. Prior to version 3.10.2, static routes which contain files with compressed variants (`.gz` or `.br` extension) are vulnerable to path traversal outside the root directory if those variants are symbolic links. The server protects static routes from path traversal outside the root directory when `follow_symlinks=False` (default). It does this by resolving the requested URL to an absolute path and then checking that path relative to the root. However, these checks are not performed when looking for compressed variants in the `FileResponse` class, and symbolic links are then automatically followed when performing the `Path.stat()` and `Path.open()` to send the file. Version 3.10.2 contains a patch for the issue. Reference: https://nvd.nist.gov/vuln/detail/CVE-2024-42367 https://github.com/aio-libs/aiohttp/security/advisories/GHSA-jwhx-xcg6-8xhj Upstream patch: https://github.com/aio-libs/aiohttp/commit/ce2e9758814527589b10759a20783fb03b98339f 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')
-rw-r--r--meta-python/recipes-devtools/python/python3-aiohttp/CVE-2024-42367.patch65
1 files changed, 65 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-aiohttp/CVE-2024-42367.patch b/meta-python/recipes-devtools/python/python3-aiohttp/CVE-2024-42367.patch
new file mode 100644
index 0000000000..dadec31f3a
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-aiohttp/CVE-2024-42367.patch
@@ -0,0 +1,65 @@
1From e19cb50fb529bbe75cc4f1b68eeb0a3f631ad0d0 Mon Sep 17 00:00:00 2001
2From: "J. Nick Koston" <nick@koston.org>
3Date: Thu, 8 Aug 2024 11:19:28 -0500
4Subject: [PATCH] Do not follow symlinks for compressed file variants (#8652)
5
6CVE: CVE-2024-42367
7
8Upstream-Status: Backport
9[https://github.com/aio-libs/aiohttp/commit/ce2e9758814527589b10759a20783fb03b98339f]
10
11Co-authored-by: Steve Repsher <steverep@users.noreply.github.com>
12Signed-off-by: Jiaying Song <jiaying.song.cn@windriver.com>
13---
14 CHANGES/8652.bugfix.rst | 1 +
15 aiohttp/web_fileresponse.py | 26 ++++++++++++++++++++++++++
16 2 files changed, 27 insertions(+)
17 create mode 100644 CHANGES/8652.bugfix.rst
18
19diff --git a/CHANGES/8652.bugfix.rst b/CHANGES/8652.bugfix.rst
20new file mode 100644
21index 000000000..3a1003e50
22--- /dev/null
23+++ b/CHANGES/8652.bugfix.rst
24@@ -0,0 +1 @@
25+Fixed incorrectly following symlinks for compressed file variants -- by :user:`steverep`.
26diff --git a/aiohttp/web_fileresponse.py b/aiohttp/web_fileresponse.py
27index f41ed3fd0..35dbd41e1 100644
28--- a/aiohttp/web_fileresponse.py
29+++ b/aiohttp/web_fileresponse.py
30@@ -127,6 +127,32 @@ class FileResponse(StreamResponse):
31 self.content_length = 0
32 return await super().prepare(request)
33
34+ def _get_file_path_stat_encoding(
35+ self, accept_encoding: str
36+ ) -> Tuple[pathlib.Path, os.stat_result, Optional[str]]:
37+ """Return the file path, stat result, and encoding.
38+
39+ If an uncompressed file is returned, the encoding is set to
40+ :py:data:`None`.
41+
42+ This method should be called from a thread executor
43+ since it calls os.stat which may block.
44+ """
45+ file_path = self._path
46+ for file_extension, file_encoding in ENCODING_EXTENSIONS.items():
47+ if file_encoding not in accept_encoding:
48+ continue
49+
50+ compressed_path = file_path.with_suffix(file_path.suffix + file_extension)
51+ with suppress(OSError):
52+ # Do not follow symlinks and ignore any non-regular files.
53+ st = compressed_path.lstat()
54+ if S_ISREG(st.st_mode):
55+ return compressed_path, st, file_encoding
56+
57+ # Fallback to the uncompressed file
58+ return file_path, file_path.stat(), None
59+
60 async def prepare(self, request: "BaseRequest") -> Optional[AbstractStreamWriter]:
61 filepath = self._path
62
63--
642.34.1
65