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

Đang mở
#422 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@fzipi đang làm issue này rồi.

Từ ngày 25/11/2026.

  • #423 của @fzipi — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
nginx
Lĩnh vực
backend, security

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Perl
Star
1.9k
Fork
312
Merge trung bình
2 ngày 22 giờ
Pull request đã merge (30 ngày)
4

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của owasp-modsecurity/ModSecurity-nginx

Tất cả issue của owasp-modsecurity/ModSecurity-nginx

Issue tương tự

Thêm issue về Perl

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.