Dependency Confusion Vulnerability in FastAPI: Malicious Code Injection Risk
Summary
MAL-2026-4750: Malicious code in fastapi (PyPI). Affects fastapi versions 0.136.3. No fix is published. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
FastAPI is a popular web framework for building APIs with Python 3.6+ based on standard Python type hints. It is designed to be easy to use, fast, and efficient, allowing developers to create robust applications quickly. FastAPI is widely adopted due to its performance and ease of integration with other libraries. However, the recent discovery of a malicious dependency poses a significant risk to users who install the package without awareness of its implications.
Vulnerability Detail
The vulnerability arises from the inclusion of an undocumented dependency 'fastar>=0.9.0' in FastAPI version 0.136.3. This dependency is a typosquat, meaning it is designed to exploit the similarity in naming to trick users into installing malicious code. When users follow the official installation instructions to install FastAPI with the 'standard' option, they inadvertently install 'fastar', which could lead to code execution on their systems. This poses a severe risk, especially for developers and CI environments that rely on FastAPI for their applications.
How To Fix
This package is malicious. Remove it and rotate any credentials it could have accessed.
pip uninstall fastapi
If it arrived as a transitive dependency, remove the package that pulled it in, then reinstall.
Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →
Workaround
As a temporary workaround, users can avoid using the 'standard' installation option and manually install only the necessary dependencies for FastAPI. For example, you can install FastAPI without the optional dependencies using:
pip install fastapi
This will prevent the installation of the 'fastar' package.
Conclusion
The discovery of the 'fastar' dependency in FastAPI highlights the importance of being vigilant about package dependencies. Users should take immediate action to update their installations and consider using tools like Vulert to monitor for vulnerabilities in their software.
See every vulnerability recorded for fastapi →
FAQ
'fastar' is an undocumented and potentially malicious package that was added to FastAPI's dependencies, posing a risk of code execution.
You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.
If you have installed FastAPI version 0.136.3, you should immediately update to a patched version using 'pip install --upgrade fastapi'.
Using 'fastar' can lead to malicious code execution on your system, potentially compromising your application and data.
Regularly monitor your dependencies for vulnerabilities using tools like Vulert, which can alert you in real-time for open-source vulnerabilities.
References
Related vulnerabilities
Recent vulnerabilities recorded for fastapi.