8.2high
Litestar allows unbounded resource consumption (DoS vulnerability)
- Severity
- 8.2high CVSS:4.0 by GitHub_M
- Exploit likelihood
- 0.79% (higher than 57% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-gjcc-jvgw-wvwjPYSEC-2024-178PYSEC-2026-1944
Description
Litestar is an Asynchronous Server Gateway Interface (ASGI) framework. Prior to version 2.13.0, the multipart form parser shipped with litestar expects the entire request body as a single byte string and there is no default limit for the total size of the request body. This allows an attacker to upload arbitrary large files wrapped in a `multipart/form-data` request and cause excessive memory consumption on the server. The multipart form parser in affected versions is vulnerable to this type of attack by design. The public method signature as well as its implementation both expect the entire request body to be available as a single byte string. It is not possible to accept large file uploads in a safe way using this parser. This may be a regression, as a variation of this issue was already reported in CVE-2023-25578. Limiting the part number is not sufficient to prevent out-of-memory errors on the server. A patch is available in version 2.13.0.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| litestar-org litestar | < 2.13.0, before 2.13.0 | CVE List |
| litestar (PyPI) | before 2.13.0, before 53c1473b5ff7502816a9a339ffc90731bb0c2138 | GitHub Advisory Database, PyPA Advisory Database |
| starlite (PyPI) | up to 1.51.16 | GitHub Advisory Database, PyPA Advisory Database |
| litestar litestar | before 2.13.0 | NVD |
All scores
| GitHub_M | 8.2high CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:L |
| GitHub | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| GitHub | high CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:L |
| NVD | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| PyPA Advisory Database | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| PyPA Advisory Database | Not scored CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:L |
Classification
SSVC (CISA-ADP): exploitation poc, automatable yes, technical impact partial.
What each source says
CVE List
Litestar is an Asynchronous Server Gateway Interface (ASGI) framework. Prior to version 2.13.0, the multipart form parser shipped with litestar expects the entire request body as a single byte string and there is no default limit for the total size of the request body. This allows an attacker to upload arbitrary large files wrapped in a `multipart/form-data` request and cause excessive memory consumption on the server. The multipart form parser in affected versions is vulnerable to this type of attack by design. The public method signature as well as its implementation both expect the entire request body to be available as a single byte string. It is not possible to accept large file uploads in a safe way using this parser. This may be a regression, as a variation of this issue was already reported in CVE-2023-25578. Limiting the part number is not sufficient to prevent out-of-memory errors on the server. A patch is available in version 2.13.0.
GitHub Advisory Database
Summary
Litestar offers multiple methods to return a parsed representation of the request body, as well as extractors that rely on those parsers to map request content to structured data types. Multiple of those parsers do not have size limits when reading the request body into memory, which allows an attacker to cause excessive memory consumption on the server by sending large requests.
Details
The Request methods to parse json, msgpack or form-data all read the entire request stream into memory via await self.body() without a prior size check or size limit. There may be other places (e.g. extractors) where this can happen.
For most formats, a configurable size limit would be sufficient to mitigate this issue. The total request size can also be limited by a proxy (e.g. nginx) in front of the actual application as a workaround. However, for applications that actually want to accept large file uploads via multipart/form-data, a simple size limit would not be practical. The multipart parser currently used by Litestar expects a single byte string as input and does not support incremental parsing via Request.stream(). Applications could bypass the Litestar parser and use a streaming parser to read from Request.stream() instead, but that would not work with extractors and other features of the framework. Switching the parser for a different implementation is currently not possible via public APIs.
PoC
Start an applications that accesses Request.json(), Request.msgpack() or Request.form() or uses an extractor that relies on those parsers internally, and send a large request with a matching content type. The actual content of the request does not matter. For example: curl -F "foo=</dev/random" http://127.0.0.1:8000/) for multipart/form-data. Server memory consumption will increase very quickly until memory (and swap) are exhausted.
Impact
This is a denial of service (DoS) vulnerability affecting all Litestar applications that process json, msgpack or form-data submission requests.
NVD (es)
Litestar es un framework de interfaz de puerta de enlace de servidor asincrónico (ASGI). Antes de la versión 2.13.0, el analizador de formularios multiparte que se incluye con litestar espera que todo el cuerpo de la solicitud sea una cadena de un solo byte y no hay un límite predeterminado para el tamaño total del cuerpo de la solicitud. Esto permite que un atacante cargue archivos arbitrarios de gran tamaño envueltos en una solicitud `multipart/form-data` y provoque un consumo excesivo de memoria en el servidor. El analizador de formularios multiparte en las versiones afectadas es vulnerable a este tipo de ataque por diseño. La firma del método público, así como su implementación, esperan que todo el cuerpo de la solicitud esté disponible como una cadena de un solo byte. No es posible aceptar cargas de archivos grandes de forma segura utilizando este analizador. Esto puede ser una regresión, ya que ya se informó de una variación de este problema en CVE-2023-25578. Limitar el número de partes no es suficiente para evitar errores de falta de memoria en el servidor. Hay un parche disponible en la versión 2.13.0.
References
Related
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2024-52581 changed 2024-11-25 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-gjcc-jvgw-wvwj changed 2026-07-07 | CC-BY-4.0 |
| NVD | CVE-2024-52581 changed 2026-06-17 | Public domain |
| PyPA Advisory Database | PYSEC-2024-178 changed 2026-07-07 | CC-BY-4.0 |
| PyPA Advisory Database | PYSEC-2026-1944 changed 2026-07-07 | CC-BY-4.0 |