Repository navigation
fix(router): send a single Host header to HTTP/1.1 backends - #1915
Merged
Merged
Conversation
With `rewrite_host` on a frontend, `apply_request_rewrites_and_headers` (`lib/src/protocol/mux/router.rs`) rewrote the request authority and then added a synthetic `Host` header block. The HTTP/1.1 converter (`kawa::protocol::h1::converter`) already writes `Host: <authority>` right after the request line, so an HTTP/1.1 backend received two `Host` headers, and servers that reject a duplicate (Go's `net/http`) answered 400. The HTTP/2 converter filters every `host` block, so the block was useless there. An operator request header named `Host` had the same root cause and worse: the backend received the client's authority and the operator's value as two different `Host` lines, the smuggling primitive the code comment claimed to prevent. The authority is now the only carrier of the backend `Host`: no `Host` header block is ever inserted. A non-empty `Host` request header edit replaces the authority (last one wins) unless `rewrite_host` is set, which keeps precedence; an empty one still drops header blocks only. An HTTP/2 backend therefore now receives that edit as `:authority`. The H1→H1 rewrite test now requires exactly one `Host`; new e2e tests cover the operator `Host` edit (H1→H1) and `rewrite_host` from an HTTP/2 frontend to an HTTP/1.1 backend. Fixes #1908 Signed-off-by: Florentin Dubois <[email protected]>
`cargo audit --deny warnings` (CI "cargo audit") fails on main's lockfile with two findings published after its last green run: - RUSTSEC-2026-0433: pulldown-cmark 0.13.5, quadratic parsing of nested image wikilinks with ENABLE_WIKILINKS. Fixed in 0.13.6. A build dependency only, through prost-build. - async-executor 1.14.0 is yanked. Moved to 1.14.1. Lockfile-only: both are patch updates within the existing requirements. Signed-off-by: Florentin Dubois <[email protected]>
Shine-neko
approved these changes
Nov 3, 2026
Brings in #1919 (lockfile) and #1914 (command channel error) and keeps both CHANGELOG slots, each followed by a blank line. Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
added a commit
that referenced
this pull request
Nov 3, 2026
main now carries #1915 as a squash commit, whose CHANGELOG insertion conflicts with the stacked original. Keeps every CHANGELOG slot; the tree is unchanged. Signed-off-by: Florentin Dubois <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1908.
Problem
apply_request_rewrites_and_headers(lib/src/protocol/mux/router.rs) rewrote the request authority forrewrite_host, then inserted a syntheticHostheader block. The H1 converter (kawa::protocol::h1::converter) already writesHost: <authority>right after the request line, so an HTTP/1.1 backend got twoHostheaders. Go'snet/httpand other servers that refuse duplicates answered400. The H2 converter filters everyhostblock, so on H2 backends the block was dropped anyway.The same root cause affected an operator request header named
Host([[…frontends.headers]] position = "request", key = "Host"). Withoutrewrite_host, the backend received the client's authority and the operator's value as two differentHostlines:That is the CWE-444-style primitive the code comment said the dedup prevented.
Change
Host. NoHostheader block is ever inserted.Hostrequest header edit replaces the authority, and the last one wins.rewrite_hoststill takes precedence over it. An emptyHostedit still drops header blocks only, and the authority always reaches the backend.Hostedit is now sent as:authority. Before, the header was silently filtered there. H1 and H2 backends now see the same value.Host:headers" is fixed, anddoc/configure.mddocuments theHostedit rule.Tests (each seen red before the fix)
test_rewrite_host_h1_h1now requires exactly oneHost(backend.local). Before, it usedcontains, which passed with duplicates.test_request_header_host_h1_h1checks that an operatorHostedit gives a singleHost: override.local.test_rewrite_host_h2_h1checks thatrewrite_hostfrom an H2 (TLS) frontend to an H1 backend gives a singleHost: backend.local.Commands run
cargo +nightly fmt --all -- --check: exit 0cargo clippy --all-targets --locked -- -D warnings: exit 0cargo build --all-features --locked: exit 0cargo test --workspace --locked -- --skip tests::fuzz_tests::: exit 0, 3416 passed, 0 failed (e2e: 670 passed)redirect_rewrite_auth_tests+h2_security_header_injection: 47 passedDocs
CHANGELOG
Unreleased› Fixed;doc/configure.md(custom headers section).Dependencies
#1919 (the lockfile fix for
cargo audit) and #1914 are onmain;mainis merged into this branch, so CI runs on exactly the tree this PR lands. The later PRs are stacked on this one. Merge order: #1915 → #1918 → #1916 → #1917.