{"id":"CVE-2026-53540","aliases":["CVE-2026-53540","GHSA-v9pg-7xvm-68hf","PYSEC-2026-3040"],"related":[],"kind":"vulnerability","state":"published","title":"Python-Multipart: Negative Content-Length in parse_form buffers the entire body in memory","summary":"Python-Multipart is a streaming multipart parser for Python. Prior to 0.0.31, parse_form() did not validate the Content-Length header before using it to bound its chunked read of the request body. A negative Content-Length turned the bounded read into a read-until-EOF, so the entire body was loaded into memory in a single read instead of in fixed-size chunks. This vulnerability is fixed in 0.0.31.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Python-Multipart is a streaming multipart parser for Python. Prior to 0.0.31, parse_form() did not validate the Content-Length header before using it to bound its chunked read of the request body. A negative Content-Length turned the bounded read into a read-until-EOF, so the entire body was loaded into memory in a single read instead of in fixed-size chunks. This vulnerability is fixed in 0.0.31.","source":"cvelist"},{"lang":"en","text":"### Summary\n\n`parse_form()` did not validate the `Content-Length` header before using it to bound its chunked read of the request body. A negative `Content-Length` turned the bounded read into a read-until-EOF, so the entire body was loaded into memory in a single read instead of in fixed-size chunks.\n\n### Details\n\n`parse_form()` reads the input stream in chunks, never reading more than the remaining `Content-Length` at a time. The per-chunk size is computed as `min(content_length - bytes_read, chunk_size)`. The header value was parsed to an integer without checking its sign, so a `Content-Length` of `-1` made this expression negative, and `input_stream.read(-1)` reads until end of stream. The intended bounded, chunked read therefore collapsed into a single unbounded read of the whole stream. The amount read is still bounded by what the client actually sends.\n\n### Impact\n\nThis only affects code that calls `parse_form()` directly with a `Content-Length` header taken from attacker-controlled input and without normalizing a negative value first. No known package is affected:\n\n* Starlette and FastAPI drive `MultipartParser` directly from the ASGI `receive()` stream and do not call `parse_form()`.\n* Known `parse_form()` consumers either do not forward `Content-Length` to it, recompute it from the already-read body, or run behind a layer (such as Werkzeug) that normalizes a negative `Content-Length` to `0`.\n\nThe realistic exposure is limited to bespoke WSGI or `http.server` handlers that forward raw client headers into `parse_form()`. In that case a crafted request buffers the body in memory at once, degrading availability under concurrent requests rather than causing a complete denial of service.\n\n### Mitigation\n\nUpgrade to version `0.0.31` or later, which rejects a negative `Content-Length` with a `ValueError` before reading the stream.","format":"markdown","source":"ghsa"},{"lang":"es","text":"Python-Multipart es un analizador multipart de transmisión para Python. Antes de 0.0.31, parse_form() no validaba el encabezado Content-Length antes de usarlo para limitar su lectura en fragmentos del cuerpo de la solicitud. Un Content-Length negativo convertía la lectura limitada en una lectura hasta EOF, por lo que el cuerpo completo se cargaba en memoria en una sola lectura en lugar de en fragmentos de tamaño fijo. Esta vulnerabilidad está corregida en 0.0.31.","source":"nvd"}],"published":"2026-06-15T20:23:45.000Z","modified":"2026-10-25T23:10:00.167Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L","score":3.7,"rating":"LOW"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L","score":3.7,"rating":"LOW"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L","score":3.7,"rating":"LOW"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L","score":3.7,"rating":"LOW"}],"cwes":["CWE-1284"],"affected":[{"ranges":[{"version":"< 0.0.31","status":"affected"}],"vendor":"Kludex","product":"python-multipart","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"0.0.31"}],"ecosystem":"PyPI","package":"python-multipart","purl":"pkg:pypi/python-multipart","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"0.0.31"}],"vendor":"fastapiexpert","product":"python-multipart","cpe":"cpe:2.3:a:fastapiexpert:python-multipart:*:*:*:*:*:python:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"0.0.31"}],"ecosystem":"PyPI","package":"python-multipart","purl":"pkg:pypi/python-multipart","source":"pysec"}],"references":[{"url":"https://github.com/Kludex/python-multipart/security/advisories/GHSA-v9pg-7xvm-68hf","tags":["vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/Kludex/python-multipart","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/python-multipart","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-v9pg-7xvm-68hf","tags":["advisory"],"sources":["pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-53540","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2026-06-22T17:21:49.069Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-53540","url":"https://www.cve.org/CVERecord?id=CVE-2026-53540","licence":"CVE Terms of Use","modified":"2026-06-22T17:21:55.932Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-v9pg-7xvm-68hf","url":"https://github.com/advisories/GHSA-v9pg-7xvm-68hf","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:50.590Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-53540","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-53540","licence":"Public domain","modified":"2026-10-25T23:10:00.167Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-3040","url":"https://osv.dev/vulnerability/PYSEC-2026-3040","licence":"CC-BY-4.0","modified":"2026-07-13T16:33:29.088Z"}],"updatedAt":"2026-11-25T22:59:25.390Z","epss":{"score":0.0023,"percentile":0.14798,"date":"2026-12-01T12:00:22.000Z"}}