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
| Vector | AV: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
Found an issue in the description? Have something to add? Feel free to write us 👾
Weakness Enumeration
Related Identifiers
Affected Products
Debian
Fastapi