-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple Host header values handled poorly #8716
Comments
Looks like Jetty interprets the all field values, including commas, as a single "Host" (or Server Name), complete with commas. |
Oh a minor correction: it's not multiple https://httpwg.org/specs/rfc9112.html#request.target
|
We might want to revive the closed PR #7279 as it addressed many of the "bad host" and "bad authority" cases. (just not the multiple header cases) |
Signed-off-by: Joakim Erdfelt <[email protected]>
Opened PR #8717 as a simple way to address this |
Signed-off-by: Joakim Erdfelt <[email protected]>
* Issue #8716 - Handle bad host/authority headers better * Remove extra `Host` header in testcase that doesn't deal with bad Host headers * Create URIUtil.isRegName * Correcting HostPortTest.testValidAuthority * Correcting RequestTest.testInvalidHostHeader * Remove clonable, set to final Signed-off-by: Joakim Erdfelt <[email protected]>
Closing, as PR #8717 is merged. |
Will Jetty issue a security advisory for the previous behaviour for accepting multiple Host headers? Jetty was susceptible of Host header injection attacks when combined with a load balancer / reverse proxy accepting multiple Host headers, as outlined in #7278 (comment). |
@bjorncs please explain how accepting the last Host header is a security advisory? |
@bjorncs there's a few variations of this ... Variation 1: Duplicate headers, same value
This variation is rejected by the HttpParser. Variation 2: Duplicate headers, different values
This variation is rejected by the HttpParser. Variation 3: Single header, comma delimited, with space, same value
As the parsing of the Variation 4: Single header, comma delimited, with space, different values
As the parsing of the Variation 5: Single Header, comma delimited, no space.
As the parsing of the |
What does java support when it comes to the variations of multiple headers with a comma?
|
I tried to generate a CVSS score for this change, but the problem is that on it's own there is no affect - no change of scope, no loss of integrity, no loss of confidentiality, no loss of availability.... so the score is 0.0. It's the kind of issue that needs another component in order to have consequences. I.e. if a front end policed some security policy based on the first host header and then jetty acted on the second host header, that would indeed be a security problem. |
@joakime I'll try to outline the hypothetical scenario from my previous comment. I interpret @Hexles's comment as CDNs such as Cloudflare would route based on the value of the first Host header, while including both Host headers in the forwarded request.
Could the above request access an internal handler/rest-API in this scenario? @gregw Agree, it's a fair assessment that it's not worthy an advisory. A reverse proxy that's non-compliant with RFC-9112 is required, and relying on virtual hosts configuration as a security measure is unlikely. I have not verified whether claims regarding the CDNs' handling of Host headers are true. |
It's easy to verify that scenario 2 does get through Cloudflare (routed by the first There is another variant 6:
This scenario gets past both Cloudflare and Nginx, and I'd be surprised if the @bjorncs your idea about having a single Jetty with two virtual hosts is interesting, and might worth verifying. In my case, it was because of some application-level auth code that determines whether a request is internal by looking at the host (to see if it's using the private Kubernetes domain). In addition, our pentester used this trick to get past WAF to exploit the infamous log4j bug because of course host/URL is logged. |
All, I'm very happy for us to issue a security advisory on this. We were interpreting the host header contrary to the specification, which in some circumstances can definitely be a security issue. It's hard to characterize, but no harm at least advising people that if they are on an old jetty, they need to consider any checking/routing done by an intermediary that might interpret multiple host headers differently to jetty. |
@bjorncs @Hexcles There's been 2 recent PRs in
Default is to reject with 400 Bad Request. These Compliance modes exist allow a server to operate in an unsafe mode while they work with their clients to address their bad usages of HTTP. |
Jetty version(s)
9.4.x thru 12.0.x
Java version/vendor
(use: java -version)
All
OS type/version
All
Description
When a request is received with multiple host headers it's handled poorly.
This was pointed out by @Hexcles at #7278 (comment)
Example using the jetty 11 demos.
So the key bits in the above example are ...
Host: localhost, foo, bar, zed
was sentHttpServletRequest.getRequestURL()
ishttp://localhost, foo, bar, zed/test/dump/info
HttpServletRequest.getServerName()
islocalhost, foo, bar, zed
The text was updated successfully, but these errors were encountered: