HighGHSA-5rvq-cxj2-64vfCVE-2026-53539PYSEC-2026-3036

python-multipart: Quadratic-time querystring parsing with semicolon separators causes CPU denial of service

Published 15 Jun 2026 · Updated 10 Sept 2026

Is your project on an affected python-multipart?

Private repo? Upload its lockfile instead, or connect GitHub to check every repo.

Look after several Python apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie

Affected package

Affected
<0.0.30
Fixed in
0.0.30
Update to the fixed version for your release line, for example:pip install 'python-multipart>=0.0.30'

Details

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.

Is GHSA-5rvq-cxj2-64vf in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected python-multipart, and gives you the command that fixes it.

More advisories for python-multipart

  • LowCVE-2026-53540python-multipart: Negative Content-Length in parse_form buffers the entire body in memory · 15 Jun 2026
  • LowCVE-2026-53538python-multipart: Semicolon treated as querystring field separator enables parameter smuggling · 15 Jun 2026
  • LowCVE-2026-53537python-multipart: Content-Disposition parameter smuggling via RFC 2231/5987 extended parameters · 15 Jun 2026
  • HighCVE-2026-42561python-multipart has Denial of Service via unbounded multipart part headers · 6 May 2026
  • MediumCVE-2026-40347python-multipart affected by Denial of Service via large multipart preamble or epilogue data · 15 Apr 2026
  • HighCVE-2026-24486Python-Multipart has Arbitrary File Write via Non-Default Configuration · 26 Jan 2026
All 9 advisories for python-multipart

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.