
Docker-Lab zur Reproduktion von CVE-2026-42533, einem Pre-Auth-nginx-Heap-Overflow und Info-Leak durch Two-Pass-Capture-Clobbering, mit PoC-Skripten und gepatchtem Vergleich.
CVSS 9.2 (Kritisch) — Pre-Auth Heap-Buffer-Overflow + Info-Leak in nginx Betroffen: nginx 0.9.6 – 1.30.3 / 1.31.2 | Gepatcht: 1.30.4 / 1.31.3
┌─────────────────────────────────────┐
│ Host machine │
│ │
PoC scripts ──────┤ :8080 ──► nginx-vuln (1.26.x) │
│ │ VULNERABLE │
│ ▼ │
│ backend (Python echo) │
│ ▲ │
│ │ │
│ :8081 ──► nginx-patched (1.30.4) │
│ SAFE │
└─────────────────────────────────────┘
# 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 wertet Direktivenwerte (proxy_set_header, return, add_header, etc.)
in zwei Durchläufen unter Verwendung eines gemeinsam genutzten, veränderlichen Arrays r->captures aus:
| Durchlauf | Zweck | Liest r->captures |
|---|---|---|
| LEN | Benötigte Puffergröße messen | Ja — um die Länge von $1 zu ermitteln |
(regex map evaluates here, CLOBBERING r->captures) | ||
| VALUE | Daten in den zugewiesenen Puffer schreiben | Ja — aber jetzt zeigt $1 woanders hin |
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
}
| Richtung | URI-Größe | Map-Eingabegröße | Ergebnis |
|---|---|---|---|
| Overflow | Kurz (3 B) | Lang (4096 B) | LEN weist klein zu, VALUE schreibt groß → Heap-Overflow |
| Info Leak | Lang (8000 B) | Kurz (5 B) | LEN weist groß zu, VALUE schreibt klein → Heap-Rückstände in der Antwort |
| Endpunkt | Sink | Map-Trigger | Demo |
|---|---|---|---|
/api/v1/{path} | proxy_set_header | $is_bot (User-Agent) | Overflow |
/leak/{path} | return + add_header | $ref_domain (Referer) | Info leak |
/rce/{path} | set + return | $is_bot (User-Agent) | Overflow |
/safe/{path} | return (no map) | None | Control (safe) |
| Datei | Zweck |
|---|---|
docker-compose.yml | Lab-Orchestrierung |
Dockerfile.nginx-vuln | Anfälliges nginx 1.26.x |
Dockerfile.nginx-patched | Gepatchtes nginx 1.30.4 |
nginx-vuln.conf | Anfällige Konfiguration mit kommentierten Mustern |
backend.py | Echo-Server zur Überprüfung der weitergeleiteten Header |
poc_overflow.py | Heap-Overflow-PoC (eskalierende Payload-Größen) |
poc_infoleak.py | Info-Leak-PoC (Erkennung von Heap-Rückständen) |
poc_curl.sh | Schnelle curl-basierte Tests |
Verwenden Sie den Config-Scanner:
python3 nginx_capture_clobber_scan.py /etc/nginx/nginx.conf
~ / ~* Regex-Muster in map, wenn Captures an anderer Stelle verwendet werdenNUR FÜR BILDUNGSZWECKE UND AUTORISIERTE SICHERHEITSTESTS.