CVE-2022-24761
Waitress versions 2.1.0 and prior, proxy, RFC7230 standard mismatch, request smuggling, int parsing, chunk extensions
- CVSS 7.5
- CWE-444 Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling')
- Input Validation and Sanitization
- Remote
Waitress is a Web Server Gateway Interface server for Python 2 and 3. When using Waitress versions 2.1.0 and prior behind a proxy that does not properly validate the incoming HTTP request matches the RFC7230 standard, Waitress and the frontend proxy may disagree on where one request starts and where it ends. This would allow requests to be smuggled via the front-end proxy to waitress and later behavior. There are two classes of vulnerability that may lead to request smuggling that are addressed by this advisory: The use of Python's `int()` to parse strings into integers, leading to `+10` to be parsed as `10`, or `0x01` to be parsed as `1`, where as the standard specifies that the string should contain only digits or hex digits; and Waitress does not support chunk extensions, however it was discarding them without validating that they did not contain illegal characters. This vulnerability has been patched in Waitress 2.1.1. A workaround is available. When deploying a proxy in front of waitress, turning on any and all functionality to make sure that the request matches the RFC7230 standard. Certain proxy servers may not have this functionality though and users are encouraged to upgrade to the latest version of waitress instead.
- CVSS base score
- 7.5
- Published
- 2022-03-17
- OWASP
- A06 Vulnerable and Outdated Components
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Fixed by upgrading
- Yes
Solution
Update Waitress to version 2.1.1.
Vulnerable code sample
from waitress import serve
# Example of a vulnerable Waitress server setup (before the patch)
def vulnerable_int_parsing(value):
# Vulnerable parsing method that does not adhere to RFC7230
return int(value) # This can lead to parsing issues with +10 or 0x01
def handle_request(environ, start_response):
# Example of handling a request without strict validation
headers = environ.get('HTTP_HEADERS', '')
# Here, we are not validating headers as per RFC7230
response_body = b'Hello, World!'
status = '200 OK'
start_response(status, [('Content-Type', 'text/plain'), ('Content-Length', str(len(response_body)))])
return [response_body]
if __name__ == "__main__":
serve(handle_request, host='0.0.0.0', port=8080)Patched code sample
from waitress import serve
from waitress.channel import Server
# Custom server class to enforce stricter request validation
class SecureServer(Server):
def handle_request(self, request):
# Validate that the request conforms to RFC7230
if not self.is_valid_request(request):
self.send_error_response(request)
return
super().handle_request(request)
def is_valid_request(self, request):
# Implement strict validation logic here
# For example, ensure that headers and body conform to the RFC7230 standard
return True # Replace with actual validation logic
def send_error_response(self, request):
# Send a 400 Bad Request response if validation fails
request.send_response(400, "Bad Request")
request.end_headers()
# Serve the application using the secure server
if __name__ == "__main__":
serve(SecureServer(), host='0.0.0.0', port=8080)Cite this entry
@misc{vaitp:cve202224761,
title = {{Waitress versions 2.1.0 and prior, proxy, RFC7230 standard mismatch, request smuggling, int parsing, chunk extensions}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2022},
note = {VAITP Python Vulnerability Dataset, entry CVE-2022-24761},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2022-24761/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
