Inconsistent handling of invalid headers causes unexpected behavior
まだ誰も着手していません。
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.2k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、issue に記載されている 3 つの header() 呼び出しを再現し、PHP のヘッダー検証パスを調べて、セミコロン、タブ、改行がどのように処理されるかを確認します。無効なヘッダー構文が適切な警告とともに一貫して拒否され、有効なヘッダーに影響がない状態になったら作業は完了です。3 つの例のカバレッジを追加してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, php
- 領域
- backend-api-design, security
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100