Transfer-Encoding and Connection response headers seen by the rules don't match the chunked filter's

Aperta
#420 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@fzipi ci sta già lavorando.

Dal 25/11/2026.

  • #421 di @fzipi — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
22/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c, nginx
Ambito
security

Direzione di ricerca

The bug is in the connector's response-header resolvers for Transfer-Encoding and Connection, which read r->chunked and r->keepalive before nginx's chunked filter has run. Start with those resolvers, then reproduce with the ssi on config in the issue and curl -i to see the headers the rule receives. Done means RESPONSE_HEADERS:Transfer-Encoding matches chunked output, Connection reflects close, and the reproduction returns 403. PR #421 is already open against this issue, so check it before starting.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

The response headers handed to the rules in phase 3 don't match what nginx sends when the body is chunked, or when nginx closes the connection because it can't chunk.

nginx's chunked filter runs after the connector's header filter. The Transfer-Encoding resolver checks r->chunked, which that filter hasn't set yet, so it's always 0. The Connection resolver checks r->keepalive, which the chunked filter may still clear. As a result:

  1. Transfer-Encoding: chunked is never seen. A response of unknown length over HTTP/1.1 is sent chunked, but RESPONSE_HEADERS:Transfer-Encoding is never set.
  2. Connection: keep-alive is seen when nginx sends Connection: close. This happens when nginx can't chunk a response of unknown length: an HTTP/1.0 keep-alive request, or chunked_transfer_encoding off. nginx then clears r->keepalive.
  3. Trailers: with add_trailer, nginx chunks the response and drops Content-Length. The rules see Content-Length and no Transfer-Encoding.

To reproduce

ssi on clears the length of a static file before the connector runs:

location / {
    ssi on;
    modsecurity on;
    modsecurity_rules '
        SecRuleEngine On
        SecRule RESPONSE_HEADERS:Transfer-Encoding "@streq chunked" "id:1,phase:3,deny,status:403"
    ';
}

curl -i http://localhost/index.html returns 200 with Transfer-Encoding: chunked. The rule should have matched and returned 403.

Not covered

gzip also runs after the connector and can drop a known Content-Length. Predicting that would mean copying gzip's own checks (Accept-Encoding, gzip_types, gzip_min_length, ...), so that case isn't covered here.

Lingua principale
Perl
Stelle
1.9k
Fork
312
Merge medio
2g 22h
PR unite (30g)
4

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di owasp-modsecurity/ModSecurity-nginx

Tutte le issue di owasp-modsecurity/ModSecurity-nginx

Issue simili

Altre issue su Perl

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.