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
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone

Comments

@urld
Copy link
Contributor

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
Copy link
Contributor

/cc @tombergan for any thoughts

@bradfitz bradfitz added this to the Go1.11 milestone Feb 20, 2018
@bradfitz bradfitz added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Feb 20, 2018
@bradfitz
Copy link
Contributor

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.

@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.
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

3 participants