-
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
Open redirect when sending custom Host header to URL with no trailing forward-slash #5029
Comments
That is indeed an interesting behavior. No virtual hosts is pretty normal. |
This is entirely normal behaviour and is exactly what the host header is intended for. If you have a machine that is hosting multiple virtual domains on the same IP address, then the only way you can ever send a redirect to the correct URL is to use the Host header. If we started using the IP address or server name for such redirects, then we'd have the problem of leaking potentially private information from within a server cluster, as the IP and/or address name. |
Doing some further research, the Location header is defined by https://tools.ietf.org/html/rfc7231#section-7.1.2 and it says that absolute URIs should be resolved against the effective request URI. So I think we are doing things correctly. However, the question remains.... can we do things even better?
|
Finally I don't think this is an open redirect because, whilst Host header is not really trusted data, it is different to a URI path or parameter which can be either entered by a user or passed in a link. A browser cannot be tricked into sending a request to a different host than the host header with typical phishing attacks. To make a Host header different to the network routing implies an attacker already has access to change browser behaviour and/or alter bytes on the wire, so such a connection is already vulnerable. |
I think we could issue a redirect without the hostname portion, no?
|
Yeah, the RFC2616 rules on https://tools.ietf.org/html/rfc7231#section-7.1.2 But this leads to something interesting, as the resolution of a chain of Example: Original Request is against
Which redirects to
Which redirects for login, but this is where it gets interesting... |
I don't see that last example as a show stopper. Perhaps when we know we are in RFC7230 Compliance mode for the connector, we only make the
All other redirects are relative. |
Sounds good. We could even possibly control this with a compliance setting? |
I think it should work with a compliance setting, sure. But I still have 2 scenarios I'm still thinking about.
Are either of those scenarios currently impacting the absolute-uri resolution of the |
@srapizzi what do you think of this issue? We don't think there is a security issue, perhaps just an enhancement to produce relative Are there security tools that check for this particular case? Thanks! |
Hi @sbordet |
Note that if this is considered a vulnerability in jetty, then apache have the exact same "vulnerability":
I think this is just the spec being correctly implemented. |
Provide option to allow relative redirection
Since relative redirects are now allowed by RFC 7230, I've created a PR to add an option to use them when appropriate. |
Thank you @gregw for providing a quick fix |
PR #5038 merged |
Jetty version
9.4.9.v20180320
Java version
Oracle JDK 1.8.0_191-b12
OS type/version
Windows 10
Description
I have found that if you send an HTTP POST request to a Jetty server instance and you don't end the URL with a trailing forward-slash (
/
) it performs a redirection to the URL with the forward-slash appended. With this behaviour I can send a custom Host header which will be included in the redirect response.For example:
I create a socket connection to localhost:8081.
Request
POST /servlet HTTP/1.1
Host: www.google.com:443
Content-Type: application/json
Content-Length: 16
{"name":"value"}
Response
HTTP/1.1 302 Found
Date: Tue, 07 Jul 2020 21:04:38 GMT
Location: http://www.google.com:443/servlet/
Content-Length: 0
I have not configured any virtual hosts.
Is this the intented behaviour? Because this can be regarded as an open redirect
The text was updated successfully, but these errors were encountered: