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: sanitize Cookie.Domain #6013

Closed
bradfitz opened this issue Aug 1, 2013 · 4 comments
Closed

net/http: sanitize Cookie.Domain #6013

bradfitz opened this issue Aug 1, 2013 · 4 comments
Labels
FrozenDueToAge Suggested Issues that may be good for new contributors looking for work to do.
Milestone

Comments

@bradfitz
Copy link
Contributor

bradfitz commented Aug 1, 2013

The cookie domain validation when writing cookie headers is not correct.

Related, but probably not sufficient:

pkg net's dnsclient.go func isDomainName(s string) bool.
@vdobler
Copy link
Contributor

vdobler commented Aug 7, 2013

Comment 1:

What kind of "validation" do you think of? Currently
`func (c *Cookie) String() string` does not validate anything
it just cleans up unsuitable (for a cookie header) characters
via sanitize{Value,Name}.
Is this issue about adding sanitizeDomain (and maybe
sanitizePath also) which replaces/dropps characters from
Domain (and Path) which do not conform to RFC 6265?
Or should `func (c *Cookie) String() string` be changed:
// String returns the serialization of the cookie for use in a Cookie
// header (if only Name and Value are set) or a Set-Cookie response
// header (if other fields are set).
// **NEW** It returns an empty string if a RFC 6265 conforming Set-Cookie
// response header cannot be constructed from c's fields. **NEW**
func (c *Cookie) String() string
But this would break Go 1 compatibility, or?

@bradfitz
Copy link
Contributor Author

bradfitz commented Aug 7, 2013

Comment 2:

See the updates in 
net/http: don't write out invalid cookie lines
https://code.google.com/p/go/source/detail?r=65920aec044a
This bug is about finishing that CL in the same way.
I deleted "sanitizeValue" because it was undefined and wrong, used by different callers
who needed different things,

@vdobler
Copy link
Contributor

vdobler commented Aug 8, 2013

Comment 3:

pkg net's dnsclient.go func isDomainName(s string) bool
is pretty lax: It allows labels to start with a digit
and allows underscores in labels.  Neither is permitted
by http://tools.ietf.org/html/rfc1034#section-3.5 which
is referenced for cookies in 
http://tools.ietf.org/html/rfc6265#section-4.1.1
Chrome actually allows cookies for domains like 3m.com
Is it okay to be lax for cookie domains too and allow
domains like www.3m.com and _xmpp-server._tcp.google.com?
as the domain-value of a cookie?  I'll assume yes and
will prepare a CL.

@bradfitz
Copy link
Contributor Author

Comment 4:

This issue was closed by revision 4f86a96.

Status changed to Fixed.

@bradfitz bradfitz added fixed Suggested Issues that may be good for new contributors looking for work to do. labels Aug 12, 2013
@rsc rsc added this to the Go1.2 milestone Apr 14, 2015
@rsc rsc removed the go1.2maybe label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge Suggested Issues that may be good for new contributors looking for work to do.
Projects
None yet
Development

No branches or pull requests

4 participants