CVE-2024-52581: Litestar Remote Code Execution Vulnerability

HIGH
Advisory Identifier: GHSA-gjcc-jvgw-wvwj
CVSS 7.5
CWE-770
Published
Advisory Summary

CVE-2024-52581 is a HIGH (CVSS 7.5) remote code execution vulnerability (CWE-770: Allocation of Resources Without Limits or Throttling) affecting Litestar libraries in the PyPI ecosystem. The issue involves litestar allows unbounded resource consumption (dos vulnerability). Remediation is available by upgrading affected packages to version 2.13.0.

CVE-2024-52581 at a Glance

CVE Identifier CVE-2024-52581
GHSA Identifier GHSA-gjcc-jvgw-wvwj
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-770: Allocation of Resources Without Limits or Throttling
Affected Product Litestar
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2024-52581

To remediate this vulnerability, upgrade all affected Litestar dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

litestar fixed: 2.13.0
pip install litestar>=2.13.0
starlite fixed: Latest secure release
pip install starlite>=Latest secure release
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show litestar

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2024-52581, inspect your installed packages using pip:

pip show litestar

Analyze the terminal output to locate any version of Litestar in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.13.0), your application is affected.

Note: The pip show litestar command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-770: Allocation of Resources Without Limits or Throttling, where the product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated. In Litestar, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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](https://pypi.org/project/multipart/) 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.

CVE-2024-52581 Affected Litestar Versions

2 component(s)
Fixed Versions:
2.13.0
Product / Package Ecosystem Affected Versions Fixed Version
litestar
PyPI
< 2.13.0
2.13.0
starlite
PyPI
≤ 1.51.16

References

Frequently Asked Questions

What is CVE-2024-52581?
CVE-2024-52581 is a security vulnerability in Litestar involving Litestar allows unbounded resource consumption (DoS vulnerability) under CWE-770: Allocation of Resources Without Limits or Throttling.
Which Litestar versions are affected?
Affected versions include releases prior to 2.13.0 across affected packages: litestar, starlite.
What version fixes CVE-2024-52581?
Upgrading to 2.13.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is litestar affected?
Yes, litestar is affected in releases prior to 2.13.0. Upgrade your dependency to 2.13.0 or later.
Is starlite affected?
Yes, starlite is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2024-52581?
CVE-2024-52581 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2024-52581?
CVE-2024-52581 is classified under CWE-770: Allocation of Resources Without Limits or Throttling (The product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated.).
How can I check PyPI dependencies for CVE-2024-52581?
Run the dependency tree command: 'pip show litestar'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-gjcc-jvgw-wvwj",
  "modified" : "2025-01-21T18:12:08Z",
  "published" : "2024-11-20T21:38:58Z",
  "aliases" : [ "CVE-2024-52581" ],
  "summary" : "Litestar allows unbounded resource consumption (DoS vulnerability) ",
  "details" : "### Summary\nLitestar 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.\n\n### Details\nThe `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.\n\nFor 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](https://pypi.org/project/multipart/) 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.\n\n### PoC\nStart 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.\n\n### Impact\nThis is a denial of service (DoS) vulnerability affecting all Litestar applications that process json, msgpack or form-data submission requests.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "litestar"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.13.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.12.1"
    }
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "starlite"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "1.51.16"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/litestar-org/litestar/security/advisories/GHSA-gjcc-jvgw-wvwj"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/litestar-org/litestar/security/advisories/GHSA-p24m-863f-fm6q"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-52581"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/litestar-org/litestar/commit/53c1473b5ff7502816a9a339ffc90731bb0c2138"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/litestar-org/litestar"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/litestar-org/litestar/blob/main/litestar/_multipart.py#L97"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/litestar/PYSEC-2024-178.yaml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-770" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-11-20T21:38:58Z",
    "nvd_published_at" : "2024-11-20T21:15:08Z"
  }
}