Skip to content
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

net/http: Redirect only sanitizes relative but not absolute URIs #23961

Closed
urld opened this issue Feb 20, 2018 · 2 comments
Closed

net/http: Redirect only sanitizes relative but not absolute URIs #23961

urld opened this issue Feb 20, 2018 · 2 comments

Comments

@urld
Copy link
Contributor

@urld urld commented Feb 20, 2018

What version of Go are you using (go version)?

go version go1.10 linux/amd64

Does this issue reproduce with the latest release?

yes

What did you do?

Call http.Redirect with various URIs:

https://play.golang.org/p/Sjx3ktkGOSQ

What did you expect to see?

I expect the same uri sanitation happening on both relative and absolute redirects.

http://example.com/foo/
http://example.com/foo/
/foo/
/foo/

What did you see instead?

URIs for absolute Redirects are used as is, without any sanitation, while relative redirect uris

http://example.com/qux/../foo/
http://example.com/qux/../foo//
/foo/
/foo/

RFC 7231 (https://tools.ietf.org/html/rfc7231#section-7.1.2) does not seem to specify if the path contained in the Location header should be "clean".

@bradfitz

This comment has been minimized.

Copy link
Contributor

@bradfitz bradfitz commented Feb 20, 2018

/cc @tombergan for any thoughts

@bradfitz bradfitz added this to the Go1.11 milestone Feb 20, 2018
@bradfitz

This comment has been minimized.

Copy link
Contributor

@bradfitz bradfitz commented May 29, 2018

I think this is working as intended.

Any cleaning we're doing is only because we try to absolute-ify any relative redirects.

But if the user gave us a plausibly correct Location header (in that it's absolute-looking), then we just pass it through.

@bradfitz bradfitz closed this May 29, 2018
@golang golang locked and limited conversation to collaborators May 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.