Skip to content

Commit

Permalink
Disallow duplicated Host headers
Browse files Browse the repository at this point in the history
  • Loading branch information
uNetworkingAB committed Oct 27, 2024
1 parent cca5a35 commit addac0b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/HttpParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,12 @@ struct HttpParser {
/* Add all headers to bloom filter */
req->bf.reset();
for (HttpRequest::Header *h = req->headers; (++h)->key.length(); ) {
if (req->bf.mightHave(h->key)) [[unlikely]] {
/* Host header is not allowed twice */
if (h->key == "host" && req->getHeader("host").data()) {
return {HTTP_ERROR_400_BAD_REQUEST, FULLPTR};
}
}
req->bf.add(h->key);
}

Expand Down

0 comments on commit addac0b

Please sign in to comment.