Closed Bug 902121 Opened 11 years ago Closed 11 years ago

Uncaught error NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS when writing to document.cookie

Categories

(Firefox OS Graveyard :: General, defect, P3)

x86
macOS
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: jrburke, Assigned: bkelly)

Details

(Keywords: perf, Whiteboard: [c= p=4 s=2013.12.06 u=])

Attachments

(2 files, 1 obsolete file)

Attached file cookietest app
When running on an unagi device with mozilla-central, I see the following error in the logcat when trying to set document.cookie from a certified app:

E/GeckoConsole(  509): ThirdPartyCookieProbe: Uncaught error [Exception... "Component returned failure code: 0x804b0050 (NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS) [nsIEffectiveTLDService.getBaseDomainFromHost]"  nsresult: "0x804b0050 (NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS)"  location: "JS frame :: resource://gre/modules/ThirdPartyCookieProbe.jsm :: normalizeHost :: line 181"  data: no]
E/GeckoConsole(  509): undefined

Shows up with latest B2G master with mozilla central (did a BRANCH=master configure and build of B2G today), but has been that way for the week since I started using mozilla-central.

Steps to reproduce:

1) Install the attached zip file by using the FirefoxOS Simulator to push the expanded zip file to the device. Instructions on how to do that available here:

https://github.com/jrburke/gaia-dev-zip#for-the-ux-person

2) Open the cookietest app and have logcat running. The error should show up.

It did not show up with b2g18.

A cookie is used by the email app to allow a fast-restore into message list from a cold boot, so this message will show up in the log for anyone launching the email app.
Is this potentially related to the problem cited in https://bugzilla.mozilla.org/show_bug.cgi?id=901697#c1?
It sounds like the same root cause. If I had to guess, something with the structure or kind of the URL/protocol used for packaged apps is not fitting with some cookie checks.

If there is a preference to address the issue by using that other ticket, that is fine with me. This one has a small app test case that may be useful.
Got the same issue when opening delicious.com, which may read/write some data to cookie.

I'm using the geeksphone 1.2 image on KEON, the logcat shows uncaught exception:

E/GeckoConsole( 1931): ThirdPartyCookieProbe: Uncaught error [Exception... "Component returned failure code: 0x804b0050 (NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS) [nsIEffectiveTLDService.getBaseDomainFromHost]"  nsresult: "0x804b0050 (NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS)"  location: "JS frame :: resource://gre/modules/ThirdPartyCookieProbe.jsm :: normalizeHost :: line 181"  data: no]
E/GeckoConsole( 1931): undefined
(In reply to classicning from comment #3)
> Got the same issue when opening delicious.com, which may read/write some
> data to cookie.
> 
> I'm using the geeksphone 1.2 image on KEON, the logcat shows uncaught
> exception:
> 
> E/GeckoConsole( 1931): ThirdPartyCookieProbe: Uncaught error [Exception...
> "Component returned failure code: 0x804b0050
> (NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS)
> [nsIEffectiveTLDService.getBaseDomainFromHost]"  nsresult: "0x804b0050
> (NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS)"  location: "JS frame ::
> resource://gre/modules/ThirdPartyCookieProbe.jsm :: normalizeHost :: line
> 181"  data: no]
> E/GeckoConsole( 1931): undefined

And this issue will crash the whole system. Vote for it because it's a critical one needed to be fixed.

I cannot reproduce it on simulator. But users with other devices have confirmed this issue:
http://www.reddit.com/r/FireFoxOS/comments/1o1ovg/system_crashed_when_opening_deliciouscom_from_keon/
According to my inverigation, this is not the root cause of system crash. It's just a minor issue within Gecko.
Blocks: 932418
Keywords: perf
Whiteboard: [c= p=4 s= u=]
Priority: -- → P3
It seems that for these cookies on b2g the issuer URI is not set.  Therefore the code here sends "?" for the referrer URI:

  http://mxr.mozilla.org/mozilla-central/source/netwerk/cookie/nsCookieService.cpp#1772

But the telemetry ThirdPartyCookieProbe.jsm always tries to normalize this URI:

  http://mxr.mozilla.org/mozilla-central/source/toolkit/components/telemetry/ThirdPartyCookieProbe.jsm#79

Apparently trying to normalize "?" throws an exception because its an invalid URI.

David, what do you think is the correct fix here?  Skip the normalization if |referrer === "?"| ?
Flags: needinfo?(dteller)
(In reply to Ben Kelly [:bkelly] from comment #6)
> David, what do you think is the correct fix here?  Skip the normalization if
> |referrer === "?"| ?

Sounds like a good plan.
Flags: needinfo?(dteller)
Assignee: nobody → bkelly
Status: NEW → ASSIGNED
Attachment #8338186 - Flags: review?(dteller)
No longer blocks: 932418
Comment on attachment 8338186 [details] [diff] [review]
third-party-cookie-referrer.patch

Review of attachment 8338186 [details] [diff] [review]:
-----------------------------------------------------------------

::: toolkit/components/telemetry/ThirdPartyCookieProbe.jsm
@@ +74,5 @@
>          // Not a third-party cookie
>          return;
>        }
>        // Add host to this._thirdPartyCookies
> +      let firstParty = (referrer === "?") ? referrer : normalizeHost(referrer);

Yes, but please add a comment.
Attachment #8338186 - Flags: review?(dteller) → review+
Thanks for the review!

Added comment indicating that nsCookieService will pass "?" if the issuer is unknown and that we don't want to try to normalize an invalid URI like this.

Carrying r+ forward.
Attachment #8338186 - Attachment is obsolete: true
Attachment #8338501 - Flags: review+
Try looks good, so checkin-needed.
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/4704a41581c6
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [c= p=4 s= u=] → [c= p=4 s=2013.12.06 u=]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: