Miggo Logo

CVE-2025-62727: Starlette vulnerable to O(n^2) DoS via Range header merging in ``starlette.responses.FileResponse``

7.5

CVSS Score
3.1

Basic Information

EPSS Score
-
Published
10/28/2025
Updated
10/28/2025
KEV Status
No
Technology
TechnologyPython

Technical Details

CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Package NameEcosystemVulnerable VersionsFirst Patched Version
starlettepip<= 0.49.00.49.1

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability exists in the starlette.responses.FileResponse class, specifically within the _parse_range_header static method. The root cause is the use of a regular expression with catastrophic backtracking (re.compile(r"(\\d*)-(\\d*)")) to parse the Range HTTP header. An attacker can send a request with a crafted Range header containing a large number of specially formed substrings, which triggers a quadratic-time complexity in the regex engine, leading to excessive CPU consumption and a denial-of-service. The provided patch confirms this by removing the re.compile and the associated list comprehension that used _RANGE_PATTERN.findall(). It replaces this vulnerable logic with a new _parse_ranges method that manually and safely parses the header by splitting the string, thus avoiding the ReDoS vulnerability. Any application endpoint that serves files using starlette.responses.FileResponse or starlette.staticfiles.StaticFiles (which uses FileResponse internally) is affected.

Vulnerable functions

FileResponse._parse_range_header
starlette/responses.py
The function `_parse_range_header` in the `FileResponse` class is vulnerable to a regular expression denial-of-service (ReDoS) attack. It uses a regex `_RANGE_PATTERN = re.compile(r"(\\d*)-(\\d*)")` to parse the `Range` HTTP header. This regex has a quadratic time complexity, meaning a specially crafted `Range` header with a large number of non-overlapping ranges can cause the server's CPU to spike, leading to denial of service. The patch removes the regex-based parsing and replaces it with a safer, manual parsing implementation in a new `_parse_ranges` method.

WAF Protection Rules

WAF Rule

### Summ*ry *n un*ut**nti**t** *tt**k*r **n s*n* * *r**t** *TTP R*n** *****r t**t tri***rs qu**r*ti*-tim* pro**ssin* in St*rl*tt*'s `*il*R*spons*` R*n** p*rsin*/m*r*in* lo*i*. T*is *n**l*s *PU *x**ustion p*r r*qu*st, **usin* **ni*l‑o*‑s*rvi** *or *n*

Reasoning

T** vuln*r**ility *xists in t** `st*rl*tt*.r*spons*s.*il*R*spons*` *l*ss, sp**i*i**lly wit*in t** `_p*rs*_r*n**_*****r` st*ti* m*t*o*. T** root **us* is t** us* o* * r**ul*r *xpr*ssion wit* **t*strop*i* ***ktr**kin* (`r*.*ompil*(r"(\\**)-(\\**)")`) t