Inconsistent handling of invalid headers causes unexpected behavior
Nessuno ha ancora preso questa issue.
- Lingua principale
- C
- Stelle
- 40.4k
- Fork
- 8.2k
- Merge medio
- 2g 13h
- PR unite (30g)
- 96
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo le tre chiamate a header() descritte nell’issue e ispeziona il percorso di validazione degli header di PHP per capire come vengono gestiti punti e virgola, tabulazioni e nuove righe. Il lavoro è completato quando la sintassi degli header non valida viene rifiutata in modo coerente con un avviso appropriato e gli header validi rimangono inalterati; aggiungi la copertura per i tre esempi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c, php
- Ambito
- backend-api-design, security
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100