
Docker lab reproducing CVE-2026-42533, a pre-auth nginx heap overflow and info leak via two-pass capture clobbering, with PoC scripts and patched comparison.
CVSS 9.2 (Critical) — Pre-auth heap buffer overflow + info leak in nginx Affected: nginx 0.9.6 – 1.30.3 / 1.31.2 | Patched: 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 evaluates directive values (proxy_set_header, return, add_header, etc.)
in two passes using a shared mutable array r->captures:
| Pass | Purpose | Reads r->captures |
|---|---|---|
| LEN | Measure buffer size needed | Yes — to get $1 length |
(regex map evaluates here, CLOBBERING r->captures) | ||
| VALUE | Write data into allocated buffer | Yes — but now $1 points elsewhere |
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 | URI size | Map input size | Result |
|---|---|---|---|
| Overflow | Short (3 B) | Long (4096 B) | LEN allocates small, VALUE writes large → heap overflow |
| Info Leak | Long (8000 B) | Short (5 B) | LEN allocates large, VALUE writes small → heap residue in response |
| Endpoint | 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) |
| File | Purpose |
|---|---|
docker-compose.yml | Lab orchestration |
Dockerfile.nginx-vuln | Vulnerable nginx 1.26.x |
Dockerfile.nginx-patched | Patched nginx 1.30.4 |
nginx-vuln.conf | Vulnerable configuration with annotated patterns |
backend.py | Echo server to inspect proxied headers |
poc_overflow.py | Heap overflow PoC (escalating payload sizes) |
poc_infoleak.py | Info leak PoC (heap residue detection) |
poc_curl.sh | Quick curl-based tests |
Use the config scanner:
python3 nginx_capture_clobber_scan.py /etc/nginx/nginx.conf
~ / ~* regex patterns in map when captures are used elsewhereFOR EDUCATIONAL AND AUTHORIZED SECURITY TESTING ONLY.