VYPR
Moderate severityNVD Advisory· Published Oct 24, 2023· Updated Feb 13, 2025

Werkzeug vulnerable to high resource usage when parsing multipart/form-data containing a large part with CR/LF character at the beginning

CVE-2023-46136

Description

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.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
werkzeugPyPI
>= 3.0.0, < 3.0.13.0.1
werkzeugPyPI
< 2.3.82.3.8

Affected products

1

Patches

3
f3c803b3ade4

Merge 3.0.x (#2801)

https://github.com/pallets/werkzeugPhil JonesOct 24, 2023via ghsa
3 files changed · +18 2
  • CHANGES.rst+8 0 modified
    @@ -1,5 +1,13 @@
     .. currentmodule:: werkzeug
     
    +Version 3.0.1
    +-------------
    +
    +Released 2023-10-24
    +
    +-   Fix slow multipart parsing for large parts potentially enabling DoS
    +    attacks. :cwe:`CWE-407`
    +
     Version 3.0.0
     -------------
     
    
  • pyproject.toml+1 1 modified
    @@ -1,6 +1,6 @@
     [project]
     name = "Werkzeug"
    -version = "3.0.0"
    +version = "3.0.1"
     description = "The comprehensive WSGI web application library."
     readme = "README.rst"
     license = {file = "LICENSE.rst"}
    
  • src/werkzeug/sansio/multipart.py+9 1 modified
    @@ -251,12 +251,20 @@ def _parse_data(self, data: bytes, *, start: bool) -> tuple[bytes, int, bool]:
             else:
                 data_start = 0
     
    -        if self.buffer.find(b"--" + self.boundary) == -1:
    +        boundary = b"--" + self.boundary
    +
    +        if self.buffer.find(boundary) == -1:
                 # No complete boundary in the buffer, but there may be
                 # a partial boundary at the end. As the boundary
                 # starts with either a nl or cr find the earliest and
                 # return up to that as data.
                 data_end = del_index = self.last_newline(data[data_start:]) + data_start
    +            # If amount of data after last newline is far from
    +            # possible length of partial boundary, we should
    +            # assume that there is no partial boundary in the buffer
    +            # and return all pending data.
    +            if (len(data) - data_end) > len(b"\n" + boundary):
    +                data_end = del_index = len(data)
                 more_data = True
             else:
                 match = self.boundary_re.search(data)
    
b1916c0c083e

Fix: slow multipart parsing for huge files with few CR/LF characters

https://github.com/pallets/werkzeugPaweł SrokoszOct 12, 2023via ghsa
1 file changed · +9 1
  • src/werkzeug/sansio/multipart.py+9 1 modified
    @@ -251,12 +251,20 @@ def _parse_data(self, data: bytes, *, start: bool) -> tuple[bytes, int, bool]:
             else:
                 data_start = 0
     
    -        if self.buffer.find(b"--" + self.boundary) == -1:
    +        boundary = b"--" + self.boundary
    +
    +        if self.buffer.find(boundary) == -1:
                 # No complete boundary in the buffer, but there may be
                 # a partial boundary at the end. As the boundary
                 # starts with either a nl or cr find the earliest and
                 # return up to that as data.
                 data_end = del_index = self.last_newline(data[data_start:]) + data_start
    +            # If amount of data after last newline is far from
    +            # possible length of partial boundary, we should
    +            # assume that there is no partial boundary in the buffer
    +            # and return all pending data.
    +            if (len(data) - data_end) > len(b"\n" + boundary):
    +                data_end = del_index = len(data)
                 more_data = True
             else:
                 match = self.boundary_re.search(data)
    
f2300208d5e2

Fix: slow multipart parsing for huge files with few CR/LF characters

https://github.com/pallets/werkzeugPaweł SrokoszOct 12, 2023via ghsa
1 file changed · +9 1
  • src/werkzeug/sansio/multipart.py+9 1 modified
    @@ -251,12 +251,20 @@ def _parse_data(self, data: bytes, *, start: bool) -> tuple[bytes, int, bool]:
             else:
                 data_start = 0
     
    -        if self.buffer.find(b"--" + self.boundary) == -1:
    +        boundary = b"--" + self.boundary
    +
    +        if self.buffer.find(boundary) == -1:
                 # No complete boundary in the buffer, but there may be
                 # a partial boundary at the end. As the boundary
                 # starts with either a nl or cr find the earliest and
                 # return up to that as data.
                 data_end = del_index = self.last_newline(data[data_start:]) + data_start
    +            # If amount of data after last newline is far from
    +            # possible length of partial boundary, we should
    +            # assume that there is no partial boundary in the buffer
    +            # and return all pending data.
    +            if (len(data) - data_end) > len(b"\n" + boundary):
    +                data_end = del_index = len(data)
                 more_data = True
             else:
                 match = self.boundary_re.search(data)
    

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

9

News mentions

0

No linked articles in our index yet.