<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>22481</bug_id>
          
          <creation_ts>2013-06-26 17:45:08 +0000</creation_ts>
          <short_desc>Spec should include rationale for security checks on localStorage</short_desc>
          <delta_ts>2013-07-26 00:13:09 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Bobby Holley (:bholley)">bobbyholley</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>ian</cc>
    
    <cc>jonas</cc>
    
    <cc>mike</cc>
    
    <cc>w3c</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>89904</commentid>
    <comment_count>0</comment_count>
    <who name="Bobby Holley (:bholley)">bobbyholley</who>
    <bug_when>2013-06-26 17:45:08 +0000</bug_when>
    <thetext>Hixie explained on IRC that it has to do with per-origin storage mutexes, but that&apos;s a bit of a leap to make from just reading the spec. It would be helpful to list that rationale here:

http://www.whatwg.org/specs/web-apps/current-work/#security-localStorage</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90240</commentid>
    <comment_count>1</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-07-03 16:56:01 +0000</bug_when>
    <thetext>Upon further investigation, the storage mutex rationale here doesn&apos;t hold water.

I don&apos;t know why it&apos;s designed this way.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90509</commentid>
    <comment_count>2</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-07-09 20:03:27 +0000</bug_when>
    <thetext>Adam, do you remember why we block scripts that used document.domain from accessing the WebStorage objects from their original origin?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90528</commentid>
    <comment_count>3</comment_count>
    <who name="Bobby Holley (:bholley)">bobbyholley</who>
    <bug_when>2013-07-09 20:53:39 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; Adam, do you remember why we block scripts that used document.domain from
&gt; accessing the WebStorage objects from their original origin?

Well, the wouldn&apos;t have access to the original origin, right? Shouldn&apos;t it just behave like document.cookie and give you the local data from your effective script origin post document.domain?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90559</commentid>
    <comment_count>4</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-07-09 23:36:44 +0000</bug_when>
    <thetext>Do we really want the magic document.domain origins to have storage areas? I&apos;m not sure how we&apos;d even explain that to the user.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90562</commentid>
    <comment_count>5</comment_count>
    <who name="Bobby Holley (:bholley)">bobbyholley</who>
    <bug_when>2013-07-09 23:50:19 +0000</bug_when>
    <thetext>(In reply to comment #4)
&gt; Do we really want the magic document.domain origins to have storage areas?
&gt; I&apos;m not sure how we&apos;d even explain that to the user.

I don&apos;t follow.

I don&apos;t know much about this, but I&apos;d assume that when foo.bar.com sets document.domain to bar.com, document.cookie gives you bar.com&apos;s cookies, and window.localStorage gives you bar.com&apos;s storage. I haven&apos;t tested this in any UA (and haven&apos;t even checked what gecko does) FWIW.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90571</commentid>
    <comment_count>6</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-07-10 00:26:29 +0000</bug_when>
    <thetext>If your origin is &apos;http://sub.example.com:80&apos; and you set document.domain to &apos;example.com&apos;, your effective origin becomes &apos;http://example.com:manual override&apos;.

Other than through document.domain, you can never reach this origin. It doesn&apos;t map to any real Web site.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90572</commentid>
    <comment_count>7</comment_count>
    <who name="Bobby Holley (:bholley)">bobbyholley</who>
    <bug_when>2013-07-10 00:45:45 +0000</bug_when>
    <thetext>(In reply to comment #6)
&gt; If your origin is &apos;http://sub.example.com:80&apos; and you set document.domain to
&gt; &apos;example.com&apos;, your effective origin becomes &apos;http://example.com:manual
&gt; override&apos;.
&gt; 
&gt; Other than through document.domain, you can never reach this origin. It
&gt; doesn&apos;t map to any real Web site.

So, do you get special cookies for http://example.com:manualoverride? If so, then couldn&apos;t we do the same localStorage?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90684</commentid>
    <comment_count>8</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-07-12 19:43:49 +0000</bug_when>
    <thetext>document.cookie, per spec, is unaffected by document.domain. It sets the cookie against the page&apos;s URL (which can change using pushState(), e.g.), not the page&apos;s origin. (Cookies are set to a URL with a path, not to an origin like Storage.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90824</commentid>
    <comment_count>9</comment_count>
    <who name="Bobby Holley (:bholley)">bobbyholley</who>
    <bug_when>2013-07-16 23:02:53 +0000</bug_when>
    <thetext>(In reply to comment #8)
&gt; document.cookie, per spec, is unaffected by document.domain. It sets the
&gt; cookie against the page&apos;s URL (which can change using pushState(), e.g.),
&gt; not the page&apos;s origin. (Cookies are set to a URL with a path, not to an
&gt; origin like Storage.)

Ah, I see. Are there any other APIs in the spec world that store persistent data? What happens for indexedDB?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91179</commentid>
    <comment_count>10</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-07-23 23:34:21 +0000</bug_when>
    <thetext>Good question, I don&apos;t know. Sicking?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91255</commentid>
    <comment_count>11</comment_count>
    <who name="Jonas Sicking (Not reading bugmail)">jonas</who>
    <bug_when>2013-07-24 18:45:03 +0000</bug_when>
    <thetext>A page from &quot;http://foo.bar.com&quot; that has set its document.domain to &quot;bar.com&quot; definitely should not be able to access &quot;bar.com&quot;s local-storage data.

The security model of document.domain is that for a page from &quot;http://foo.bar.com&quot; to be able to interact with &quot;bar.com&quot; in any way, something from &quot;bar.com&quot; has to opt in to that. I.e. a page from &quot;*.bar.com&quot; needs to also set its document.domain to &quot;bar.com&quot;.

I don&apos;t think document.domain should affect the behavior of localStorage at all. It doesn&apos;t affect indexedDB or EventSource or XMLHttpRequest at all. I.e. in all those cases do we behave as if document.domain had not been set.

I.e. if a page on &quot;http://foo.bar.com&quot; sets document.domain to &quot;bar.com&quot; and makes a XHR request to a page on &quot;http://foo.bar.com&quot; it is still treated as a same-origin request. And a request to anything on &quot;bar.com&quot; is still treated as a cross-origin request. And if the request uses CORS, we still send &quot;http://foo.bar.com&quot; as origin.

And if that same page accesses window.indexedDB from its own window, it will get data for the &quot;http://foo.bar.com&quot; origin.

If two pages from &quot;http://foo.bar.com&quot; and &quot;http://crow.bar.com&quot; both set their document.domain to &quot;bar.com&quot;, and the page from &quot;http://foo.bar.com&quot; accesses otherWindow.indexedDB, where &apos;otherWindow&apos; refers to the window for the &quot;http://crow.bar.com&quot;-page, that it would get data for the &quot;http://crow.bar.com&quot; page.

I.e. the data that you receive should be based on the window you are getting the indexedDB property from. document.domain only affect which objects you can reach, it doesn&apos;t otherwise affect storage or network APIs at all.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91297</commentid>
    <comment_count>12</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-07-26 00:12:56 +0000</bug_when>
    <thetext>So basically, remove all the security stuff around Storage... Yeah, that seems reasonable. Ok. Done. This will simplify some of the other discussions, too.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91298</commentid>
    <comment_count>13</comment_count>
    <who name="">contributor</who>
    <bug_when>2013-07-26 00:13:09 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r8090.
Check-in comment: Remove the weird stuff around document.domain and localStorage. It doesn&apos;t really do anything anyway.
http://html5.org/tools/web-apps-tracker?from=8089&amp;to=8090</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>