Security fix · CVE-2021-32677
Cross-Site Request Forgery (CSRF) in FastAPI
Published Jun 9, 2021 · catalog updated Jun 9, 2021 · Cross-Site Request Forgery (CSRF)
Last checked Nov 4, 2026. A connected source was read within the last 7 days.
Check if you run it
No confirmed exploitation is on record for CVE-2021-32677. EPSS is 0.72%. Act only if a listed version of Cross-Site Request Forgery (CSRF) is installed.
Gaps on this record
- The stored product name is a package slug. The name on this page is taken from the title (Cross-Site Request Forgery (CSRF)).
- No vendor fix or required action is stored. Compare the linked advisory before you change production.
- Severity
- Medium5.3
- Known exploitation
- Not in CISA/VulnCheck KEV
- EPSS
- 0.72%
- Remediation
- Version ranges on file
- Affected products
- pip fastapi
### Impact FastAPI versions lower than 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 , FastAPI would try to read the request payload as JSON even if the header sent was not set to or a compatible JSON media type (e.g. ). So, a request with a content type of containing JSON data would be accepted and the JSON data would be extracted. But requests with content type are exempt from [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) preflights, for being considered [Simple requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#simple_requests). So, the browser would 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. ### Patches This is fixed in FastAPI . The request data is now parsed as JSON only if the header is or another JSON compatible media type like . ### Workarounds It's best to upgrade to the latest FastAPI. But still, it would be possible to add a middleware or a dependency that checks the header and aborts the request if it is not or another JSON compatible content type. ### References * [CORS on Mozilla web docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) * [This answer on StackExchange](https://security.stackexchange.com/questions/157528/ways-to-bypass-browsers-cors-policy/157531#157531) * [OWASP CSRF](https://owasp.org/www-community/attacks/csrf) * Fixed in PR [#2118](https://github.com/tiangolo/fastapi/pull/2118) ### For more information If you have any questions or comments, write to [security@tiangolo.com](mailto:security@tiangolo.com)
Are you affected?
Enter the version you run. The result uses only the ranges stored on this record.
The check returns affected, not affected, or incomplete. It does not guess a version that is missing from the record.
- pip fastapi<0.65.2
How to fix CVE-2021-32677
Upgrade
CVE-2021-32677 lists a fix boundary at 0.65.2. Compare the installed build with that boundary before you change production.
Version check
Affected <0.65.2
Advisory
Open the cve_org record and follow its fix.
Official advisories
What to do
Three questions, each answered from this record only. Confirm the vendor advisory before you patch.
Should you patch?
No confirmed exploitation is on record for CVE-2021-32677. EPSS is 0.72%. Act only if a listed version of Cross-Site Request Forgery (CSRF) is installed.
Which versions are affected?
Compare what you have installed with <0.65.2. Compare the installed version with the linked vendor advisory before you change production.
What should an analyst verify?
CWE-352: Cross-Site Request Forgery (CSRF). EPSS 0.72%. There is no CISA KEV listing. No Exploit-DB or Metasploit reference is linked. Use the source links for the original advisory.
Technology hubs
Code
The project this record applies to. Exploit listings stay in References.
No public source repository is identified for this product.
Timeline
Detection, updates, and resolution for this record.
Jun 9, 2021 · Maintainer security tabs
Detected
### Impact FastAPI versions lower than 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 , FastAPI would try to read the request payload as JSON even if the header sent was not set to or a compatible JSON media type (e.g. ). So, a request with a content type of c
Sources
- CVE.orgVulnerability recordCVE-2021-32677
Official CVE identifier
cve.org - Maintainer security tabsVendor advisoryGHSA-8h2j-cgx8-6xv7
### Impact FastAPI versions lower than 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 , FastAPI would try to read the request payload as JSON even if the header sent was not set to or a compatible JSON media type (e.g. ). So, a request with a content type of c
github.com
Freshness
Last verified in this catalog Nov 2, 2026. Significant claims (KEV, EPSS, CVSS, affected ranges) come from the source rows above — open the original publisher for the authoritative advisory.
- CVE.orgNov 4, 2026
- Maintainer security tabsNov 2, 2026