Skip to content

Test duplicate Host headers that the mismatch check misses - #1343

Open
connabyss wants to merge 2 commits into
python-hyper:masterfrom
connabyss:test/duplicate-host-headers
Open

connabyss wants to merge 2 commits into
python-hyper:masterfrom
connabyss:test/duplicate-host-headers

Conversation

@connabyss

Copy link
Copy Markdown

292a408 rejects request headers with more than one Host header (GHSA-6hr6-w5qg-qmwg), and 92b925e added a test case for it. That case puts the mismatching Host header last, so the older :authority/Host mismatch check already rejects it. The test still passes with the new duplicate check taken out.

This adds two cases that only the duplicate check catches:

  • a mismatching Host header first and the matching one last
  • two Host headers and no :authority

Both are accepted without the fix and rejected with it. Tests only.

I wrote this with help from Claude Code (noted in the commit message).

292a408 rejects a request header block with more than one Host header
(GHSA-6hr6-w5qg-qmwg), and 92b925e added a test case for it. That case
puts the mismatching Host last, so the older :authority/Host mismatch
check already rejects it: the test still passes with the new check
taken out.

Add two cases only the duplicate check catches: the matching Host
header last, and two Host headers with no :authority. Both are
accepted without the fix.

Assisted-by: Claude Code
@Kriechi

Kriechi commented Nov 1, 2026

Copy link
Copy Markdown
Member

Thanks - good catch! 🎉
Would you mind updating the test itself to assert we are raising the ProtocolError with the correct message?
Thanks!

Move the duplicate Host header cases into their own list and add a
test that checks the ProtocolError says "Request header block has
multiple Host headers", so it fails if any other header check rejects
these blocks instead. The cases stay in the general invalid header
list too.

Assisted-by: Claude Code
@connabyss

connabyss commented Nov 1, 2026 •

Copy link
Copy Markdown
Author

Sure, done in b7b20fa. I moved the three duplicate Host cases into their own list and added a test that checks the ProtocolError says "Request header block has multiple Host headers", so it fails if some other check rejects these blocks instead. They still run in the general invalid header list too.

I used Claude Code to check that the new test fails on all six cases with the fix from 292a408 taken out, and that it passes with the fix in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants