CVE-2023-46136: Werkzeug vulnerable to high resource usage when parsing multipart/form-data containing a large part with CR/LF character at the beginning
Pallets Werkzeug is vulnerable to a denial of service, caused by a flaw when parsing multipart/form-data containing a large part with CR/LF character at the beginning. By sending a specially crafted request, a remote authenticated attacker could exploit this vulnerability to cause a denial of service condition.
Other sources
Werkzeug is a comprehensive WSGI web application library. If an upload of a file that starts with CR or LF and then is followed by megabytes of data without these characters: all of these bytes are appended chunk by chunk into internal bytearray and lookup for boundary is performed on growing buffer. This allows an attacker to cause a denial of service by sending crafted multipart data to an endpoint that will parse it. The amount of CPU time required can block worker processes from handling legitimate requests. This vulnerability has been patched in version 3.0.1.
— NVD
Werkzeug is a comprehensive WSGI web application library. In versions on the 3.x branch prior to 3.0.1 and on the 2.x branch prior to 2.3.8, if an upload of a file that starts with CR or LF and then is followed by megabytes of data without these characters: all of these bytes are appended chunk by chunk into internal bytearray and lookup for boundary is performed on growing buffer. This allows an attacker to cause a denial of service by sending crafted multipart data to an endpoint that will parse it. The amount of CPU time required can block worker processes from handling legitimate requests. This vulnerability has been patched in version 3.0.1 and 2.3.8.
— MITRE
Werkzeug multipart data parser needs to find a boundary that may be between consecutive chunks. That's why parsing is based on looking for newline characters. Unfortunately, code looking for partial boundary in the buffer is written inefficiently, so if we upload a file that starts with CR or LF and then is followed by megabytes of data without these characters: all of these bytes are appended chunk by chunk into internal bytearray and lookup for boundary is performed on growing buffer.
This allows an attacker to cause a denial of service by sending crafted multipart data to an endpoint that will parse it. The amount of CPU time required can block worker processes from handling legitimate requests. The amount of RAM required can trigger an out of memory kill of the process. If many concurrent requests are sent continuously, this can exhaust or kill all available workers.
— GitHub
Affected Software
Remediation
Event History
Frequently Asked Questions
What is CVE-2023-46136?
CVE-2023-46136 is a vulnerability in the Werkzeug library that allows for a file upload issue.
What is the impact of CVE-2023-46136?
The impact of CVE-2023-46136 is high, with a severity value of 8, as it allows for potential unauthorized access to uploaded files.
How does CVE-2023-46136 work?
CVE-2023-46136 occurs due to inefficient code in the Werkzeug multipart data parser, which allows for potential boundary parsing issues when uploading files beginning with CR or LF characters.
What is the affected software version of CVE-2023-46136?
The affected software version of CVE-2023-46136 is Werkzeug 3.0.0, with version 3.0.1 being the remedy.
How can I fix CVE-2023-46136?
To fix CVE-2023-46136, update Werkzeug to version 3.0.1 or higher.