
Laboratório Docker que reproduz o CVE-2026-42533, um heap overflow pré-autenticação no nginx e vazamento de informações via clobbering de captura em duas passagens, com scripts PoC e comparação com a versão corrigida.
CVSS 9.2 (Crítico) — Heap buffer overflow pré-autenticação + vazamento de informações no nginx Afetado: nginx 0.9.6 – 1.30.3 / 1.31.2 | Corrigido: 1.30.4 / 1.31.3
┌─────────────────────────────────────┐
│ Máquina host │
│ │
Scripts PoC ──────┤ :8080 ──► nginx-vuln (1.26.x) │
│ │ VULNERÁVEL │
│ ▼ │
│ backend (Python echo) │
│ ▲ │
│ │ │
│ :8081 ──► nginx-patched (1.30.4) │
│ SEGURO │
└─────────────────────────────────────┘
# 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
O nginx avalia valores de diretivas (proxy_set_header, return, add_header, etc.)
em duas passagens usando um array mutável compartilhado r->captures:
| Passagem | Propósito | Lê r->captures |
|---|---|---|
| LEN | Mede o tamanho do buffer necessário | Sim — para obter o comprimento de $1 |
(o regex map é avaliado aqui, SOBRESCREVENDO r->captures) | ||
| VALUE | Escreve dados no buffer alocado | Sim — mas agora $1 aponta para outro lugar |
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
}
| Direção | Tamanho da URI | Tamanho da entrada do map | Resultado |
|---|---|---|---|
| Overflow | Curta (3 B) | Longa (4096 B) | LEN aloca pequeno, VALUE escreve grande → heap overflow |
| Vazamento de Informações | Longa (8000 B) | Curta (5 B) | LEN aloca grande, VALUE escreve pequeno → resíduo de heap na resposta |
| Endpoint | Sink | Gatilho do Map | Demonstração |
|---|---|---|---|
/api/v1/{path} | proxy_set_header | $is_bot (User-Agent) | Overflow |
/leak/{path} | return + add_header | $ref_domain (Referer) | Vazamento de informações |
/rce/{path} | set + return | $is_bot (User-Agent) | Overflow |
/safe/{path} | return (sem map) | Nenhum | Controle (seguro) |
| Arquivo | Propósito |
|---|---|
docker-compose.yml | Orquestração do laboratório |
Dockerfile.nginx-vuln | nginx 1.26.x vulnerável |
Dockerfile.nginx-patched | nginx 1.30.4 corrigido |
nginx-vuln.conf | Configuração vulnerável com padrões anotados |
backend.py | Servidor echo para inspecionar cabeçalhos proxiados |
poc_overflow.py | PoC de heap overflow (tamanhos de payload escalonados) |
poc_infoleak.py | PoC de vazamento de informações (detecção de resíduo de heap) |
poc_curl.sh | Testes rápidos baseados em curl |
Use o scanner de configuração:
python3 nginx_capture_clobber_scan.py /etc/nginx/nginx.conf
~ / ~* em map quando capturas forem usadas em outros lugaresAPENAS PARA FINS EDUCACIONAIS E TESTES DE SEGURANÇA AUTORIZADOS.