7.5high
Python-Multipart: Quadratic-time querystring parsing with semicolon separators causes CPU denial of service
- Severity
- 7.5high CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.39% (higher than 35% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-5rvq-cxj2-64vfPYSEC-2026-3036
Description
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.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| Kludex python-multipart | < 0.0.30 | CVE List |
| python-multipart (PyPI) | before 0.0.30 | GitHub Advisory Database, PyPA Advisory Database |
| fastapiexpert python-multipart | before 0.0.30 | NVD |
All scores
| GitHub_M | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| GitHub | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| PyPA Advisory Database | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
Classification
What each source says
CVE List
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.
GitHub Advisory Database
Summary
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.
Details
In python_multipart/multipart.py, both the FIELD_NAME and FIELD_DATA states located the next separator like this:
sep_pos = data.find(b"&", i)
if sep_pos == -1:
sep_pos = data.find(b";", i)
data.find(b"&", i) scans from i to the end of the buffer and returns -1 only when there is no & anywhere in the remainder. For a ; separated body with no &, this failed full buffer scan repeats once per field, making parsing quadratic in the body length.
For example, a 1 MiB url encoded body consisting of a; repeated ~500,000 times, submitted with Content-Type: application/x-www-form-urlencoded, causes the parser to perform on the order of 10^11 byte comparisons, consuming several seconds of CPU for a single request. Cost scales quadratically with chunk size.
The parser is reachable through the public QuerystringParser class and through the high level FormParser, create_form_parser, and parse_form APIs for url encoded bodies. It is also the parser Starlette and FastAPI use for application/x-www-form-urlencoded request bodies via request.form().
Impact
Uncontrolled CPU consumption (denial of service). Parsing is synchronous, so a single small crafted form body occupies the handling worker for seconds, blocking any other work on that worker until parsing finishes. Sustained concurrent requests keep workers continuously busy, degrading or denying service.
Mitigation
Upgrade to python-multipart 0.0.30 or later, which treats only & as a field separator (per the WHATWG URL standard) using a single bounded scan, making parsing linear in the body length.
NVD (es)
Python-Multipart es un analizador multipart de streaming para Python. Antes de la versión 0.0.30, al analizar cuerpos application/x-www-form-urlencoded, QuerystringParser localizaba el separador de campo con una búsqueda en dos pasos: primero escaneaba todo el búfer restante en busca de &, y solo cuando no existía ningún & más adelante, recurría a escanear en busca de ;. Para un cuerpo que usa ; como separador y no contiene ningún &, cada iteración de campo realizaba un escaneo completo fallido de & sobre todo el búfer restante antes de localizar el ; cercano. Con N campos separados por punto y coma en un fragmento de tamaño B, esto produce O(B^2) comparaciones de bytes por fragmento. Un atacante puede enviar un cuerpo pequeño y manipulado de la forma a;a;a;... y hacer que el analizador gaste segundos de CPU por solicitud. Un puñado de solicitudes concurrentes puede agotar los procesos de trabajo. Esta vulnerabilidad está corregida en la versión 0.0.30.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-53539 changed 2026-06-23 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-5rvq-cxj2-64vf changed 2026-09-10 | CC-BY-4.0 |
| NVD | CVE-2026-53539 changed 2026-10-25 | Public domain |
| PyPA Advisory Database | PYSEC-2026-3036 changed 2026-07-13 | CC-BY-4.0 |