Relative Location response header is seen by the rules, nginx sends it absolute

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

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

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

2026年11月25日 から。

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

評価

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

調査の方向性

Start at the connector's phase 3 response-header filter and the point where RESPONSE_HEADERS is populated; compare it with nginx's terminal HTTP/1, HTTP/2 and HTTP/3 header filters. Reproduce with the directory redirect and SecRule RESPONSE_HEADERS:Location, then build the same absolute Location before rules run, honoring absolute_redirect, server_name_in_redirect, port_in_redirect, SSL/HTTP3 scheme and proxy_redirect. Done when the rule matches the client-visible URL and tests cover relative redirects, proxies, error_page redirects and ports.

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

説明

The response headers handed to the rules in phase 3 contain a relative Location as it is, for example /dir/. With absolute_redirect on, the default, nginx sends an absolute URL instead: http://localhost:8080/dir/.

nginx builds the absolute value in its terminal header filters (HTTP/1, HTTP/2 and HTTP/3), which run after the connector's header filter. The host comes from server_name_in_redirect, the Host header or the local address. The port depends on port_in_redirect, and the scheme is https over SSL or HTTP/3. A rule on RESPONSE_HEADERS:Location written against what clients receive therefore never matches a redirect nginx built from a relative URI: directory redirects, proxy_redirect results, error_page ... =301 /path, etc.

To reproduce

With a directory dir under the root:

location / {
    modsecurity on;
    modsecurity_rules '
        SecRuleEngine On
        SecRule RESPONSE_HEADERS:Location "@streq http://localhost:8080/dir/" "id:1,phase:3,deny,status:403"
    ';
}

curl -i http://localhost:8080/dir returns 301 with Location: http://localhost:8080/dir/. The rule should have matched and returned 403.

主要言語
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 を短くまとめたダイジェスト。