{"id":"CVE-2025-54121","aliases":["CVE-2025-54121","GHSA-2c2j-9gv5-cj73","PYSEC-2026-1941"],"related":[],"kind":"vulnerability","state":"published","title":"Starlette has possible denial-of-service vector when parsing large files in multipart forms","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"### Summary\nWhen parsing a multi-part form with large files (greater than the [default max spool size](https://github.com/encode/starlette/blob/fa5355442753f794965ae1af0f87f9fec1b9a3de/starlette/formparsers.py#L126)) `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.\n\n### Details\nPlease see this discussion for details: https://github.com/encode/starlette/discussions/2927#discussioncomment-13721403. In summary the following UploadFile code (copied from [here](https://github.com/encode/starlette/blob/fa5355442753f794965ae1af0f87f9fec1b9a3de/starlette/datastructures.py#L436C5-L447C14)) has a minor bug. Instead of just checking for `self._in_memory` we should also check if the additional bytes will cause a rollover.\n\n```python\n\n    @property\n    def _in_memory(self) -> bool:\n        # check for SpooledTemporaryFile._rolled\n        rolled_to_disk = getattr(self.file, \"_rolled\", True)\n        return not rolled_to_disk\n\n    async def write(self, data: bytes) -> None:\n        if self.size is not None:\n            self.size += len(data)\n\n        if self._in_memory:\n            self.file.write(data)\n        else:\n            await run_in_threadpool(self.file.write, data)\n```\n\nI have already created a PR which fixes the problem: https://github.com/encode/starlette/pull/2962\n\n\n### PoC\nSee the discussion [here](https://github.com/encode/starlette/discussions/2927#discussioncomment-13721403) for steps on how to reproduce.\n\n### Impact\nTo 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.","format":"markdown","source":"ghsa"},{"lang":"es","text":"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.","source":"nvd"}],"published":"2025-07-21T19:34:23.000Z","modified":"2026-09-10T03:50:25.704Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L","score":5.3,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L","score":5.3,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L","score":5.3,"rating":"MEDIUM"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L","score":5.3,"rating":"MEDIUM"}],"cwes":["CWE-770"],"affected":[{"ranges":[{"version":"< 0.47.2","status":"affected"}],"vendor":"encode","product":"starlette","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"0.47.2"}],"ecosystem":"PyPI","package":"starlette","purl":"pkg:pypi/starlette","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"0.47.2"}],"ecosystem":"PyPI","package":"starlette","purl":"pkg:pypi/starlette","source":"pysec"}],"references":[{"url":"https://github.com/encode/starlette/security/advisories/GHSA-2c2j-9gv5-cj73","tags":["web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/encode/starlette/commit/9f7ec2eb512fcc3fe90b43cb9dd9e1d08696bec1","tags":["fix","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/encode/starlette/blob/fa5355442753f794965ae1af0f87f9fec1b9a3de/starlette/datastructures.py#L436C5-L447C14","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/encode/starlette/discussions/2927#discussioncomment-13721403","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2025-54121","tags":["advisory"],"sources":["ghsa","pysec"]},{"url":"https://github.com/encode/starlette","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/starlette","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-2c2j-9gv5-cj73","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2025-07-22T19:54:16.504Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-54121","url":"https://www.cve.org/CVERecord?id=CVE-2025-54121","licence":"CVE Terms of Use","modified":"2025-07-22T19:54:24.784Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-2c2j-9gv5-cj73","url":"https://github.com/advisories/GHSA-2c2j-9gv5-cj73","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:25.704Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-54121","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-54121","licence":"Public domain","modified":"2026-06-17T09:39:29.220Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-1941","url":"https://osv.dev/vulnerability/PYSEC-2026-1941","licence":"CC-BY-4.0","modified":"2026-07-07T17:47:58.806Z"}],"updatedAt":"2026-11-25T22:59:01.515Z","epss":{"score":0.0066,"percentile":0.52845,"date":"2026-12-01T12:00:22.000Z"}}