{"id":922,"cve":"CVE-2022-24761","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2022-24761","cwe":"CWE-444 Inconsistent Interpretation of HTTP Requests ('HTTP Request\/Response Smuggling')","cwe_number":444,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/444","cvss_score":7.5,"published":"2022-03-17","owasp":"A06 Vulnerable and Outdated Components","odc":"Function","cdc":"Incorrect Functionality","category":"Input Validation and Sanitization","subcategory":"Insecure Parsing or Deserialization","scope":"Remote","impact":"Denial of Service (DoS)","summary":"Waitress versions 2.1.0 and prior, proxy, RFC7230 standard mismatch, request smuggling, int parsing, chunk extensions","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2022-24761\/","description":"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.","solution":"Update Waitress to version 2.1.1.","affected_component":"Waitress","fixed_by_upgrading":true,"vulnerable_code":"from waitress import serve\n\n# Example of a vulnerable Waitress server setup (before the patch)\ndef vulnerable_int_parsing(value):\n    # Vulnerable parsing method that does not adhere to RFC7230\n    return int(value)  # This can lead to parsing issues with +10 or 0x01\n\ndef handle_request(environ, start_response):\n    # Example of handling a request without strict validation\n    headers = environ.get('HTTP_HEADERS', '')\n    # Here, we are not validating headers as per RFC7230\n    response_body = b'Hello, World!'\n    status = '200 OK'\n    start_response(status, [('Content-Type', 'text\/plain'), ('Content-Length', str(len(response_body)))])\n    return [response_body]\n\nif __name__ == \"__main__\":\n    serve(handle_request, host='0.0.0.0', port=8080)","patched_code":"from waitress import serve\nfrom waitress.channel import Server\n\n# Custom server class to enforce stricter request validation\nclass SecureServer(Server):\n    def handle_request(self, request):\n        # Validate that the request conforms to RFC7230\n        if not self.is_valid_request(request):\n            self.send_error_response(request)\n            return\n        super().handle_request(request)\n\n    def is_valid_request(self, request):\n        # Implement strict validation logic here\n        # For example, ensure that headers and body conform to the RFC7230 standard\n        return True  # Replace with actual validation logic\n\n    def send_error_response(self, request):\n        # Send a 400 Bad Request response if validation fails\n        request.send_response(400, \"Bad Request\")\n        request.end_headers()\n\n# Serve the application using the secure server\nif __name__ == \"__main__\":\n    serve(SecureServer(), host='0.0.0.0', port=8080)","payload_needed":false,"payload":null,"payload_status":"none","published_fix":[{"repository":"Pylons\/waitress","commit_url":"https:\/\/github.com\/Pylons\/waitress\/commit\/e75b0d9afbea8a933f8f5f11d279e661cbfd676b","commit_subject":"Add new regular expressions for Chunked Encoding","units":[{"file":"src\/waitress\/rfc7230.py","function":null},{"file":"src\/waitress\/utilities.py","function":null},{"file":"src\/waitress\/utilities.py","function":"undquote"}]}],"references":null}