Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
net/http/cookiejar: Domain matching against IP address #12610
The following test fails:
Further inspection shows that it fails with errNoHostname here:
I believe the comment refers to RFC6265 5.1.3. It states that the domain string must either be identical with the string it's matched against, OR that all of the three subsequently listed conditions are met, one of which are that the string being matched must be a host name.
In the case of the matched string being an IP address and the domain string being the same IP address, the first condition is met. I therefor believe that L447-L452 should be removed.
The situation is not really simple: RFC 6265 is not clear whether to allow or deny
The current implementation in Chromium rejects domain cookies in IP addresses
My gut feeling is that cookies with an IP address as the domain-attribute should be
RFC 6265 is not really clear here. I read the following
RFC 6265 section 5.1.3, second bullet, third star  as a definition of host name in
Therefore my understanding of the algorithm to produce a canonicalized host name
RFC 6265 section 5.1.2 step 1  is that an IP address does not qualify as a
and the cookie should be dropped as it is done currently.
The Chromium test case you linked as  shows that Chromium allows a cookie to be set with a domain attribute if that attribute is an exact match (L470-L472 in the same file).
The third star is so that suffix matching is only applied on host names. 5.1.3 also states that if the two strings matches each other exactly, they domain-match.
Regarding RFC6265 5.3:
If I visit the URL http://127.0.0.1/ in my browser, it is my understanding that "the canonicalized request-host" is "127.0.0.1". If the domain-attribute in the Set-Cookie header is set to 127.0.0.1, the canonicalized request-host domain-matches the domain-attribute under the rules of 5.1.3 (exact match).
The comment in the Chromium test case is interesting: "This matches IE/Firefox, even though it seems a bit wrong." Maybe that behaviour is wrong.
One more from the Chromium test case: Chromium treats
As I said RFC 6265 is not clear here.
I think silently converting the domain cookie to a host cookie is okay, but I do not think that domain cookies on IP addresses make sense at all.
Would you have time to test the behaviour on Chrome, FF, IE, Safari and curl? I thinks showing that all these "browsers" handle domain attributes equal to the request IP address the same would add considerable weight to the proposed change.
For the following web service:
sets the cookie "foo" for 127.0.0.1
I will be able to test IE, Safari in the beginning of next week.
Safari 9.0 (11601.1.56)
sets the cookie "foo" for 127.0.0.1 for the previously mentioned test case.
*: Added Expires attribute to make sure a persistent cookie file was created in "Temporary Internet Files".