Repository navigation
Fix false duplicate-Host detection from Bloom filter collisions - #1975
Open
abu-tahir-0 wants to merge 1 commit into
Open
abu-tahir-0 wants to merge 1 commit into
abu-tahir-0 wants to merge 1 commit into
Conversation
The duplicate-header check trusted the header-name Bloom filter, so a collision (e.g. "hxsst" followed by "Host") was rejected as a duplicate. Confirm duplicates against the actual stored header names.
| bool seenHost = false; | ||
| for (HttpRequest::Header *h = req->headers; (++h)->key.length(); ) { | ||
| if (req->bf.mightHave(h->key)) [[unlikely]] { | ||
| if (h->key == "host") [[unlikely]] { |
Contributor
There was a problem hiding this comment.
This check needs to be faster. I'm not sure comparison with C-string is fast in the false case. If you do it like h->key == std::string_view("host", 4) I guess it's guaranteed to be fast since it knows the size always. Maybe even add if (h->key.length() == 4 && .....) to be sure.
This branch has not been deployed
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 #1967
The parser's duplicate-header detection for
Hostconsults a Bloom filter of header names. A Bloom collision — for examplehxsstappearing beforeHost— was treated as a duplicateHostand the request was rejected witherr=3.Change
After the Bloom filter reports a possible duplicate, confirm against the actual stored header names before rejecting, so collisions no longer cause false positives while genuine duplicate
Hostheaders are still rejected.Tests
tests/HttpParser.cpp: a colliding header beforeHostis accepted, the reverse ordering is accepted, and an actual duplicateHostis still rejected.err=3for the collision ordering.HttpParsertest executable passes in the Docker build.