Inconsistent handling of invalid headers causes unexpected behavior
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- C
- Estrellas
- 40.4k
- Forks
- 8.2k
- Merge medio
- 2 d 13 h
- PR fusionados (30 d)
- 96
Descripción
Description
The following code:
<?php
header( "X-Foo;: hello" );
header( "X-Foo\t: hello" );
header( "X-Foo\n: hello" );
The 3rd one results in a warning (Header may not contain more than a single header, new line detected) and the header is not set.
The other 2 however are sent without a warning. The 2nd one will get fixed by nginx, however the 1st one passes through (see https://github.com/nginx/nginx/issues/899)
This not only is inconsistent, this also allows for certain attack vectors if the request is proxied and the proxy does not handle the invalid headers correctly (sorry, can't go into detail on this at this moment in time, due to pending security reports)
Since headers are apparently getting validated in PHP already (otherwise we wouldn't have an error for the 3rd one), this validation should be fixed to strictly check if the provided header adheres to the HTTP header standards
PHP Version
PHP 8.4, however affects previous PHP versions similarly
Operating System
No response
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza reproduciendo las tres llamadas a header() descritas en el issue e inspecciona la ruta de validación de headers de PHP para determinar cómo se manejan los puntos y comas, las tabulaciones y los saltos de línea. El trabajo estará terminado cuando la sintaxis de headers no válida se rechace sistemáticamente con una advertencia adecuada y los headers válidos no se vean afectados; añade cobertura para los tres ejemplos.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- c, php
- Área
- backend-api-design, security
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100