Transfer-Encoding and Connection response headers seen by the rules don't match the chunked filter's
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
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:
Transfer-Encoding: chunkedis never seen. A response of unknown length over HTTP/1.1 is sent chunked, butRESPONSE_HEADERS:Transfer-Encodingis never set.Connection: keep-aliveis seen when nginx sendsConnection: close. This happens when nginx can't chunk a response of unknown length: an HTTP/1.0 keep-alive request, orchunked_transfer_encoding off. nginx then clearsr->keepalive.- Trailers: with
add_trailer, nginx chunks the response and dropsContent-Length. The rules seeContent-Lengthand noTransfer-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 ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
owasp-modsecurity/ModSecurity-nginx のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
owasp-modsecurity/ModSecurity-nginx#418 ·
メンテナーはふだん 1 日以内に返信
-
:1st_place_medal: good first issue enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
owasp-modsecurity/ModSecurity-nginx#359 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
Relative Location response header is seen by the rules, nginx sends it absolute対応中かも @fzipi が今日担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
owasp-modsecurity/ModSecurity-nginx#422 ·
メンテナーはふだん 1 日以内に返信
-
Documentation: Clarify dynamic module ABI compatibility with distribution-patched NGINX packages対応中かも @airween が今日担当しました。 オープンenhancement
owasp-modsecurity/ModSecurity-nginx#419 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Connection response header is seen by the rules on HTTP/2 responses対応中かも @fzipi が今日担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
owasp-modsecurity/ModSecurity-nginx#415 ·
メンテナーはふだん 1 日以内に返信
owasp-modsecurity/ModSecurity-nginx の issue をすべて見る
似ている issue
-
fix(rodex): sent mail loses the last character of title and body対応中かも @baphomello が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
inverse-inc/packetfence#9768 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
-
Package Update Update Bot
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
priv-kweihmann/meta-sca#13307 ·