
Docker lab reproduisant CVE-2026-42533, un débordement de tas nginx pré-authentification et une fuite d'informations via l'écrasement de capture en deux passes, avec des scripts PoC et une comparaison corrigée.
CVSS 9.2 (Critique) — Débordement de tampon heap pré-authentification + fuite d'informations dans nginx Affecté : nginx 0.9.6 – 1.30.3 / 1.31.2 | Corrigé : 1.30.4 / 1.31.3
┌─────────────────────────────────────┐
│ Machine hôte │
│ │
Scripts PoC ──────┤ :8080 ──► nginx-vuln (1.26.x) │
│ │ VULNÉRABLE │
│ ▼ │
│ backend (Python echo) │
│ ▲ │
│ │ │
│ :8081 ──► nginx-patched (1.30.4) │
│ SÛR │
└─────────────────────────────────────┘
# Build and start
docker compose up --build -d
# Verify
curl http://localhost:8080/health
curl http://localhost:8081/health
# Run PoC
python3 poc_overflow.py # Heap overflow (crash worker)
python3 poc_infoleak.py # Info leak (heap residue)
bash poc_curl.sh # Quick curl-based tests
# Compare with patched
python3 poc_overflow.py localhost 8081
python3 poc_infoleak.py localhost 8081
# Check for crashes
docker logs nginx-vuln 2>&1 | grep -iE 'signal|segfault|abort'
# Cleanup
docker compose down
nginx évalue les valeurs de directive (proxy_set_header, return, add_header, etc.)
en deux passes à l'aide d'un tableau mutable partagé r->captures :
| Passe | Objectif | Lit r->captures |
|---|---|---|
| LEN | Mesurer la taille de tampon nécessaire | Oui — pour obtenir la longueur de $1 |
(la regex map est évaluée ici, ÉCRASANT r->captures) | ||
| VALUE | Écrire les données dans le tampon alloué | Oui — mais maintenant $1 pointe ailleurs |
map $http_user_agent $is_bot {
~*(bot|crawl|spider) 1; # ← regex map = clobber trigger
default 0;
}
location ~ "^/api/v1/(.+)$" { # ← regex capture source
proxy_set_header X-Route "$1 — $is_bot"; # ← two-pass sink
# ^^ ^^^^^^^
# capture ref + map var in same buffer = BUG
}
| Direction | Taille de l'URI | Taille de l'entrée map | Résultat |
|---|---|---|---|
| Débordement | Courte (3 o) | Longue (4096 o) | LEN alloue petit, VALUE écrit grand → débordement de heap |
| Fuite d'informations | Longue (8000 o) | Courte (5 o) | LEN alloue grand, VALUE écrit petit → résidu de heap dans la réponse |
| Endpoint | Sink | Déclencheur map | Démo |
|---|---|---|---|
/api/v1/{path} | proxy_set_header | $is_bot (User-Agent) | Débordement |
/leak/{path} | return + add_header | $ref_domain (Referer) | Fuite d'informations |
/rce/{path} | set + return | $is_bot (User-Agent) | Débordement |
/safe/{path} | return (sans map) | Aucun | Contrôle (sûr) |
| Fichier | Objectif |
|---|---|
docker-compose.yml | Orchestration du lab |
Dockerfile.nginx-vuln | nginx 1.26.x vulnérable |
Dockerfile.nginx-patched | nginx 1.30.4 corrigé |
nginx-vuln.conf | Configuration vulnérable avec motifs annotés |
backend.py | Serveur echo pour inspecter les en-têtes proxifiés |
poc_overflow.py | PoC de débordement de heap (tailles de payload croissantes) |
poc_infoleak.py | PoC de fuite d'informations (détection de résidu de heap) |
poc_curl.sh | Tests rapides basés sur curl |
Utilisez le scanner de configuration :
python3 nginx_capture_clobber_scan.py /etc/nginx/nginx.conf
~ / ~* dans map lorsque des captures sont utilisées ailleursÀ DES FINS ÉDUCATIVES ET DE TESTS DE SÉCURITÉ AUTORISÉS UNIQUEMENT.