CVE-2023-30798: MultipartParser DOS with too many fields or files in Starlette Framework
Duplicate Advisory This advisory has been withdrawn because it is a duplicate of GHSA-74m5-2c7w-9w3x. This link is maintained to preserve external references.
Original Description There MultipartParser usage in Encode's Starlette python framework before versions 0.25.0 allows an unauthenticated and remote attacker to specify any number of form fields or files which can cause excessive memory usage resulting in denial of service of the HTTP service.
Other sources
Impact
The MultipartParser using the package python-multipart accepts 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 <abbr title="out of memory">OOM</abbr> 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:
Have python-multipart installed and call request.form() or via another framework like FastAPI, using form field parameters or UploadFile parameters, which in turn calls request.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):
maxfiles=1000 maxfields=1000
Workarounds
Applications that don't install python-multipart or that don't use form fields are safe.
In older versions, it's also possible to instead of calling request.form() call request.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-data is structured and parsed are in the RFC 7578.
— GitHub
Encode Starlette is vulnerable to a denial of service, caused by a flaw with accepting unlimited number of multipart parts in the python-multipart package in the MultipartParser. By sending a specially-crafted request, a remote attacker could exploit this vulnerability to cause high CPU and memory usages, and results in a denial of service condition.
— IBM
Affected Software
Remediation
Event History
Frequently Asked Questions
What is CVE-2023-30798?
CVE-2023-30798 is a vulnerability in the MultipartParser of Encode Starlette, which allows an attacker to cause a denial of service by sending specially-crafted requests.
What is the severity of CVE-2023-30798?
The severity of CVE-2023-30798 is high, with a CVSS score of 7.5.
How does CVE-2023-30798 affect Starlette framework?
CVE-2023-30798 affects the Encode Starlette framework in versions prior to 0.25.0.
How can an attacker exploit CVE-2023-30798?
An attacker can exploit CVE-2023-30798 by sending specially-crafted requests to the affected system.
Is there a fix available for CVE-2023-30798?
Yes, the vulnerability in Encode Starlette can be fixed by upgrading to version 0.25.0 or later.