Skip to content
DoS Write-up Intermediate

A Deep Dive into FastAPI’s Security Vulnerability: CVE-2024–24762

A ReDoS vulnerability in FastAPI's form data handling via python-multipart allows an attacker to send a crafted Content-Type header that causes excessive CPU consumption, stalling the event loop. This can lead to denial of service, preventing the application from handling legitimate requests.

elniak Follow

Published on systemweakness.com

CVE-2024–24762, a recently uncovered vulnerability within the FastAPI framework, casts a spotlight on the critical need for vigilant security practices.

ElNiak, on systemweakness.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the regular expression used by python-multipart to parse the Content-Type header has catastrophic backtracking, allowing a crafted header to cause excessive CPU consumption.

Impact

An attacker could cause a denial of service by stalling the main event loop, preventing the application from handling legitimate requests and potentially leading to significant downtime.

What the attacker needed

FastAPI version up to 0.109.0; python-multipart dependency; ability to send HTTP requests

The fix

The vulnerability was fixed in FastAPI version 0.109.1; developers should upgrade to this version or later.

How it was found

  1. Set up a FastAPI application with a form submission endpoint.
  2. Craft a malicious Content-Type header with a long boundary value designed to trigger regex backtracking.
  3. Send a POST request to the endpoint with the crafted header and sample form data.
  4. Observe the server's CPU usage spike and the event loop stall, causing denial of service.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

FastAPI is a tool for building web APIs in Python. A regular expression is a pattern used to match text, and some patterns can be very slow when given specially crafted input. Here, an attacker sends a malformed header that makes the pattern take a very long time to process, using up the server's CPU and stopping it from responding to normal users.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by elniak

View all

28 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.