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

Abierto
#422 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@fzipi ya está trabajando en esto.

Desde el 25/11/2026.

  • #423 de @fzipi — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
nginx
Área
backend, security

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Perl
Estrellas
1.9k
Forks
312
Merge medio
2 d 22 h
PR fusionados (30 d)
4

Preparar el entorno

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de owasp-modsecurity/ModSecurity-nginx

Todos los issues de owasp-modsecurity/ModSecurity-nginx

Issues similares

Más issues de Perl

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.