Skip to content
FlawDB
Sign in
Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

CVE-2021-32677

HIGH 8.2EPSS 50%

Cross-Site Request Forgery (CSRF) in FastAPI

Also known as GHSA-8h2j-cgx8-6xv7, PYSEC-2021-100

Mitigation

  • Upgrade fastapi to 0.65.2 or later.

Who should check

  • Projects that depend on PyPI package fastapi (< 0.65.2)
  • Anyone running tiangolo fastapi < 0.65.2

Vulnerability facts

Affected
fastapi < 0.65.2
Fixed in
0.65.2
Exploited in the wild
Not in CISA KEV
Public exploit / PoC
None known
Remote exploitation
Remote, no login needed
CVSS
8.2 (v3.1, CNA)CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:NOpen in CVSS calculator
Show all 8 CVSS metrics
  • Attack vector: Network
  • Attack complexity: Low
  • Privileges required: None
  • User interaction: None
  • Scope: Unchanged
  • Confidentiality impact: Low
  • Integrity impact: High
  • Availability impact: None
EPSS
0.72% chance of exploitation in 30 days (percentile 50, 2026-11-26)
CWE
CWE-352
Published
Modified

Description

FastAPI is a web framework for building APIs with Python 3.6+ based on standard Python type hints. FastAPI versions lower than 0.65.2 that used cookies for authentication in path operations that received JSON payloads sent by browsers were vulnerable to a Cross-Site Request Forgery (CSRF) attack. In versions lower than 0.65.2, FastAPI would try to read the request payload as JSON even if the content-type header sent was not set to application/json or a compatible JSON media type (e.g. application/geo+json). A request with a content type of text/plain containing JSON data would be accepted and the JSON data would be extracted. Requests with content type text/plain are exempt from CORS preflights, for being considered Simple requests. The browser will execute them right away including cookies, and the text content could be a JSON string that would be parsed and accepted by the FastAPI application. This is fixed in FastAPI 0.65.2. The request data is now parsed as JSON only if the content-type header is application/json or another JSON compatible media type like application/geo+json. It's best to upgrade to the latest FastAPI, but if updating is not possible then a middleware or a dependency that checks the content-type header and aborts the request if it is not application/json or another JSON compatible content type can act as a mitigating workaround.

Affected and fixed versions

Package / productAffectedFixedSource
PyPI fastapi< 0.65.20.65.2osv
tiangolo fastapi< 0.65.2—cvelist

Check your systems with an agent

Paste this into Claude Code, Cursor or another coding agent. It only reads; it changes nothing.

Check whether anything I run is affected by CVE-2021-32677. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2021-32677.md
Affected: fastapi < 0.65.2
Fixed in: 0.65.2

Steps:
1. Search this machine and project for fastapi (PyPI), tiangolo fastapi: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.

References

FAQ

Is CVE-2021-32677 being exploited?

There is no confirmed exploitation: CVE-2021-32677 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.72% chance of exploitation in the next 30 days (as of 2026-11-26).

How serious is CVE-2021-32677?

High: CVSS 8.2 (v3.1, scored by CNA). Remote, no login needed.

Which versions are affected by CVE-2021-32677?

fastapi < 0.65.2.

Is there a fix for CVE-2021-32677?

Yes. Fixed in 0.65.2. Upgrade fastapi to 0.65.2 or later.

How do I check if I'm affected by CVE-2021-32677?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

Sponsors