LiveActive security incident?Get immediate response
CVE Record

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

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.

HighCVSS 8.2Not KEV-listedUpdated
Glexia's TakeAutomated analysishigh

Security readout for executives and security teams

Plain-English summary

FastAPI before 0.65.2 could accept JSON data even when a browser sent it as text/plain. For applications using cookies for authentication, this could let a malicious site trigger authenticated actions in a user’s browser without the normal CORS preflight protection.

Executive priority

Treat as high priority for browser-facing FastAPI services using cookie sessions. The fix is straightforward, and affected systems could allow unauthorized actions under a legitimate user’s session. Prioritize public portals and admin workflows first.

Technical view

The flaw is CWE-352 CSRF. Vulnerable FastAPI versions parsed request bodies as JSON without requiring application/json or a compatible media type. Browser text/plain requests are simple requests and can include cookies, so affected JSON path operations using cookie authentication could process forged state-changing requests.

Likely exposure

Exposure is most likely in FastAPI applications below 0.65.2 that authenticate browser users with cookies and expose JSON endpoints that change data or perform sensitive actions. APIs using non-cookie authentication or not reachable by browsers may have lower practical exposure, but the sources do not fully enumerate safe configurations.

Exploitation context

The provided sources do not show CISA KEV listing or active exploitation evidence. Exploitation depends on an authenticated browser context and vulnerable application behavior: cookie-based auth, JSON payload handling, and acceptance of non-JSON content types. Internet-facing administrative or customer portals are higher concern.

Researcher notes

The key issue is parser behavior, not a generic CORS misconfiguration. The fix narrows JSON parsing to application/json and compatible media types. Validation should focus on content-type handling and cookie-authenticated JSON operations, without assuming every FastAPI deployment is exploitable.

Mitigation direction

  • Upgrade FastAPI to 0.65.2 or later; latest stable is preferred.
  • If upgrade is delayed, enforce JSON-compatible Content-Type on JSON endpoints.
  • Reject unexpected text/plain bodies before request data is parsed as JSON.
  • Review cookie-authenticated state-changing endpoints for CSRF protections.
  • Check distribution package advisories if FastAPI came from an OS repository.

Validation and detection

  • Inventory deployed FastAPI versions and flag anything below 0.65.2.
  • Identify JSON endpoints that rely on browser cookies for authentication.
  • Confirm JSON endpoints reject non-JSON-compatible Content-Type values.
  • Add regression tests for Content-Type enforcement on sensitive routes.
  • Verify dependency lockfiles, containers, and runtime environments use the fixed FastAPI version.
Prepared
Confidence
high
Sources
5

Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.

Potential ATT&CK relevance

Conservative CVE-to-ATT&CK context

These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.

ATT&CK lookup starting points

Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.

cwe · medium confidence lookup

CWE-352: User-session and phishing behavior lookup

Client-side and session-facing weaknesses should be reviewed alongside initial-access and user-execution behaviors. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.

Open ATT&CK lookup
cve · low confidence lookup

CVE-2021-32677 mapping review

Open the CVE-to-ATT&CK bridge for reviewed, inferred, or future official mappings tied to this CVE.

Open ATT&CK lookup
Vulnerability profileCVE Program record
Severity
High
CVSS
8.2 (3.1)
Known Exploited
No
Published

Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:N

Official CVE source material

CNA and ADP enrichment extracted from CVE v5

These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.

1CVSS vectors
0Timeline events
0ADP providers
4Source links

CVSS vector scores

1 official score

We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.

ScoreVersionSeverityVectorExploitImpactSource
8.2CVSS 3.1HighCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:N3.94.2Primary CVE score

Vulnerability scoring details

Base CVSS 3.1 score

8.2High
CVSS 3.1 vector shape for CVE-2021-32677Attack VectorAttack ComplexityPrivileges RequiredUser InteractionScopeConfidentiality ImpactIntegrity ImpactAvailability Impact

Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:N

Attack Vector
NetworkAdjacentLocalPhysical
Attack Complexity
LowHigh
Privileges Required
NoneLowHigh
User Interaction
NoneRequired
Scope
ChangedUnchanged
Confidentiality Impact
HighLowNone
Integrity Impact
HighLowNone
Availability Impact
HighLowNone

Source materials

Affected products

Products and packages named in the record

VendorProductVersion / packageStatus
tiangolofastapi< 0.65.2Listed
Weakness

CWE details

CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.

CWE-352 · source CWE mapping

Cross-Site Request Forgery (CSRF)

Cross-Site Request Forgery (CSRF) represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.