Update dependency starlette to v1 [SECURITY]#162
Open
renovate[bot] wants to merge 1 commit into
Open
Conversation
10677d2 to
f5b4222
Compare
f5b4222 to
769dd8e
Compare
769dd8e to
11a39e4
Compare
11a39e4 to
b243571
Compare
Contributor
Author
|
b243571 to
48b6690
Compare
48b6690 to
4f0fcd5
Compare
4f0fcd5 to
03b8d70
Compare
03b8d70 to
dae75b2
Compare
dae75b2 to
4dd97b5
Compare
4dd97b5 to
dc7a9c9
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.22.0→^1.0.0==0.25.0→==1.0.1MultipartParser denial of service with too many fields or files
CVE-2023-30798 / GHSA-74m5-2c7w-9w3x
More information
Details
Impact
The
MultipartParserusing the packagepython-multipartaccepts an unlimited number of multipart parts (form fields or files).Processing too many parts results in high CPU usage and high memory usage, eventually leading to an OOM process kill.
This can be triggered by sending too many small form fields with no content, or too many empty files.
For this to take effect application code has to:
python-multipartinstalled andrequest.form()UploadFileparameters, which in turn callsrequest.form().Patches
The vulnerability is solved in Starlette 0.25.0 by making the maximum fields and files customizable and with a sensible default (1000).
Applications will be secure by just upgrading their Starlette version to 0.25.0 (or FastAPI to 0.92.0).
If application code needs to customize the new max field and file number, there are new
request.form()parameters (with the default values):max_files=1000max_fields=1000Workarounds
Applications that don't install
python-multipartor that don't use form fields are safe.In older versions, it's also possible to instead of calling
request.form()callrequest.stream()and parse the form data in internal code.In most cases, the best solution is to upgrade the Starlette version.
References
This was reported in private by @das7pad via internal email. He also coordinated the fix across multiple frameworks and parsers.
The details about how
multipart/form-datais structured and parsed are in the RFC 7578.Severity
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Starlette has Path Traversal vulnerability in StaticFiles
CVE-2023-29159 / GHSA-v5gw-mw7f-84px
More information
Details
Summary
When using
StaticFiles, if there's a file or directory that starts with the same name as theStaticFilesdirectory, that file or directory is also exposed viaStaticFileswhich is a path traversal vulnerability.Details
The root cause of this issue is the usage of
os.path.commonprefix():https://github.com/encode/starlette/blob/4bab981d9e870f6cee1bd4cd59b87ddaf355b2dc/starlette/staticfiles.py#L172-L174
As stated in the Python documentation (https://docs.python.org/3/library/os.path.html#os.path.commonprefix) this function returns the longest prefix common to paths.
When passing a path like
/static/../static1.txt,os.path.commonprefix([full_path, directory])returns./staticwhich is the common part of./static1.txtand./static, It refers to/static/../static1.txtbecause it is considered in the staticfiles directory. As a result, it becomes possible to view files that should not be open to the public.The solution is to use
os.path.commonpathas the Python documentation explains thatos.path.commonprefixworks a character at a time, it does not treat the arguments as paths.PoC
In order to reproduce the issue, you need to create the following structure:
And run the
Starletteapp with:And running the commands:
The
static1.txtand the directorystatic_disalloware exposed.Impact
Confidentiality is breached: An attacker may obtain files that should not be open to the public.
Credits
Security researcher Masashi Yamane of LAC Co., Ltd reported this vulnerability to JPCERT/CC Vulnerability Coordination Group and they contacted us to coordinate a patch for the security issue.
Severity
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Starlette Denial of service (DoS) via multipart/form-data
CVE-2024-47874 / GHSA-f96h-pmfr-66vw
More information
Details
Summary
Starlette treats
multipart/form-dataparts without afilenameas text form fields and buffers those in byte strings with no size limit. This allows an attacker to upload arbitrary large form fields and cause Starlette to both slow down significantly due to excessive memory allocations and copy operations, and also consume more and more memory until the server starts swapping and grinds to a halt, or the OS terminates the server process with an OOM error. Uploading multiple such requests in parallel may be enough to render a service practically unusable, even if reasonable request size limits are enforced by a reverse proxy in front of Starlette.PoC
curl http://localhost:8000 -F 'big=</dev/urandom'Impact
This Denial of service (DoS) vulnerability affects all applications built with Starlette (or FastAPI) accepting form requests.
Severity
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Starlette has possible denial-of-service vector when parsing large files in multipart forms
CVE-2025-54121 / GHSA-2c2j-9gv5-cj73
More information
Details
Summary
When parsing a multi-part form with large files (greater than the default max spool size)
starlettewill block the main thread to roll the file over to disk. This blocks the event thread which means we can't accept new connections.Details
Please see this discussion for details: https://github.com/encode/starlette/discussions/2927#discussioncomment-13721403. In summary the following UploadFile code (copied from here) has a minor bug. Instead of just checking for
self._in_memorywe should also check if the additional bytes will cause a rollover.I have already created a PR which fixes the problem: https://github.com/encode/starlette/pull/2962
PoC
See the discussion here for steps on how to reproduce.
Impact
To be honest, very low and not many users will be impacted. Parsing large forms is already CPU intensive so the additional IO block doesn't slow down
starlettethat much on systems with modern HDDs/SSDs. If someone is running on tape they might see a greater impact.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).
Starlette has missing Host header validation that poisons request.url.path, bypassing path-based security checks
CVE-2026-48710 / GHSA-86qp-5c8j-p5mr
More information
Details
Summary
In affected versions, the HTTP
Hostrequest header was not validated before being used to reconstructrequest.url. Because the routing algorithm relies on the raw HTTP path whilerequest.urlis rebuilt from theHostheader, a malformed header could makerequest.url.pathdiffer from the path that was actually requested. Middleware and endpoints that apply security restrictions based onrequest.url(rather than the rawscopepath) could therefore be bypassed.Details
When a client requests
http://example.com/foo, it sends:Affected versions reconstructed the URL by concatenating
http://{host}{path}and re-parsing the result. TheHostvalue is only valid as auri-host [ ":" port ]per RFC 9112 §3.2, whereuri-hostfollows the restrictedhostgrammar of RFC 3986 §3.2.2. When it contains characters outside that grammar - notably/,?, or#- those characters move the path/query/fragment boundaries during re-parsing, so the parsedrequest.url.pathno longer matches the path the server actually received. For example:reconstructs to
http://example.com/abc?bar=/foo, whose parsedpathis/abc- even though routing used the real path/foo. The router still dispatches to/fooand the endpoint executes, but any middleware or code that readsrequest.url.pathsees/abc, so path-based authorization checks can be bypassed.Impact
Any application running an affected version that relies on
request.url(orrequest.url.path) for security-sensitive decisions is affected. The most common case is middleware that gates access to certain path prefixes based onrequest.url.path. Deployments fronted by a proxy or load balancer are mitigated only if that proxy rejects or normalizes the malformedHostheader before forwarding and the application does not trust attacker-controlled host headers (e.g.X-Forwarded-Host) elsewhere.Mitigation
Upgrade to a patched version, which validates the
Hostheader against the grammar of RFC 9112 §3.2 / RFC 3986 §3.2.2 when constructingrequest.urland falls back toscope["server"]for malformed values.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Release Notes
Kludex/starlette (starlette)
v1.0.1: Version 1.0.1Compare Source
What's Changed
Hostheader when constructingrequest.urlby @Kludex in #3279Full Changelog: Kludex/starlette@1.0.0...1.0.1
v1.0.0: Version 1.0.0Compare Source
Starlette 1.0 is here! 🎉
After nearly eight years since its creation, Starlette has reached its first stable release.
A special thank you to @lovelydinosaur, the creator of Starlette, Uvicorn, HTTPX and MkDocs, whose work helped to lay the foundation for the modern async Python ecosystem. 🙏
Thank you to @adriangb, @graingert, @agronholm, @florimondmanca, @aminalaee, @tiangolo, @alex-oleshkevich, @abersheeran, and @uSpike for helping make Starlette what it is today. And to all my sponsors - especially @tiangolo, @huggingface, and @elevenlabs - thank you for your support!
Thank you to all 290+ contributors who have shaped Starlette over the years! ❤️
Read more on the blog post.
Check out the full release notes at https://www.starlette.io/release-notes/#100-march-22-2026
Full Changelog: Kludex/starlette@1.0.0rc1...1.0.0
v0.52.1: Version 0.52.1Compare Source
What's Changed
typing_extensionsin older Python versions by @Kludex in #3109Full Changelog: Kludex/starlette@0.52.0...0.52.1
v0.52.0: Version 0.52.0Compare Source
In this release,
Statecan be accessed using dictionary-style syntax for improved type safety (#3036).See Accessing State for more details.
Full Changelog: Kludex/starlette@0.51.0...0.52.0
v0.51.0: Version 0.51.0Compare Source
Added
allow_private_networkinCORSMiddleware#3065.Changed
DeprecationWarningfor wsgi module #3082.New Contributors
Full Changelog: Kludex/starlette@0.50.0...0.51.0
v0.50.0: Version 0.50.0Compare Source
Removed
Full Changelog: Kludex/starlette@0.49.3...0.50.0
v0.49.3: Version 0.49.3Compare Source
Fixed
Middlewaretype #3059.Full Changelog: Kludex/starlette@0.49.2...0.49.3
v0.49.2: Version 0.49.2Compare Source
Fixed
if-modified-sinceheader ifif-none-matchis present inStaticFiles#3044.Full Changelog: Kludex/starlette@0.49.1...0.49.2
v0.49.1: Version 0.49.1Compare Source
This release fixes a security vulnerability in the parsing logic of the
Rangeheader inFileResponse.You can view the full security advisory: GHSA-7f5h-v6xp-fcq8
Fixed
Full Changelog: Kludex/starlette@0.49.0...0.49.1
v0.49.0: Version 0.49.0Compare Source
Added
encodingparameter toConfigclass #2996.Request.cookies#3029.Literaltype forWebSocketEndpointencoding values #3027.Changed
Middlewarewhen usingBaseHTTPMiddleware#2976.New Contributors
Full Changelog: Kludex/starlette@0.48.0...0.49.0
v0.48.0: Version 0.48.0Compare Source
Added
Changed
New Contributors
Full Changelog: Kludex/starlette@0.47.3...0.48.0
v0.47.3: Version 0.47.3Compare Source
Fixed
asyncio.iscoroutinefunctionfor Python 3.12 and older by @mjpieters in encode#2984New Contributors
Full Changelog: Kludex/starlette@0.47.2...0.47.3
v0.47.2Compare Source
Fixed
UploadFilecheck for future rollover #2962.New Contributors
Full Changelog: Kludex/starlette@0.47.1...0.47.2
v0.47.1: Version 0.47.1Compare Source
Fixed
SelfinTestClient.__enter__#2951Full Changelog: Kludex/starlette@0.47.0...0.47.1
v0.47.0: Version 0.47.0Compare Source
Added
pathsendextension #2671.partitionedattribute toResponse.set_cookie#2501.Changed
methodsparameter type fromlist[str]toCollection[str]#2903.import typingbyfrom typing import ...in the whole codebase #2867.Fixed
ExceptionMiddleware.http_exceptionas async to prevent thread creation #2922.New Contributors
Full Changelog: Kludex/starlette@0.46.2...0.47.0
v0.46.2: Version 0.46.2Compare Source
What's Changed
TemplateResponseby @alex-oleshkevich in encode#2909BaseHTTPMiddlewareby @ramannanda9 in encode#2911New Contributors
Full Changelog: Kludex/starlette@0.46.1...0.46.2
v0.46.1: Version 0.46.1Compare Source
Fixed
follow_symlinks=True#2896.Full Changelog: Kludex/starlette@0.46.0...0.46.1
v0.46.0: Version 0.46.0Compare Source
Added
GZipMiddleware: Make sureVaryheader is always added if a response can be compressed #2865.Fixed
GZipMiddleware: Don't compress on server sent events #2871.Changed
MultiPartParser: Renamemax_file_sizetospool_max_size#2780.Deprecated
TestClient(timeout=...)#2840.New Contributors
Full Changelog: Kludex/starlette@0.45.3...0.46.0
v0.45.3: Version 0.45.3Compare Source
Fixed
lookup_pathon commonpath comparison by @Kludex in encode#2851Full Changelog: Kludex/starlette@0.45.2...0.45.3
v0.45.2: Version 0.45.2Compare Source
Fixed
create_memory_object_streamcompatible with old anyio versions once again, and bump anyio minimum version to 3.6.2 by @graingert in #2833.Full Changelog: Kludex/starlette@0.45.1...0.45.2
v0.45.1: Version 0.45.1Compare Source
Fixed
MemoryObjectReceiveStreamupon exception inBaseHTTPMiddlewarechildren by @Kludex in encode#2813Refactor
Full Changelog: Kludex/starlette@0.45.0...0.45.1
v0.45.0: Version 0.45.0Compare Source
Removed
ExceptionMiddlewareimport proxy fromstarlette.exceptionsmodule by @Kludex in encode#2826WS_1004_NO_STATUS_RCVDandWS_1005_ABNORMAL_CLOSUREby @Kludex in encode#2827Full Changelog: Kludex/starlette@0.44.0...0.45.0
v0.44.0: Version 0.44.0Compare Source
Added
max_part_sizeparameter toRequest.form()by @iudeen in encode#2815clientparameter toTestClientby @iudeen in encode#2810New Contributors
Full Changelog: Kludex/starlette@0.43.0...0.44.0
v0.43.0: Version 0.43.0Compare Source
Removed
allow_redirectsargument fromTestClient#2808.Added
New Contributors
Full Changelog: Kludex/starlette@0.42.0...0.43.0
v0.42.0: Version 0.42.0Compare Source
Added
ClientDisconnectonStreamingResponse#2732.Fixed
StaticFileswhenfollow_symlinks=True#2711.python-multipartversion to0.0.180ba8395.httpxversion to0.27.0#2773.New Contributors
Full Changelog: Kludex/starlette@0.41.3...0.42.0
v0.41.3: Version 0.41.3Compare Source
Fixed
scope[raw_path]on theTestClient#2716.dictbyMappingonHTTPException.headers#2749.Full Changelog: Kludex/starlette@0.41.2...0.41.3
v0.41.2: Version 0.41.2Compare Source
What's Changed
python-multipartby @Kludex in encode#2737Full Changelog: Kludex/starlette@0.41.1...0.41.2
v0.41.1: Version 0.41.1Compare Source
What's Changed
python-multipartimport topython_multipartby @Kludex in encode#2733python-multipartversion to 0.0.13 by @Kludex in encode#2734Full Changelog: Kludex/starlette@0.41.0...0.41.1
v0.41.0: Version 0.41.0Compare Source
Added
HTTPExceptionbeforewebsocket.accept()encode#2725v0.40.0: Version 0.40.0Compare Source
This release fixes a Denial of service (DoS) via
multipart/form-datarequests.You can view the full security advisory:
GHSA-f96h-pmfr-66vw
Fixed
max_part_sizetoMultiPartParserto limit the size of parts inmultipart/form-datarequests fd038f3.
v0.39.2: Version 0.39.2Compare Source
Fixed
request.url_forwhen only "app" scope is available #2672.python-multipart==0.0.12#2708.Full Changelog: Kludex/starlette@0.39.1...0.39.2
v0.39.1: Version 0.39.1Compare Source
Fixed
responses.pyandschemas.py#2700.get_route_pathby removing regular expression usage #2701.FileResponse.chunk_sizewhen handling multiple ranges #2703.token_hexfor generating multipart boundary strings #2702.Full Changelog: Kludex/starlette@0.39.0...0.39.1
v0.39.0: Version 0.39.0Compare Source
Added
FileResponse#2697Full Changelog: Kludex/starlette@0.38.6...0.39.0
v0.38.6: Version 0.38.6Compare Source
Fixed
MemoryObjectReceiveStreaminTestClient#2693.Full Changelog: Kludex/starlette@0.38.5...0.38.6
v0.38.5: Version 0.38.5Compare Source
Fixed
BackgroundTasksfrom withinBaseHTTPMiddleware#2688.This behavior was removed in 0.38.3, and is now restored.
Full Changelog: Kludex/starlette@0.38.4...0.38.5
v0.38.4: Version 0.38.4Compare Source
Fixed
root_pathremoval inget_route_pathfunction #2600Full Changelog: Kludex/starlette@0.38.3...0.38.4
v0.38.3: Version 0.38.3Compare Source
Added
Fixed
BaseHTTPMiddlewareviaStreamingResponse#2620.Full Changelog: Kludex/starlette@0.38.2...0.38.3
v0.38.2: Version 0.38.2Compare Source
Fixed
routing.get_name()not to assume all routines have__name__#2648Full Changelog: Kludex/starlette@0.38.1...0.38.2
v0.38.1: Version 0.38.1Compare Source
Removed
Full Changelog: Kludex/starlette@0.38.0...0.38.1
v0.38.0: Version 0.38.0Compare Source
Added
memoryviewinStreamingResponseandResponse#2576and #2577.
StaticFiles#2583.Changed
Jinja2Templateinstantiation parameters #2568.Fixed
WebSocketTestSession#2597.Full Changelog: Kludex/starlette@0.37.2...0.38.0
v0.37.2: Version 0.37.2Compare Source
Added
bytesto_RequestDatatype #2510.Fixed
scope["client"]toNoneonTestClient(#2377)" #2525.appargument passed tohttpx.Clienton theTestClient#2526.Full Changelog: Kludex/starlette@0.37.1...0.37.2
v0.37.1: Version 0.37.1Compare Source
Fixed
Config#2485.Full Changelog: Kludex/starlette@0.37.0...0.37.1
v0.37.0: Version 0.37.0Compare Source
Added
Full Changelog: Kludex/starlette@0.36.3...0.37.0
v0.36.3: Version 0.36.3Compare Source
Fixed
anyio.Eventon async context #2459.Full Changelog: Kludex/starlette@0.36.2...0.36.3
v0.36.2: Version 0.36.2Compare Source
Fixed
python-multipartto0.0.713e5c26.Content-Type#2443.Full Changelog: Kludex/starlette@0.36.1...0.36.2
v0.36.1: Version 0.36.1Compare Source
Fixed
Full Changelog: Kludex/starlette@0.36.0...0.36.1
v0.36.0: Version 0.36.0Compare Source
Added
pathsendextension #2435.WebSocketTestSessionon close #2427.WebSocketDisconnectwhenWebSocket.send()exceptsIOError#2425.FileNotFoundErrorwhen theenv_fileparameter onConfigis not valid #2422.Full Changelog: Kludex/starlette@0.35.1...0.36.0
v0.35.1: Version 0.35.1Compare Source
Fixed
FileResponseinside ofStaticFiles#2406.typing-extensionsoptional again #2409.Full Changelog: Kludex/starlette@0.35.0...0.35.1
v0.35.0: Version 0.35.0Compare Source
Added
*argstoMiddlewareand improve its type hints #2381.Fixed
IterableinsteadIteratoroniterate_in_threadpool#2362.Changes
root_pathto keep compatibility with mounted ASGI applications and WSGI #2400.scope["client"]toNoneonTestClient#2377.Full Changelog: Kludex/starlette@0.34.0...0.35.0
v0.34.0: Version 0.34.0Compare Source
Added
ParamSpecforrun_in_threadpool#2375.UploadFile.__repr__#2360.Fixed
TestClient#2376.StaticFiles#2334.Deprecated
FileResponse(method=...)parameter #2366.Full Changelog: Kludex/starlette@0.33.0...0.34.0
v0.33.0: Version 0.33.0Compare Source
Added
middlewareperRoute/WebSocketRoute#2349.middlewareperRouter#2351.Fixed
"path"and"root_path"scope keys #2352.ensure_ascii=Falseonjson.dumps()forWebSocket.send_json()#2341.v0.32.0: Version 0.32.0Compare Source
Added
reasononWebSocketDisconnect#2309.domainparameter toSessionMiddleware#2280.Changed
HTMLResponseinstead ofResponseon_TemplateResponse#2274.Response.rendertype annotation to its pre-0.31.0 state #2264.Full Changelog: Kludex/starlette@0.31.1...0.32.0
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 these updates again.
This PR was generated by Mend Renovate. View the repository job log.