CVE-2025-54121
JSON

5.3medium

Starlette has possible denial-of-service vector when parsing large files in multipart forms

Severity
5.3medium CVSS:3.1 by GitHub_M
Exploit likelihood
0.66% (higher than 52% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-2c2j-9gv5-cj73PYSEC-2026-1941

Description

Starlette is a lightweight ASGI (Asynchronous Server Gateway Interface) framework/toolkit, designed for building async web services in Python. In versions 0.47.1 and below, when parsing a multi-part form with large files (greater than the default max spool size) starlette will block the main thread to roll the file over to disk. This blocks the event thread which means the application can't accept new connections. The UploadFile code has a minor bug where instead of just checking for self._in_memory, the logic should also check if the additional bytes will cause a rollover. The vulnerability is fixed in version 0.47.2.

Affected

Product or packageVersionsReported by
encode starlette< 0.47.2CVE List
starlette (PyPI)before 0.47.2GitHub Advisory Database, PyPA Advisory Database

All scores

GitHub_M5.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
GitHub5.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
PyPA Advisory Database5.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L

Classification

CWE-770

SSVC (CISA-ADP): exploitation poc, automatable no, technical impact partial.

What each source says

CVE List

Starlette is a lightweight ASGI (Asynchronous Server Gateway Interface) framework/toolkit, designed for building async web services in Python. In versions 0.47.1 and below, when parsing a multi-part form with large files (greater than the default max spool size) starlette will block the main thread to roll the file over to disk. This blocks the event thread which means the application can't accept new connections. The UploadFile code has a minor bug where instead of just checking for self._in_memory, the logic should also check if the additional bytes will cause a rollover. The vulnerability is fixed in version 0.47.2.

GitHub Advisory Database
Summary

When parsing a multi-part form with large files (greater than the default max spool size) starlette will block the main thread to roll the file over to disk. This blocks the event thread which means we can't accept new connections.

Details

Please see this discussion for details: https://github.com/encode/starlette/discussions/2927#discussioncomment-13721403. In summary the following UploadFile code (copied from here) has a minor bug. Instead of just checking for self._in_memory we should also check if the additional bytes will cause a rollover.


    @property
    def _in_memory(self) -> bool:
        # check for SpooledTemporaryFile._rolled
        rolled_to_disk = getattr(self.file, "_rolled", True)
        return not rolled_to_disk

    async def write(self, data: bytes) -> None:
        if self.size is not None:
            self.size += len(data)

        if self._in_memory:
            self.file.write(data)
        else:
            await run_in_threadpool(self.file.write, data)

I have already created a PR which fixes the problem: https://github.com/encode/starlette/pull/2962

PoC

See the discussion here for steps on how to reproduce.

Impact

To be honest, very low and not many users will be impacted. Parsing large forms is already CPU intensive so the additional IO block doesn't slow down starlette that much on systems with modern HDDs/SSDs. If someone is running on tape they might see a greater impact.

NVD (es)

Starlette es un framework/kit de herramientas ASGI (Interfaz de Puerta de Enlace de Servidor Asíncrona) ligero, diseñado para crear servicios web asíncronos en Python. En las versiones 0.47.1 y anteriores, al analizar un formulario multiparte con archivos grandes (superiores al tamaño máximo de spool predeterminado), Starlette bloquea el hilo principal para que no transfiera el archivo al disco. Esto bloquea el hilo de eventos, lo que impide que la aplicación acepte nuevas conexiones. El código UploadFile presenta un pequeño error: en lugar de simplemente comprobar self._in_memory, la lógica también debería comprobar si los bytes adicionales provocarán una transferencia. Esta vulnerabilidad se corrigió en la versión 0.47.2.

References

Sources

SourceRecordLicence
CVE ListCVE-2025-54121 changed 2025-07-22CVE Terms of Use
GitHub Advisory DatabaseGHSA-2c2j-9gv5-cj73 changed 2026-09-10CC-BY-4.0
NVDCVE-2025-54121 changed 2026-06-17Public domain
PyPA Advisory DatabasePYSEC-2026-1941 changed 2026-07-07CC-BY-4.0