CVE-2024-47874: Starlette Denial of service (DoS) via multipart/form-data
Summary Starlette treats multipart/form-data parts without a filename as 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
python from starlette.applications import Starlette from starlette.routing import Route
async def poc(request): async with request.form(): pass
app = Starlette(routes=[ Route('/', poc, methods=["POST"]), ])
sh 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.
Other sources
Starlette is an Asynchronous Server Gateway Interface (ASGI) framework/toolkit. Prior to version 0.40.0, Starlette treats multipart/form-data parts without a filename as 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. This Denial of service (DoS) vulnerability affects all applications built with Starlette (or FastAPI) accepting form requests. Verison 0.40.0 fixes this issue.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/starletteto a version that resolves this vulnerability.Fixed in 0.40.0 - Upgrade
Upgrade
debian/starletteto a version that resolves this vulnerability.Fixed in 0.26.1-1+deb12u1 - Upgrade
Upgrade
debian/starletteto a version that resolves this vulnerability.Fixed in 0.41.0-1 - Upgrade
Upgrade
debian/starletteto a version that resolves this vulnerability.Fixed in 0.26.1-1+deb12u1Fixed in 0.26.1-1+deb12u2Fixed in 0.46.1-3+deb13u3Fixed in 1.9.0-1 - Upgrade
Upgrade
Starletteto a version that resolves this vulnerability.Fixed in 0.40.0
Event History
Frequently Asked Questions
What is the severity of CVE-2024-47874?
CVE-2024-47874 is classified as a high severity vulnerability due to the potential for denial of service attacks.
How do I fix CVE-2024-47874?
To address CVE-2024-47874, upgrade Starlette to version 0.40.0 or later.
What types of attacks are possible with CVE-2024-47874?
CVE-2024-47874 allows attackers to upload excessively large form fields, leading to performance degradation and potential denial of service.
Is CVE-2024-47874 present in earlier versions of Starlette?
Yes, CVE-2024-47874 affects all versions of Starlette prior to 0.40.0.
How can I determine if my application is affected by CVE-2024-47874?
Check if your application uses Starlette versions lower than 0.40.0 to identify if it is affected by CVE-2024-47874.