CVE-2024-40627 OpaMiddleware does not filter HTTP OPTIONS requests
Unauthenticated attackers can discover existing entities by sending HTTP OPTIONS requests, bypassing authentication checks in the FastAPI OPA middleware.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Over the internet
- Victim action needed
- Not needed
- Fix
- Available
What is CVE-2024-40627?
CVE-2024-40627 is a medium-severity vulnerability in busykoala fastapi-opa, published on 15 Jul 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.
Official description
Fastapi OPA is an opensource fastapi middleware which includes auth flow. HTTP `OPTIONS` requests are always allowed by `OpaMiddleware`, even when they lack authentication, and are passed through directly to the application. `OpaMiddleware` allows all HTTP `OPTIONS` requests without evaluating it against any policy. If an application provides different responses to HTTP `OPTIONS` requests based on an entity existing (such as to indicate whether an entity is writable on a system level), an unauthenticated attacker could discover which entities exist within an application. This issue has been addressed in release version 2.0.1. All users are advised to upgrade. There are no known workarounds for this vulnerability.
Weakness: CWE-204
Which versions are affected by CVE-2024-40627?
3 open source packages ship an affected version, including fastapi-opa.
| Package | Affected | Fixed in |
|---|---|---|
fastapi-opa PyPI | All versions | 2.0.1 |
fastapi-opa PyPI | All versions | 2.0.1 |
fastapi-opa PyPI | All versions | 2.0.1 |
How do I fix CVE-2024-40627?
Upgrade fastapi-opa to 2.0.1 or later.
Is CVE-2024-40627 being exploited?
It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-40627 exists.
Sources
Also known as GHSA-5f5c-8rvc-j8wf, PYSEC-2026-1361, UBUNTU-CVE-2024-40627.