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

オープン
#420 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@fzipi がすでに取り組んでいます。

2026年11月25日 から。

  • #421 @fzipi による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
22/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
c, nginx
領域
security

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Perl
スター
1.9k
フォーク
312
平均マージ
2日 22時間
マージ済み PR(30日)
4

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

owasp-modsecurity/ModSecurity-nginx のほかの issue

owasp-modsecurity/ModSecurity-nginx の issue をすべて見る

似ている issue

Perl の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。