Skip to content

Commit 292a408

Browse files
SunandMKriechi
authored andcommitted
reject duplicate Host headers in request headers
Duplicate Host headers are now rejected with a ProtocolError. This addresses a request smuggling primitive where a consumer downgrading HTTP/2 to HTTP/1.1 would emit two Host header lines, causing backend divergence (CWE-444). The _validate_host_authority_header() function now counts Host headers and raises ProtocolError if more than one is present, covering both the receive path (_check_host_authority_header) and the send path (_check_sent_host_authority_header).
1 parent 04d3b87 commit 292a408

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/h2/utilities.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,9 @@ def _validate_host_authority_header(headers: Iterable[Header]) -> Generator[Head
449449
if header[0] == b":authority":
450450
authority_header_val = header[1]
451451
elif header[0] == b"host":
452+
if host_header_val is not None:
453+
msg = "Request header block has multiple Host headers."
454+
raise ProtocolError(msg)
452455
host_header_val = header[1]
453456

454457
yield header

0 commit comments

Comments
 (0)