GMS-2024-92: Starlette Content-Type Header ReDoS
Summary
When using form data, python-multipart
uses a Regular Expression to parse the HTTP Content-Type
header, including options.
An attacker could send a custom-made Content-Type
option that is very difficult for the RegEx to process, consuming CPU resources and stalling indefinitely (minutes or more) while holding the main event loop. You’ll see the server locks up, is unable to serve anymore requests and one CPU core is pegged to 100%
You can even start uvicorn with multiple workers with the –workers 4 argument and as long as you send (workers + 1) requests you’ll completely DoS the FastApi server.
If you try submitting Json to the /submit_json endpoint with the malicious Content-Type header you’ll see it isn’t vulnerable. So this only affects FastAPI when it parses Form data.
References
Detect and mitigate GMS-2024-92 with GitLab Dependency Scanning
Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →