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

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>167058</bug_id>
          
          <creation_ts>2017-01-14 15:05:05 -0800</creation_ts>
          <short_desc>REGRESSION(r210531): Broke local resource loads from custom local protocols</short_desc>
          <delta_ts>2017-01-24 15:31:01 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore Misc.</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugzilla.gnome.org/show_bug.cgi?id=777246</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=167392</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Catanzaro">mcatanzaro</reporter>
          <assigned_to name="Michael Catanzaro">mcatanzaro</assigned_to>
          <cc>achristensen</cc>
    
    <cc>bfulgham</cc>
    
    <cc>bugs-noreply</cc>
    
    <cc>cgarcia</cc>
    
    <cc>commit-queue</cc>
    
    <cc>dbates</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>tpopela</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1266855</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2017-01-14 15:05:05 -0800</bug_when>
    <thetext>r210531 broke the Epiphany overview (new tab) page, about:overview aka ephy-about://overview. WebKit no longer loads:

 * The large Epiphany symbolic icon that&apos;s displayed on the overview page when no history is available (first run)
 * Any of the webpage snapshots

I added a WTFLogAlways in SecurityOrigin::canDisplay and also in CachedResourceLoader::canRequest. It prints an error like this for each overview snapshot:

File overview does not have same volume as /home/mcatanzaro/.cache/thumbnails/large/f19dd053c0b3baa7ad326f9440c1ac44.png, fail!
canRequest: security origin ephy-about:// cannot display file:///home/mcatanzaro/.cache/thumbnails/large/f19dd053c0b3baa7ad326f9440c1ac44.png

Note that it wouldn&apos;t make sense for &quot;overview&quot; to have an associated volume, since it&apos;s a resource served via custom protocol and not a file on disk.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1266857</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2017-01-14 15:21:37 -0800</bug_when>
    <thetext>This is going to be a blocker for the GTK+ port. I&apos;m not sure the right thing to do here. Is it acceptable to enforce this check only for file URIs and not all local protocols? I&apos;ll submit a patch that does that. The downside of this approach is that it&apos;s not hard to image a custom local URI scheme that allows loading untrusted data.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1266859</commentid>
    <comment_count>2</comment_count>
      <attachid>298863</attachid>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2017-01-14 15:26:21 -0800</bug_when>
    <thetext>Created attachment 298863
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1266880</commentid>
    <comment_count>3</comment_count>
      <attachid>298863</attachid>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2017-01-14 18:23:26 -0800</bug_when>
    <thetext>Comment on attachment 298863
Patch

Yes, I think this is fine. The intent with the original change was to limit a local HTML file from pulling in content from other volumes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1266887</commentid>
    <comment_count>4</comment_count>
      <attachid>298863</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2017-01-14 19:07:47 -0800</bug_when>
    <thetext>Comment on attachment 298863
Patch

Should find a way to make a regression test so we won’t break this again.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1266914</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2017-01-14 21:26:17 -0800</bug_when>
    <thetext>We already have GTK+ API tests /webkit2/WebKitSecurityManager/file-xhr and /webkit2/WebKitWebContext/uri-scheme in TestWebKitWebContext.cpp. I should add a test that combines the two.

That said, /webkit2/WebKitSecurityManager/file-xhr happens to be broken right now, due to r210531, so we did have tests to catch it... they were just platform-specific. It also broke /webkit2/WebKitConsoleMessage/network-error (in TestConsoleMessage.cpp). My patch cannot fix either of them, as those tests do not use custom protocols.

So I think my patch here is insufficient. Perhaps we need to be more lenient with our same-volume check. What is the volume of the page loaded by WebPage::loadHTMLString(&quot;...&quot;, &quot;file:///foo&quot;)? Could it possibly be expected to match the volume of a file that does not exist? (The current check fails if both files are not real files on disk.) Or perhaps the test needs to be updated to not use this construction.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1267129</commentid>
    <comment_count>6</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2017-01-16 05:36:15 -0800</bug_when>
    <thetext>(In reply to comment #5)
&gt; We already have GTK+ API tests /webkit2/WebKitSecurityManager/file-xhr and
&gt; /webkit2/WebKitWebContext/uri-scheme in TestWebKitWebContext.cpp. I should
&gt; add a test that combines the two.
&gt; 
&gt; That said, /webkit2/WebKitSecurityManager/file-xhr happens to be broken
&gt; right now, due to r210531, so we did have tests to catch it... they were
&gt; just platform-specific. It also broke
&gt; /webkit2/WebKitConsoleMessage/network-error (in TestConsoleMessage.cpp). My
&gt; patch cannot fix either of them, as those tests do not use custom protocols.
&gt; 
&gt; So I think my patch here is insufficient. Perhaps we need to be more lenient
&gt; with our same-volume check. What is the volume of the page loaded by
&gt; WebPage::loadHTMLString(&quot;...&quot;, &quot;file:///foo&quot;)? Could it possibly be expected
&gt; to match the volume of a file that does not exist? (The current check fails
&gt; if both files are not real files on disk.) Or perhaps the test needs to be
&gt; updated to not use this construction.

Yes, we are now always failing when a file doesn&apos;t exist. I don&apos;t think we should fail here in this case, but a 404 should be returned instead. This is also causing the context menu api to fail, because we use a fake video source too ( file:///movie.ogg)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1267199</commentid>
    <comment_count>7</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2017-01-16 12:22:45 -0800</bug_when>
    <thetext>Hey Carlos, I wrote a patch to do that, but I realized it&apos;s not the correct solution. It fixes our tests only if the files do not actually exist on disk. Yeah, that&apos;s the usual case, but I think it&apos;s not the right thing to do. For example:

webkit_web_view_load_html (view, &quot;...&quot;, &quot;file:///file-that-does-not-exist&quot;);

Say there really is somehow a file /file-that-does-not-exist. In that case, it&apos;s not loaded from disk, so this volume check should not apply to it, because the actual HTML content is application-controlled. But the file does still exist on disk, which will screw up the permissions check.

Furthermore, using the existence of a file on disk for the permissions testing is not good enough as a malicious file could delete itself from disk in order to bypass the permissions checking.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1267200</commentid>
    <comment_count>8</comment_count>
      <attachid>298863</attachid>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2017-01-16 12:23:33 -0800</bug_when>
    <thetext>Comment on attachment 298863
Patch

I think we definitely want to restrict this permissions check to the &quot;file&quot; protocol, so this patch is correct, but it is not sufficient.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1267753</commentid>
    <comment_count>9</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2017-01-18 08:46:30 -0800</bug_when>
    <thetext>(In reply to comment #8)
&gt; Comment on attachment 298863 [details]
&gt; Patch
&gt; 
&gt; I think we definitely want to restrict this permissions check to the &quot;file&quot;
&gt; protocol, so this patch is correct, but it is not sufficient.

Yes, please, at least push this patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1267860</commentid>
    <comment_count>10</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2017-01-18 13:39:07 -0800</bug_when>
    <thetext>I&apos;m not sure we should; we need to fix file protocol as well, this patch does nothing for that, and we might even need to roll out the original change. This needs further discussion.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1267869</commentid>
    <comment_count>11</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2017-01-18 13:56:28 -0800</bug_when>
    <thetext>(In reply to comment #9)
&gt; (In reply to comment #8)
&gt; &gt; Comment on attachment 298863 [details]
&gt; &gt; Patch
&gt; &gt; 
&gt; &gt; I think we definitely want to restrict this permissions check to the &quot;file&quot;
&gt; &gt; protocol, so this patch is correct, but it is not sufficient.
&gt; 
&gt; Yes, please, at least push this patch.

I&apos;d like to land this patch, too, because I found a few places where we do something similar with local URL schemes that should not fall under this Volume check.

We (Apple) should have a test case for this case, and I can do so as a separate (related) patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1267878</commentid>
    <comment_count>12</comment_count>
      <attachid>298863</attachid>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2017-01-18 14:20:34 -0800</bug_when>
    <thetext>Comment on attachment 298863
Patch

Talked with Brent on IRC. We&apos;re going to land this patch regardless of what we decide regarding how to handle nonexistent files.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1267897</commentid>
    <comment_count>13</comment_count>
      <attachid>298863</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2017-01-18 14:45:11 -0800</bug_when>
    <thetext>Comment on attachment 298863
Patch

Clearing flags on attachment: 298863

Committed r210888: &lt;http://trac.webkit.org/changeset/210888&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1267898</commentid>
    <comment_count>14</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2017-01-18 14:45:17 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1268088</commentid>
    <comment_count>15</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2017-01-19 05:06:56 -0800</bug_when>
    <thetext>(In reply to comment #12)
&gt; Comment on attachment 298863 [details]
&gt; Patch
&gt; 
&gt; Talked with Brent on IRC. We&apos;re going to land this patch regardless of what
&gt; we decide regarding how to handle nonexistent files.

Brent, we landed https://trac.webkit.org/changeset/210922

I think that until we discover some broken application, we might not need to do anything else here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1269271</commentid>
    <comment_count>16</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2017-01-23 17:18:18 -0800</bug_when>
    <thetext>&lt;rdar://problem/30068195&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>298863</attachid>
            <date>2017-01-14 15:26:21 -0800</date>
            <delta_ts>2017-01-18 14:45:11 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-167058-20170114172432.patch</filename>
            <type>text/plain</type>
            <size>1560</size>
            <attacher name="Michael Catanzaro">mcatanzaro</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjEwNzY4CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggOTNkNDNkZmVjMjJlZjUz
ZGY4YzZiNzEwNzk2Yzg3OGRmNjkyNmVkNi4uOWFjY2MyODU1MTE5ZTBiZTk5YTIyMTJkOGZiYTM0
NGQ2Y2NlY2JkYiAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0NoYW5nZUxvZwpAQCAtMSwzICsxLDE2IEBACisyMDE3LTAxLTE0ICBNaWNo
YWVsIENhdGFuemFybyAgPG1jYXRhbnphcm9AaWdhbGlhLmNvbT4K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