PT-2021-4289 · Fastapi+1 · Fastapi+1

Dima Boger

·

Published

2021-06-02

·

Updated

2024-02-12

·

CVE-2021-32677

CVSS v4.0

8.8

High

VectorAV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:H/VA:N/SC:N/SI:N/SA:N
Name of the Vulnerable Software and Affected Versions FastAPI versions prior to 0.65.2
Description The issue is related to a Cross-Site Request Forgery (CSRF) attack in FastAPI, a web framework for building APIs with Python. 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. This allowed a request with a content type of text/plain containing JSON data to be accepted and the JSON data to be extracted. The browser would execute such requests right away, including cookies, and the text content could be a JSON string that would be parsed and accepted by the FastAPI application.
Recommendations To resolve the issue, upgrade to the latest FastAPI version. If updating is not possible, consider adding 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.

Fix

CSRF

Weakness Enumeration

Related Identifiers

BDU:2021-04898
CVE-2021-32677
GHSA-8H2J-CGX8-6XV7
PYSEC-2021-100

Affected Products

Debian
Fastapi