Repository navigation
refuse a proxied path that does not start with a slash - #2638
Merged
Merged
Conversation
For a plain HTTP proxy the request target is the absolute-form URI, built as "http://host:port" followed directly by the path. A path that does not begin with '/', such as "@evil.example/x" or ".evil.example/x", therefore extends the authority, and the proxy connects to another host with the origin's credentials. Both ClientImpl::handle_request and open_stream_ now refuse such a path before anything is written.
Owner
|
Thanks for the fix. Refusing |
Contributor
Author
|
Thanks for merging this, and agreed that the asterisk-form mapping can wait until someone actually needs it. |
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.
Proxied path can extend the target host
Problem: with
set_proxy()on a plainClient, the request target is"http://host:port"followed directly by the path, and nothing checks that the path starts with/.cli.Get("@evil.example/x")is sent asGET http://origin.example:8080@evil.example/x, and.evil.example/xor:81/xchange the host or port the same way. The proxy routes on the absolute-form URI (RFC 9112 3.2.2), so it connects to that other host and forwards the origin'sAuthorizationheader with it. Without a proxy the same path stays on the client's own host.Fix:
ClientImpl::handle_requestandopen_stream_now refuse such a path before anything is written, using theError::Writethat other locally rejected request targets already return. Paths starting with/are unchanged.Reviewer notes:
ProxyAbsoluteFormTest.PathMustNotExtendTheAuthoritycovers the buffered and the stream path. It fails on master (the proxy receives the redirected requests) and passes with the fix.OPTIONS *through a plain proxy is now refused as well. Before this change it went out ashttp://host:port*, which was never valid either, so I think refusing it is reasonable, but I am happy to map it to the bare authority (RFC 9112 3.2.4) if you would prefer that.