summaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python/python3-waitress/CVE-2024-49768-3.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-waitress/CVE-2024-49768-3.patch')
-rw-r--r--meta-python/recipes-devtools/python/python3-waitress/CVE-2024-49768-3.patch60
1 files changed, 60 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-waitress/CVE-2024-49768-3.patch b/meta-python/recipes-devtools/python/python3-waitress/CVE-2024-49768-3.patch
new file mode 100644
index 0000000000..086c569233
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-waitress/CVE-2024-49768-3.patch
@@ -0,0 +1,60 @@
1From 5cf72c7d9f60e96a3ca65e410098e11d8053749d Mon Sep 17 00:00:00 2001
2From: Delta Regeer <bertjw@regeer.org>
3Date: Sat, 26 Oct 2024 22:13:08 -0600
4Subject: [PATCH] Fix a race condition on recv_bytes boundary when request is
5 invalid
6
7A remote client may send a request that is exactly recv_bytes long,
8followed by a secondary request using HTTP pipelining.
9
10When request lookahead is disabled (default) we won't read any more
11requests, and when the first request fails due to a parsing error, we
12simply close the connection.
13
14However when request lookahead is enabled, it is possible to process and
15receive the first request, start sending the error message back to the
16client while we read the next request and queue it. This will allow the
17secondar request to be serviced by the worker thread while the
18connection should be closed.
19
20The fix here checks if we should not have read the data in the first
21place (because the conection is going to be torn down) while we hold the
22`requests_lock` which means the service thread can't be in the middle of
23flipping the `close_when_flushed` flag.
24
25CVE: CVE-2024-49768
26Upstream-Status: Backport [https://github.com/Pylons/waitress/commit/f4ba1c260cf17156b582c6252496213ddc96b591]
27Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
28---
29 src/waitress/channel.py | 11 ++++++++++-
30 1 file changed, 10 insertions(+), 1 deletion(-)
31
32diff --git a/src/waitress/channel.py b/src/waitress/channel.py
33index eb59dd3..756adce 100644
34--- a/src/waitress/channel.py
35+++ b/src/waitress/channel.py
36@@ -147,7 +147,7 @@ class HTTPChannel(wasyncore.dispatcher):
37 # 1. We're not already about to close the connection.
38 # 2. We're not waiting to flush remaining data before closing the
39 # connection
40- # 3. There are not too many tasks already queued
41+ # 3. There are not too many tasks already queued (if lookahead is enabled)
42 # 4. There's no data in the output buffer that needs to be sent
43 # before we potentially create a new task.
44
45@@ -203,6 +203,15 @@ class HTTPChannel(wasyncore.dispatcher):
46 return False
47
48 with self.requests_lock:
49+ # Don't bother processing anymore data if this connection is about
50+ # to close. This may happen if readable() returned True, on the
51+ # main thread before the service thread set the close_when_flushed
52+ # flag, and we read data but our service thread is attempting to
53+ # shut down the connection due to an error. We want to make sure we
54+ # do this while holding the request_lock so that we can't race
55+ if self.will_close or self.close_when_flushed:
56+ return False
57+
58 while data:
59 if self.request is None:
60 self.request = self.parser_class(self.adj)