Uncaught error NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS when writing to document.cookie

RESOLVED FIXED

Status

Firefox OS
General
P3
normal
RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: jrburke, Assigned: bkelly)

Tracking

({perf})

Firefox Tracking Flags

(Not tracked)

Details

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

Attachments

(2 attachments, 1 obsolete attachment)

(Reporter)

Description

4 years ago
Created attachment 786452 [details]
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?
(Reporter)

Comment 2

4 years ago
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.

Comment 3

4 years ago
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

Comment 4

4 years ago
(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/

Comment 5

4 years ago
According to my inverigation, this is not the root cause of system crash. It's just a minor issue within Gecko.
(Reporter)

Updated

4 years ago
Blocks: 932418
Keywords: perf
Whiteboard: [c= p=4 s= u=]
Priority: -- → P3
(Assignee)

Comment 6

4 years ago
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)

Comment 8

4 years ago
Created attachment 8338186 [details] [diff] [review]
third-party-cookie-referrer.patch
Assignee: nobody → bkelly
Status: NEW → ASSIGNED
Attachment #8338186 - Flags: review?(dteller)
(Assignee)

Updated

4 years ago
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+
(Assignee)

Comment 10

4 years ago
Created attachment 8338501 [details] [diff] [review]
third-party-cookie-referrer.patch

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+
(Assignee)

Comment 11

4 years ago
https://tbpl.mozilla.org/?tree=Try&rev=e5d149817e73
(Assignee)

Comment 12

4 years ago
Try looks good, so checkin-needed.
Keywords: checkin-needed
https://hg.mozilla.org/integration/mozilla-inbound/rev/4704a41581c6
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/4704a41581c6
Status: ASSIGNED → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED

Updated

4 years ago
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.