CVE-2023-46136: Werkzeug DoS: High resource usage when parsing multipart/form-data containing a large part with CR/LF character at the beginning
(updated )
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.
References
- github.com/advisories/GHSA-hrfv-mqp8-q5rw
- github.com/pallets/werkzeug
- github.com/pallets/werkzeug/commit/b1916c0c083e0be1c9d887ee2f3d696922bfc5c1
- github.com/pallets/werkzeug/commit/f2300208d5e2a5076cbbb4c2aad71096fd040ef9
- github.com/pallets/werkzeug/commit/f3c803b3ade485a45f12b6d6617595350c0f03e2
- github.com/pallets/werkzeug/security/advisories/GHSA-hrfv-mqp8-q5rw
- github.com/pypa/advisory-database/tree/main/vulns/werkzeug/PYSEC-2023-221.yaml
- nvd.nist.gov/vuln/detail/CVE-2023-46136
- security.netapp.com/advisory/ntap-20231124-0008
Detect and mitigate CVE-2023-46136 with GitLab Dependency Scanning
Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →