chore(deps): update dependency python-multipart to v0.0.31 [security]#180
Open
renovate[bot] wants to merge 1 commit into
Open
chore(deps): update dependency python-multipart to v0.0.31 [security]#180renovate[bot] wants to merge 1 commit into
renovate[bot] wants to merge 1 commit into
Conversation
0aebe0f to
30bbf2e
Compare
30bbf2e to
9fbcea3
Compare
9fbcea3 to
7e6227c
Compare
7e6227c to
27553da
Compare
27553da to
c95e13f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
==0.0.20→==0.0.31Python-Multipart has Arbitrary File Write via Non-Default Configuration
CVE-2026-24486 / GHSA-wp53-j4wj-2cfg
More information
Details
Summary
A Path Traversal vulnerability exists when using non-default configuration options
UPLOAD_DIRandUPLOAD_KEEP_FILENAME=True. An attacker can write uploaded files to arbitrary locations on the filesystem by crafting a malicious filename.Details
When
UPLOAD_DIRis set andUPLOAD_KEEP_FILENAMEisTrue, the library constructs the file path usingos.path.join(file_dir, fname). Due to the behavior ofos.path.join(), if the filename begins with a/, all preceding path components are discarded:This allows an attacker to bypass the intended upload directory and write files to arbitrary paths.
Affected Configuration
Projects are only affected if all of the following are true:
UPLOAD_DIRis setUPLOAD_KEEP_FILENAMEis set to TrueMAX_MEMORY_FILE_SIZE(triggering a flush to disk)The default configuration is not vulnerable.
Impact
Arbitrary file write to attacker-controlled paths on the filesystem.
Mitigation
Upgrade to version 0.0.22, or avoid using
UPLOAD_KEEP_FILENAME=Truein project configurations.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:LReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
python-multipart affected by Denial of Service via large multipart preamble or epilogue data
CVE-2026-40347 / GHSA-mj87-hwqh-73pj
More information
Details
Summary
A denial of service vulnerability exists when parsing crafted
multipart/form-datarequests with large preamble or epilogue sections.Details
Two inefficient multipart parsing paths could be abused with attacker-controlled input.
Before the first multipart boundary, the parser handled leading CR and LF bytes inefficiently while searching for the start of the first part. After the closing boundary, the parser continued processing trailing epilogue data instead of discarding it immediately. As a result, parsing time could grow with the size of crafted data placed before the first boundary or after the closing boundary.
Impact
An attacker can send oversized malformed multipart bodies that consume excessive CPU time during request parsing, reducing request-handling capacity and delaying legitimate requests. This issue degrades availability but does not typically result in a complete denial of service for the entire application.
Mitigation
Upgrade to version
0.0.26or later, which skips ahead to the next boundary candidate when processing leading CR/LF data and immediately discards epilogue data after the closing boundary.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:LReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
python-multipart has Denial of Service via unbounded multipart part headers
CVE-2026-42561 / GHSA-pp6c-gr5w-3c5g
More information
Details
Summary
python-multiparthas a denial of service vulnerability in multipart part header parsing. When parsingmultipart/form-data,MultipartParserpreviously had no limit on the number of part headers or the size of an individual part header. An attacker could send a request with either many repeated headers without terminating the header block or a single very large header value, causing excessive CPU work before request rejection or completion.Impact
Applications that parse attacker-controlled
multipart/form-datawith affected versions ofpython-multipartcan experience CPU exhaustion. ASGI applications using Starlette, FastAPI, or other frameworks that invokepython-multipartmay have worker or event-loop delays while processing malicious upload requests.Details
The affected parser states are
HEADER_FIELD_START,HEADER_FIELD,HEADER_VALUE_START,HEADER_VALUE, andHEADER_VALUE_ALMOST_DONE. The issue can be triggered by:Both variants are addressed by enforcing default parser limits for maximum header count and maximum header size.
Mitigation
Upgrade to
python-multipart0.0.27or later.If upgrading is not immediately possible, reduce exposure by enforcing request body size limits at the server, proxy, or framework layer. This is only a mitigation; affected versions of
python-multipartstill parse multipart part headers without the default header count and header size limits.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:HReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
python-multipart: Content-Disposition parameter smuggling via RFC 2231/5987 extended parameters
CVE-2026-53537 / GHSA-vffw-93wf-4j4q
More information
Details
Summary
parse_options_headerparsedContent-Disposition(andContent-Type) headers withemail.message.Message, which transparently applies RFC 2231/5987 decoding. The extended parameter syntax (filename*=charset'lang'value,name*=..., and thefilename*0/filename*1continuation form) is decoded and surfaced under the barefilename/namekey, and overrides the plain parameter when both are present. RFC 7578 §4.2 explicitly forbids thefilename*form inmultipart/form-data.Components that follow RFC 7578, or that do not implement RFC 2231/5987 decoding for
multipart/form-data(WAFs, proxies, gateways), may interpret such a header differently. An attacker can exploit that difference to smuggle a different field name or filename past an upstream inspector to the backend.Details
Given both a plain and an extended parameter, the extended value won. For example:
An inspector following RFC 7578 sees the field
comment, while the returned value wasname=role. The same applies to filenames:The inspector sees
safe.txt, while the returned value wasfilename=evil.php. Continuation parameters (filename*0,filename*1, and so on) were likewise reassembled into afilenameinvisible to a plainfilename=match, and percent encoded sequences in the extended value were decoded (so..%2F,%00, and similar appeared in the returned filename).This affects the high level
parse_options_header,FormParser,create_form_parser, andparse_formAPIs, and reaches Starlette/FastAPI throughrequest.form(), where the smuggled value is exposed as the form field name orUploadFile.filename.Impact
This is an interpretation conflict (CWE-436) with other
multipart/form-dataparsers. An attacker able to submitmultipart/form-datacan present a different field name or filename to an upstream body inspecting component than the one delivered to the application. Concrete consequences depend on how the application uses these values, and may include bypassing a field name or filename based access/upload control, or, for an application that builds filesystem paths from the parsed filename without sanitization, path traversal via decoded..%2Fsequences. Decoded control bytes such as%00can likewise cause confusion between an upstream validator and the backend. TheFileclass appliesos.path.basename, so file writing through it is not directly affected.Mitigation
Upgrade to
python-multipart0.0.30or later, which ignores RFC 2231/5987 extended parameters (name*,filename*, and their continuations) so the plainname/filenameparameter remains authoritative. RFC 7578 §4.2 forbidsfilename*formultipart/form-data;name*and the continuation forms are dropped for the same reason, since they are not validmultipart/form-dataparameters either.Severity
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
python-multipart: Semicolon treated as querystring field separator enables parameter smuggling
CVE-2026-53538 / GHSA-6jv3-5f52-599m
More information
Details
Summary
QuerystringParsertreated;as a field separator inapplication/x-www-form-urlencodedbodies, in addition to&. The WHATWG URL standard, modern browsers, and Python'surllib.parse(since the CVE-2021-23336 fix) treat only&as a separator. This creates a parser differential: the same bytes are tokenized into different fields than a WHATWG compliant intermediary would produce, allowing an attacker to smuggle extra form fields past an upstream body inspecting component.Details
In
python_multipart/multipart.py, theFIELD_NAMEandFIELD_DATAstates located the next separator by scanning for&and, failing that, for;:As a result,
;acted as a field boundary. Because the fallback only triggered when no&remained in the current chunk, tokenization also depended on unrelated bytes later in the buffer and on how the body was split acrosswrite()calls. This is the same class of issue as CVE-2021-23336 in CPython'surllib.parse.For example, a body inspecting WAF or gateway that follows the WHATWG rule (only
&separates fields) receives:The upstream parses two fields,
role=userandx=";role=admin", sees a benignrole=user, and forwards the request.QuerystringParserparsed the same bytes as three fields:role="user",x="", androle="admin". The application (for example via Starlette/FastAPIrequest.form(), where the last value wins) then receivedrole=admin, a value the upstream validator never saw.The parser is reachable through the public
QuerystringParserclass, the high levelFormParser,create_form_parser, andparse_formAPIs, and Starlette/FastAPIrequest.form()for url encoded bodies.Impact
Interpretation conflict / HTTP parameter pollution. An attacker can smuggle extra or overriding form fields past an upstream component that applies the WHATWG separator rule, reaching the backend with parameters the intermediary did not observe.
Mitigation
Upgrade to
python-multipart0.0.30or later, which treats only&as a field separator per the WHATWG URL standard.;is parsed as ordinary field data, matchingurllib.parse, browsers, and other compliant parsers.Severity
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
python-multipart: Negative Content-Length in parse_form buffers the entire body in memory
CVE-2026-53540 / GHSA-v9pg-7xvm-68hf
More information
Details
Summary
parse_form()did not validate theContent-Lengthheader before using it to bound its chunked read of the request body. A negativeContent-Lengthturned 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.Details
parse_form()reads the input stream in chunks, never reading more than the remainingContent-Lengthat a time. The per-chunk size is computed asmin(content_length - bytes_read, chunk_size). The header value was parsed to an integer without checking its sign, so aContent-Lengthof-1made this expression negative, andinput_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.Impact
This only affects code that calls
parse_form()directly with aContent-Lengthheader taken from attacker-controlled input and without normalizing a negative value first. No known package is affected:MultipartParserdirectly from the ASGIreceive()stream and do not callparse_form().parse_form()consumers either do not forwardContent-Lengthto it, recompute it from the already-read body, or run behind a layer (such as Werkzeug) that normalizes a negativeContent-Lengthto0.The realistic exposure is limited to bespoke WSGI or
http.serverhandlers that forward raw client headers intoparse_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.Mitigation
Upgrade to version
0.0.31or later, which rejects a negativeContent-Lengthwith aValueErrorbefore reading the stream.Severity
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:LReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
python-multipart: Quadratic-time querystring parsing with semicolon separators causes CPU denial of service
CVE-2026-53539 / GHSA-5rvq-cxj2-64vf
More information
Details
Summary
When parsing
application/x-www-form-urlencodedbodies,QuerystringParserlocated 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 theFIELD_NAMEandFIELD_DATAstates located the next separator like this:data.find(b"&", i)scans fromito the end of the buffer and returns-1only 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 withContent-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
QuerystringParserclass and through the high levelFormParser,create_form_parser, andparse_formAPIs for url encoded bodies. It is also the parser Starlette and FastAPI use forapplication/x-www-form-urlencodedrequest bodies viarequest.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-multipart0.0.30or 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.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:HReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Release Notes
Kludex/python-multipart (python-multipart)
v0.0.31Compare Source
Content-Lengthis non-negative inparse_form#297.v0.0.30Compare Source
application/x-www-form-urlencodedbodies per the WHATWG URL standard, treating only&as a field separator #290.name*,filename*) inparse_options_header, keeping the plain parameter authoritative per RFC 7578 §4.2 #291.v0.0.29Compare Source
parse_options_header#270.v0.0.28Compare Source
bytes.find#281.v0.0.27Compare Source
v0.0.26Compare Source
v0.0.25Compare Source
File#143.FormParserclasses #257.UPLOAD_DELETE_TMPtoFormParserconfig #254.field_endfor trailing bare field names on finalize #230.v0.0.24Compare Source
chunk_sizeinparse_form()#244.v0.0.23Compare Source
trust_x_headersparameter andX-File-Namefallback #196.QuerystringParser._internal_write#229.__init__.py#227.v0.0.22Compare Source
File9433f4b.v0.0.21Compare Source
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.