# CVE-2021-32677: Cross-Site Request Forgery (CSRF) in FastAPI

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** HIGH 8.2
- **CVSS:** 8.2 (v3.1, CNA) `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:N`
- **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
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Remote, no login needed
- **EPSS:** 0.72% (percentile 50, 2026-11-26)
- **CWE:** CWE-352
- **Aliases:** GHSA-8h2j-cgx8-6xv7, PYSEC-2021-100
- **Published:** 2021-06-09T17:30:12.000Z
- **Modified:** 2026-07-08T06:28:18.554Z

## Who should check

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

## 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

- PyPI `fastapi`: affected \< 0.65.2; fixed 0.65.2 (osv)
- tiangolo fastapi: \< 0.65.2 (cvelist)

## Mitigation

- Upgrade fastapi to 0.65.2 or later.

## Check your systems with an agent

Paste this into a coding agent:

```text
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.
```

## 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.

## References

- vendor: <https://github.com/tiangolo/fastapi/security/advisories/GHSA-8h2j-cgx8-6xv7>
- vendor: <https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/MATAWX25TYKNEKLDMKWNLYDB34UWTROA/>
- vendor: <https://nvd.nist.gov/vuln/detail/CVE-2021-32677>
- patch: <https://github.com/tiangolo/fastapi/commit/fa7e3c996edf2d5482fff8f9d890ac2390dede4d>
- other: <https://github.com/pypa/advisory-database/tree/main/vulns/fastapi/PYSEC-2021-100.yaml>
- other: <https://github.com/tiangolo/fastapi>
- other: <https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/MATAWX25TYKNEKLDMKWNLYDB34UWTROA>
- other: <https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/MATAWX25TYKNEKLDMKWNLYDB34UWTROA/>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2021-32677>
- OSV: CC-BY 4.0 <https://osv.dev/vulnerability/GHSA-8h2j-cgx8-6xv7> (license: <https://creativecommons.org/licenses/by/4.0/>)
- OSV: CC-BY 4.0 <https://osv.dev/vulnerability/PYSEC-2021-100> (license: <https://creativecommons.org/licenses/by/4.0/>)

HTML: <https://flawdb.com/CVE-2021-32677> · JSON: <https://flawdb.com/api/v1/entries/CVE-2021-32677>
