Closed
Bug 616264
(CVE-2011-2362)
Opened 14 years ago
Closed 14 years ago
Cookies set for www.foo.com. are sent to www.foo.com
Categories
(Core :: Networking: Cookies, defect)
Tracking
()
People
(Reporter: dchanm+bugzilla, Assigned: ehsan.akhgari)
References
Details
(Keywords: verified1.9.2, Whiteboard: [sg:moderate] (sg:high for affected sites))
Attachments
(7 files, 1 obsolete file)
275.05 KB,
image/png
|
Details | |
558.15 KB,
image/png
|
Details | |
8.18 KB,
patch
|
dwitte
:
review-
|
Details | Diff | Splinter Review |
21.04 KB,
patch
|
ehsan.akhgari
:
review+
sdwilsh
:
review+
|
Details | Diff | Splinter Review |
23.81 KB,
patch
|
sdwilsh
:
review+
dveditz
:
approval1.9.2.17-
christian
:
approval1.9.2.18+
|
Details | Diff | Splinter Review |
21.74 KB,
patch
|
dveditz
:
approval1.9.1.19-
|
Details | Diff | Splinter Review |
3.03 KB,
patch
|
dwitte
:
review+
|
Details | Diff | Splinter Review |
Firefox considers the domains www.foo.com. (HOST1) to be the same as www.foo.com (HOST2) for cookie purposes. Note the trailing period in the first domain. Cookie values set by either HOST1/HOST2 can be retrieved by and sent to the other host. Tests showed that the hosts are considered different from crossdomain purposes. FF4b7, 3.6.11 and Safari 5.0.2 all exhibited the same behavior, while Chrome did not.
See attached screenshots for demonstration.
Steps used in screenshot
1. Visit www.tumblr.com. (controlled by me, sets a cookie)
2. Visit www.tumblr.com (note that the cookie I set is sent to tumblr.com)
The tumblr issue isn't resolved yet.
It seems to me that the Chrome way of handling hosts is more correct. However the specs may say otherwise. There may also be other areas of the code that exhibit similar behavior.
User Agents
FF4b7
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0b7) Gecko/20100101 Firefox/4.0b7
FF3.6.11
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.11) Gecko/20101013 Ubuntu/10.04 (lucid) Firefox/3.6.11
Safari 5.0.2
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-us) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5
Chrome 8.0.552.215
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.215 Safari/534.10
Reporter | ||
Comment 1•14 years ago
|
||
Comment 2•14 years ago
|
||
Is there a reason why this particular behavior is bad? hosts of that form can't exist on the public web, correct?
Reporter | ||
Comment 3•14 years ago
|
||
(In reply to comment #2)
> Is there a reason why this particular behavior is bad? hosts of that form
> can't exist on the public web, correct?
The browser considers the two domains different and I think the cookie handling should reflect that. In most cases, both domains will point to the same host and there will be no data leakage per se.
I don't think I've seen this issue outside of tumblr. The bug is marked private to give tumblr time to fix the issue.
Comment 4•14 years ago
|
||
(In reply to comment #3)
> The browser considers the two domains different and I think the cookie handling
> should reflect that. In most cases, both domains will point to the same host
> and there will be no data leakage per se.
I misunderstood you. The issue is that any site could set a cookie for www.foo.com. and then www.foo.com would get it, correct? Or is it just that if your host has a period at the end?
Comment 5•14 years ago
|
||
The original Netscape spec said to do a "tail match" on the cookie domain with the host name, which would seem to treat foo. differently from foo (as we do elsewhere, e.g. same-origin checks).
The latest draft of the proposed cookie spec update basically says the same thing (in many more words):
http://tools.ietf.org/html/draft-ietf-httpstate-cookie-18#page-18
Our behavior is arguably both non-compliant and unsafe.
We're definitely stripping the trailing dot explicitly, e.g.
http://mxr.mozilla.org/mozilla-central/source/netwerk/cookie/nsCookieService.cpp#1514
http://mxr.mozilla.org/mozilla-central/source/netwerk/cookie/nsCookieService.cpp#2343
nsEffectiveTLDService, however, takes care to preserve the trailing dot. The permission manager does, too. The cookie code strips the trailing dot when saving a block permission (nsCookieService::Remove) but doesn't when calling CheckPrefs(), possibly leading to inconsistent results. That is, if you block a trailing-dot site from the cookie manager "block this site" checkbox then it won't actually be blocked, but if you block the site from the permissions tab of the page-info dialog (or about:data) then the trailing-dot site will in fact have its cookies blocked.
Comment 6•14 years ago
|
||
(In reply to comment #4)
> I misunderstood you. The issue is that any site could set a cookie for
> www.foo.com. and then www.foo.com would get it, correct? Or is it just that if
> your host has a period at the end?
both "foo.com" and "foo.com." save cookies into the same bucket. Both sites will receive all the cookies set by either of them. Scripts on either host will have access to the cookies from both sites (or, whichever was set most recently if they have cookie name collisions).
Obviously this is mostly an edge case because most of the time the two forms do refer to the same host. But it's the kind of inconsistency that turns into a real gotcha if you find a site that's set up right (as tumblr appears to be at the moment).
Updated•14 years ago
|
Whiteboard: [sg:moderate] (sg:high for affected sites)
Updated•14 years ago
|
status1.9.1:
--- → wanted
status1.9.2:
--- → wanted
Updated•14 years ago
|
Assignee: nobody → dwitte
blocking2.0: --- → ?
Comment 7•14 years ago
|
||
FWIW I'm pretty sure this is a regression from 3.6 behavior, so we probably do want to block on it...
my understanding is that the more realistic case is:
www.discovercard.com. (not controlled by me)
www.discovercard.com[.localdomain] (controlled by me at your local internet cafe)
where the [.localdomain] is part of an implied search path.
although, realistically if i'm an evil dns provider, i might as well control everything instead of just properly abusing dns. in which case i could in fact replace www.discovercard.com. (well, until .com is DNSSEC signed in which case someone should hopefully complain that i broke the seal on .com...)
Comment 9•14 years ago
|
||
Per previous comments this seems to be a regression, so blocking.
blocking2.0: ? → beta9+
Keywords: regression
Assignee | ||
Comment 10•14 years ago
|
||
I'm shamelessly stealing this bug from Dan!
Comment 11•14 years ago
|
||
Uh, I already had a complete patch in my queue for this...
I'll skim your patch and see which one is more complete, and we can go from there. If it's mine, you've just tagged yourself for review!
Assignee | ||
Comment 12•14 years ago
|
||
(In reply to comment #11)
> Uh, I already had a complete patch in my queue for this...
>
> I'll skim your patch and see which one is more complete, and we can go from
> there. If it's mine, you've just tagged yourself for review!
Fair enough! :-)
Assignee | ||
Comment 13•14 years ago
|
||
With a test fix!
Attachment #497753 -
Attachment is obsolete: true
Attachment #497896 -
Flags: review?(dwitte)
Attachment #497753 -
Flags: review?(dwitte)
Comment 14•14 years ago
|
||
Comment on attachment 497896 [details] [diff] [review]
Patch (v1.1)
This is the right idea, but not quite complete. New patch forthcoming...
Attachment #497896 -
Flags: review?(dwitte) → review-
Comment 15•14 years ago
|
||
This handles a few more cases: it fails louder for the case where hosts are the string '.' (which is only relevant to file:// URIs, really); it explicitly does not accept such an argument for the 'domain=' attribute of Set-Cookie; and it tweaks the corresponding code in ThirdPartyUtil. (It would kinda be nice if that code wasn't copy-pasted...)
I merged your tests into existing domain-ish cookie tests, and tweaked a few of the others.
How does this look?
Attachment #498157 -
Flags: review?(ehsan)
Assignee | ||
Comment 16•14 years ago
|
||
Comment on attachment 498157 [details] [diff] [review]
patch
So, this patch looks mostly correct to me. The only part which I don't really understand is why we need to fail explicitly for the "." case.
I'm also asking for an additional review, since he's a peer and I don't feel 100% certain that I'm not missing anything on this patch.
Attachment #498157 -
Flags: review?(ehsan)
Attachment #498157 -
Flags: review?(bzbarsky)
Attachment #498157 -
Flags: review+
Comment 17•14 years ago
|
||
(In reply to comment #16)
> So, this patch looks mostly correct to me. The only part which I don't really
> understand is why we need to fail explicitly for the "." case.
Well, it just doesn't make much sense. We allow empty hosts explicitly for the file:// case (and only that), but asking for a domain cookie for that empty host is meaningless.
> I'm also asking for an additional review, since he's a peer and I don't feel
> 100% certain that I'm not missing anything on this patch.
Cool, thanks for looking!
Assignee | ||
Comment 18•14 years ago
|
||
(In reply to comment #17)
> (In reply to comment #16)
> > So, this patch looks mostly correct to me. The only part which I don't really
> > understand is why we need to fail explicitly for the "." case.
>
> Well, it just doesn't make much sense. We allow empty hosts explicitly for the
> file:// case (and only that), but asking for a domain cookie for that empty
> host is meaningless.
Thanks for the clarification!
Comment 19•14 years ago
|
||
Comment on attachment 498157 [details] [diff] [review]
patch
Kicking to Shawn because he's a peer and has less review load.
Attachment #498157 -
Flags: review?(bzbarsky) → review?(sdwilsh)
Comment 20•14 years ago
|
||
(In reply to comment #19)
> Kicking to Shawn because he's a peer and has less review load.
Ha! I'll see if I can get to it tomorrow regardless.
Comment 21•14 years ago
|
||
Comment on attachment 498157 [details] [diff] [review]
patch
r=sdwilsh
Attachment #498157 -
Flags: review?(sdwilsh) → review+
Updated•14 years ago
|
blocking1.9.1: --- → needed
blocking1.9.2: --- → needed
Comment 22•14 years ago
|
||
Comment 7 was wrong; this is old behavior (though I did rework that code for trunk a while back). So we'll want backports here.
Keywords: regression
Comment 23•14 years ago
|
||
Assignee: ehsan → dwitte
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Comment 24•14 years ago
|
||
Would be nice to get a branch patch for this.
Comment 25•14 years ago
|
||
As per today's meeting, beta 9 will be a time-based release. Marking these all betaN+. Please move it back to beta9+ if you believe it MUST be in the next beta (ie: trunk is in an unshippable state without this)
blocking2.0: beta9+ → betaN+
Updated•14 years ago
|
blocking1.9.1: needed → ?
blocking1.9.2: needed → ?
Updated•14 years ago
|
blocking1.9.1: ? → needed
blocking1.9.2: ? → needed
Updated•14 years ago
|
blocking1.9.1: needed → .18+
blocking1.9.2: needed → .15+
Comment 26•14 years ago
|
||
Things work a bit differently on 1.9.2, and I don't want to be aggressive by backporting a bunch of other changes from 2.0. This makes pretty much the minimal set of changes to get sensible API behavior, and equivalent Set-Cookie behavior.
Attachment #511216 -
Flags: review?(sdwilsh)
Comment 27•14 years ago
|
||
The patch for 1.9.1 is basically the same as for 1.9.2, so I'll wait for review feedback before posting it.
Comment 28•14 years ago
|
||
Posting 1.9.1 patch for the record.
Comment 29•14 years ago
|
||
Comment on attachment 511216 [details] [diff] [review]
1.9.2 patch
r=sdwilsh
Attachment #511216 -
Flags: review?(sdwilsh) → review+
Comment 30•14 years ago
|
||
Comment on attachment 511512 [details] [diff] [review]
1.9.1 patch
In that case, this one's almost the same!
Attachment #511512 -
Flags: review?(sdwilsh)
Comment 31•14 years ago
|
||
(The only difference is that we don't have NetUtil or nsICookieManager2.getCookiesFromHost on 1.9.1.)
Comment 32•14 years ago
|
||
Comment on attachment 511512 [details] [diff] [review]
1.9.1 patch
In that case, I don't see why I need to explicitly review this version then!
Attachment #511512 -
Flags: review?(sdwilsh)
Comment 33•14 years ago
|
||
Would anyone like to land this on the 1.9.1 and 1.9.2 branches? I sadly don't have time for treewatching at the moment. :(
Keywords: checkin-needed
Assignee | ||
Updated•14 years ago
|
Attachment #511216 -
Flags: approval1.9.2.17?
Assignee | ||
Updated•14 years ago
|
Attachment #511512 -
Flags: approval1.9.1.19?
Assignee | ||
Comment 34•14 years ago
|
||
Once they get approved, I'll take care of landing them.
Keywords: checkin-needed
Comment 35•14 years ago
|
||
Comment on attachment 511216 [details] [diff] [review]
1.9.2 patch
Approved for 1.9.2.17, a=dveditz for release-drivers
Attachment #511216 -
Flags: approval1.9.2.17? → approval1.9.2.17+
Comment 36•14 years ago
|
||
Comment on attachment 511512 [details] [diff] [review]
1.9.1 patch
Approved for 1.9.1.19, a=dveditz for release-drivers
Attachment #511512 -
Flags: approval1.9.1.19? → approval1.9.1.19+
Assignee | ||
Comment 37•14 years ago
|
||
Assignee | ||
Comment 38•14 years ago
|
||
Dan: this turned the make check tests on 1.9.1 and 1.9.2 orange. Can you take a look please?
Example log: <http://tinderbox.mozilla.org/showlog.cgi?log=Firefox3.6/1301610964.1301617247.7213.gz&fulltext=1>
Comment 39•14 years ago
|
||
Oh, you should be able to diff against and copy over the changes to the relevant tests from m-c's TestCookie. You can see from the log which ones are failing. If you have time to roll a patch I can review :)
Assignee | ||
Comment 40•14 years ago
|
||
This is basically <http://hg.mozilla.org/mozilla-central/raw-diff/d4e6e2377500/netwerk/test/TestCookie.cpp> (verbatim).
It fixes the test failure on 1.9.2, but not on 1.9.1. I'm investigating why right now.
Attachment #523617 -
Flags: review?(dwitte)
Comment 41•14 years ago
|
||
Comment on attachment 523617 [details] [diff] [review]
TestCookie.cpp fix for 1.9.2
Wonderful. r=dwitte
Attachment #523617 -
Flags: review?(dwitte) → review+
Assignee | ||
Comment 42•14 years ago
|
||
Comment on attachment 523617 [details] [diff] [review]
TestCookie.cpp fix for 1.9.2
The reason that this patch didn't fix 1.9.1 was a build problem. A clobber has fixed the problem completely, so I'll land it on both branches.
Assignee | ||
Comment 43•14 years ago
|
||
http://hg.mozilla.org/releases/mozilla-1.9.2/rev/34ce440e4b15
http://hg.mozilla.org/releases/mozilla-1.9.1/rev/4d8083b91ac8
And:
http://hg.mozilla.org/releases/mozilla-1.9.2/rev/5db56d0cfa3b
http://hg.mozilla.org/releases/mozilla-1.9.1/rev/011010dc4058
Because apparently I suck at pushing stuff today. :/
Updated•14 years ago
|
Assignee | ||
Comment 44•14 years ago
|
||
The branch fixes here have caused bug 650522 on 1.9.1 and 1.9.2.
Assignee | ||
Comment 45•14 years ago
|
||
Backed out from 1.9.1 and 1.9.2 due to the regression in bug 650522:
http://hg.mozilla.org/releases/mozilla-1.9.2/rev/1a8da3d914c3 (default)
http://hg.mozilla.org/releases/mozilla-1.9.2/rev/fab6db5c327d (relbranch)
http://hg.mozilla.org/releases/mozilla-1.9.1/rev/9e0d3f6ee9af (default)
http://hg.mozilla.org/releases/mozilla-1.9.1/rev/b2756532de0f (relbranch)
blocking1.9.1: .19+ → ?
blocking1.9.2: .17+ → ?
Updated•14 years ago
|
Updated•14 years ago
|
blocking1.9.1: ? → .20+
blocking1.9.2: ? → .18+
Comment 46•14 years ago
|
||
Comment on attachment 511216 [details] [diff] [review]
1.9.2 patch
un-approving the patches we had to back out.
Attachment #511216 -
Flags: approval1.9.2.17+ → approval1.9.2.17-
Updated•14 years ago
|
Attachment #511512 -
Flags: approval1.9.1.19+ → approval1.9.1.19-
Comment 47•14 years ago
|
||
Re-assigning to Ehsan to re-land this on 1.9.2 along with the patch in bug 650522. That patch still needs reviews before approval, you could put a roll-up patch in this bug so it shows up on our higher-priority "blocking" list.
Assignee: dwitte → ehsan
blocking1.9.1: .20+ → ---
Assignee | ||
Comment 48•14 years ago
|
||
Dan: ping? I need review on bug 650522. The code freeze for 1.9.2.18 is this monday, and if I don't get reviews in time, this will miss the release...
Comment 49•14 years ago
|
||
I missed it last weekend. :( I'll take a look by end of day tomorrow. If I forget, please ping!
Assignee | ||
Updated•14 years ago
|
Attachment #511216 -
Flags: approval1.9.2.18?
Attachment #511216 -
Flags: approval1.9.2.18? → approval1.9.2.18+
Assignee | ||
Comment 50•14 years ago
|
||
Comment 51•14 years ago
|
||
Verified for 1.9.2.18 using original scenario in comment 0 and build Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18pre) Gecko/20110607 Namoroka/3.6.18pre (.NET CLR 3.5.30729).
Verified that the checked in test is passing as well.
Keywords: verified1.9.2
Updated•14 years ago
|
Alias: CVE-2011-2362
Updated•14 years ago
|
Group: core-security
You need to log in
before you can comment on or make changes to this bug.
Description
•