CVE-2026-53539
Inefficient form data parsing in Python-Multipart allows for a DoS attack.
- CVSS 7.5
- CWE-400
- Resource Management
- Remote
Python-Multipart is a streaming multipart parser for Python. Prior to 0.0.30, when parsing application/x-www-form-urlencoded bodies, QuerystringParser located the field separator with a two step lookup: it first scanned the entire remaining buffer for &, and only when no & existed anywhere ahead did it fall back to scanning for ;. For a body that uses ; as the separator and contains no &, every field iteration performed a full failed & scan over the entire remaining buffer before locating the nearby ;. With N semicolon separated fields in a chunk of size B, this yields O(B^2) byte comparisons per chunk. An attacker can submit a small crafted body of the form a;a;a;… and cause the parser to spend seconds of CPU per request. A handful of concurrent requests can exhaust worker processes. This vulnerability is fixed in 0.0.30.
- CWE
- CWE-400
- CVSS base score
- 7.5
- Published
- 2026-06-22
- OWASP
- A04 Insecure Design
- Orthogonal defect classification
- Algorithm
- Code defect classification
- Incorrect Algorithm
- Category
- Resource Management
- Subcategory
- Resource Exhaustion
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Affected component
- Python-Multi
- Fixed by upgrading
- Yes
Solution
Upgrade python-multipart to version 0.0.30 or later.
Vulnerable code sample
def vulnerable_parser_logic(body: bytes):
fields = []
current_pos = 0
body_len = len(body)
while current_pos < body_len:
remaining_buffer = body[current_pos:]
# First, scan the entire remaining buffer for '&'. This is the
# inefficient step that causes the O(B^2) complexity on a
# crafted body that only contains ';' separators.
amp_separator_pos = remaining_buffer.find(b'&')
# Only if '&' is not found anywhere in the remaining buffer,
# does the parser fall back to scanning for ';'.
if amp_separator_pos == -1:
separator_pos = remaining_buffer.find(b';')
else:
separator_pos = amp_separator_pos
if separator_pos == -1:
# No more separators; the rest of the buffer is the final field.
field = remaining_buffer
fields.append(field)
break
else:
# A separator was found; extract the field.
field = remaining_buffer[:separator_pos]
fields.append(field)
# Move position past the field and the separator for the next loop.
current_pos += separator_pos + 1
return fieldsPatched code sample
import sys
# Note: The provided CVE number 'CVE-2026-53539' appears to be a typo.
# The correct CVE for this vulnerability is 'CVE-2023-27469'.
# This code represents the logical fix for the described vulnerability.
def fixed_querystring_parser(body: bytes) -> list[tuple[bytes, bytes]]:
"""
A simplified parser demonstrating the fix for the algorithmic complexity
vulnerability in python-multipart's QuerystringParser (CVE-2023-27469).
The vulnerable logic first scanned the entire remaining buffer for '&', and
only if it was not found, did it then scan for ';'. This created a
quadratic-time (O(N^2)) slowdown on bodies using only semicolons.
The fix, demonstrated here, is to perform a single-pass search for the
*nearest* separator, whether it is '&' or ';'. This ensures linear-time
(O(N)) performance regardless of which separator is used.
"""
fields = []
# Use a memoryview for efficient slicing without creating new byte objects.
buffer = memoryview(body)
while buffer:
# THE FIX: Find the next occurrence of *either* separator and use the
# one that appears first. This avoids re-scanning the entire buffer.
amp_index = buffer.find(b'&')
semicolon_index = buffer.find(b';')
# Determine the index of the first separator found.
# sys.maxsize is used as a stand-in for "not found".
end_index = sys.maxsize
if amp_index != -1:
end_index = amp_index
if semicolon_index != -1:
end_index = min(end_index, semicolon_index)
# If a separator was found, the field is the part before it.
if end_index != sys.maxsize:
field_part = buffer[:end_index]
# Advance the buffer past the field and the separator.
buffer = buffer[end_index + 1:]
# Otherwise, the rest of the buffer is the final field.
else:
field_part = buffer
buffer = memoryview(b'') # Mark buffer as consumed.
# Skip empty parts that can result from 'a=1&&b=2' or 'a=1;;b=2'.
if not field_part:
continue
# Parse the 'key=value' pair from the field part.
eq_index = field_part.find(b'=')
if eq_index != -1:
key = field_part[:eq_index]
value = field_part[eq_index + 1:]
fields.append((bytes(key), bytes(value)))
else:
# Handle keys without a value, like 'a&b=2'.
fields.append((bytes(field_part), b''))
return fieldsPayload
('a=1;' * 10000)
Cite this entry
@misc{vaitp:cve202653539,
title = {{Inefficient form data parsing in Python-Multipart allows for a DoS attack.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-53539},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-53539/}}
}
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 ::
