diff options
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.patch | 60 |
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 @@ | |||
| 1 | From 5cf72c7d9f60e96a3ca65e410098e11d8053749d Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Delta Regeer <bertjw@regeer.org> | ||
| 3 | Date: Sat, 26 Oct 2024 22:13:08 -0600 | ||
| 4 | Subject: [PATCH] Fix a race condition on recv_bytes boundary when request is | ||
| 5 | invalid | ||
| 6 | |||
| 7 | A remote client may send a request that is exactly recv_bytes long, | ||
| 8 | followed by a secondary request using HTTP pipelining. | ||
| 9 | |||
| 10 | When request lookahead is disabled (default) we won't read any more | ||
| 11 | requests, and when the first request fails due to a parsing error, we | ||
| 12 | simply close the connection. | ||
| 13 | |||
| 14 | However when request lookahead is enabled, it is possible to process and | ||
| 15 | receive the first request, start sending the error message back to the | ||
| 16 | client while we read the next request and queue it. This will allow the | ||
| 17 | secondar request to be serviced by the worker thread while the | ||
| 18 | connection should be closed. | ||
| 19 | |||
| 20 | The fix here checks if we should not have read the data in the first | ||
| 21 | place (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 | ||
| 23 | flipping the `close_when_flushed` flag. | ||
| 24 | |||
| 25 | CVE: CVE-2024-49768 | ||
| 26 | Upstream-Status: Backport [https://github.com/Pylons/waitress/commit/f4ba1c260cf17156b582c6252496213ddc96b591] | ||
| 27 | Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com> | ||
| 28 | --- | ||
| 29 | src/waitress/channel.py | 11 ++++++++++- | ||
| 30 | 1 file changed, 10 insertions(+), 1 deletion(-) | ||
| 31 | |||
| 32 | diff --git a/src/waitress/channel.py b/src/waitress/channel.py | ||
| 33 | index 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) | ||
