Bug 155609 - Local file restrictions are also restricting session storage
Summary: Local file restrictions are also restricting session storage
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Brent Fulgham
URL:
Keywords: InRadar
Depends on: 155185
Blocks: 164592
  Show dependency treegraph
 
Reported: 2016-03-17 16:30 PDT by Brent Fulgham
Modified: 2016-11-10 12:34 PST (History)
9 users (show)

See Also:


Attachments
Patch (4.65 KB, patch)
2016-03-17 16:58 PDT, Brent Fulgham
aestes: review+
dbates: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brent Fulgham 2016-03-17 16:30:49 PDT
In Bug 155185, I inadvertently blocked access to sessionStorage for local files. This should still be permitted.
Comment 1 Radar WebKit Bug Importer 2016-03-17 16:41:47 PDT
<rdar://problem/25229461>
Comment 2 Brent Fulgham 2016-03-17 16:58:18 PDT
Created attachment 274341 [details]
Patch
Comment 3 Daniel Bates 2016-03-17 22:58:29 PDT
Comment on attachment 274341 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=274341&action=review

> Source/WebCore/ChangeLog:13
> +        Use of 'sesssionStorage' is governed by SecurityOrigin with third party access
> +        set to 'ShouldAllowFromThirdParty::AlwaysAllowFromThirdParty'. We should not
> +        reject local files for this combination of arguments.

The bug description should come before the the list of included tests.

> LayoutTests/storage/domstorage/sessionstorage/blocked-file-access-expected.txt:3
> +Test that we are permitted access to sessionStorage from a file URL if unversal access is turned off.

Nit: unversal => universal

> LayoutTests/storage/domstorage/sessionstorage/blocked-file-access.html:14
> +Test that we are permitted access to sessionStorage from a file URL if unversal access is turned off.

Ditto.

> LayoutTests/storage/domstorage/sessionstorage/resources/blocked-example.html:16
> +    if (window.testRunner)
> +        testRunner.notifyDone();

This test does not make use of waitUntilDone() so this is not needed.
Comment 4 Daniel Bates 2016-03-17 23:00:28 PDT
(In reply to comment #3)
> > LayoutTests/storage/domstorage/sessionstorage/resources/blocked-example.html:16
> > +    if (window.testRunner)
> > +        testRunner.notifyDone();
> 
> This test does not make use of waitUntilDone() so this is not needed.

Disregard this remark.
Comment 5 Daniel Bates 2016-03-17 23:10:58 PDT
Comment on attachment 274341 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=274341&action=review

> LayoutTests/storage/domstorage/sessionstorage/blocked-file-access.html:1
> +<html>

I do not see the need for this test to use quirks mode. We should opt into standards mode by adding <!DOCTYPE html>.

> LayoutTests/storage/domstorage/sessionstorage/blocked-file-access.html:12
> +<iframe src="resources/blocked-example.html"></iframe>

On another note, is is necessary to embed other page in an iframe? I mean, could we incorporate the content of file resources/blocked-example.html directly into this file?

> LayoutTests/storage/domstorage/sessionstorage/resources/blocked-example.html:1
> +<html>

I do not see the need for this test to use quirks mode. We should opt into standards mode by adding <!DOCTYPE html>.

> LayoutTests/storage/domstorage/sessionstorage/resources/blocked-example.html:10
> +        if (window.sessionStorage) {
> +            console.log("PASS: window.sessionStorage WAS accessible");
> +        }

Nit: We tend to follow the WebKit Code Style Guidelines for JavaScriptCore and omit braces for if-bocks whose body is a single line.

This is OK as-is. I do not see the need to emphasize the word "was" by writing it in all capitals.

> LayoutTests/storage/domstorage/sessionstorage/resources/blocked-example.html:11
> +    } catch(e) {

Nit: Missing space before '('.

> LayoutTests/storage/domstorage/sessionstorage/resources/blocked-example.html:12
> +        console.log("FAIL: window.sessionStorage was NOT accessible");

This is OK as-is. I do not see the need to emphasize the word "not" by writing it in all capitals.

>> LayoutTests/storage/domstorage/sessionstorage/resources/blocked-example.html:16
>> +        testRunner.notifyDone();
> 
> This test does not make use of waitUntilDone() so this is not needed.

Never mind.
Comment 6 Brent Fulgham 2016-03-18 12:02:18 PDT
Comment on attachment 274341 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=274341&action=review

>> Source/WebCore/ChangeLog:13
>> +        reject local files for this combination of arguments.
> 
> The bug description should come before the the list of included tests.

Done.

>> LayoutTests/storage/domstorage/sessionstorage/blocked-file-access-expected.txt:3
>> +Test that we are permitted access to sessionStorage from a file URL if unversal access is turned off.
> 
> Nit: unversal => universal

Ugh! Fixed.

>> LayoutTests/storage/domstorage/sessionstorage/blocked-file-access.html:1
>> +<html>
> 
> I do not see the need for this test to use quirks mode. We should opt into standards mode by adding <!DOCTYPE html>.

OK.

>> LayoutTests/storage/domstorage/sessionstorage/blocked-file-access.html:12
>> +<iframe src="resources/blocked-example.html"></iframe>
> 
> On another note, is is necessary to embed other page in an iframe? I mean, could we incorporate the content of file resources/blocked-example.html directly into this file?

At the time this file is loaded, WKTR is already in a "allow universal file access" mode, and I found that turning it off using "setAllowUniversalAccessFromFileURLs" did not take effect during the load. Perhaps this is a bug in our test infrastructure that we could address someday, but for now the easiest approach was to set the flag, then invoke a new file load.

>> LayoutTests/storage/domstorage/sessionstorage/blocked-file-access.html:14
>> +Test that we are permitted access to sessionStorage from a file URL if unversal access is turned off.
> 
> Ditto.

Fixed.

>> LayoutTests/storage/domstorage/sessionstorage/resources/blocked-example.html:1
>> +<html>
> 
> I do not see the need for this test to use quirks mode. We should opt into standards mode by adding <!DOCTYPE html>.

Agreed.

>> LayoutTests/storage/domstorage/sessionstorage/resources/blocked-example.html:10
>> +        }
> 
> Nit: We tend to follow the WebKit Code Style Guidelines for JavaScriptCore and omit braces for if-bocks whose body is a single line.
> 
> This is OK as-is. I do not see the need to emphasize the word "was" by writing it in all capitals.

OK.

>> LayoutTests/storage/domstorage/sessionstorage/resources/blocked-example.html:11
>> +    } catch(e) {
> 
> Nit: Missing space before '('.

Whoops! Fixed.

>> LayoutTests/storage/domstorage/sessionstorage/resources/blocked-example.html:12
>> +        console.log("FAIL: window.sessionStorage was NOT accessible");
> 
> This is OK as-is. I do not see the need to emphasize the word "not" by writing it in all capitals.

Fixed.
Comment 7 Brent Fulgham 2016-03-18 12:46:40 PDT
Committed r198439: <http://trac.webkit.org/changeset/198439>
Comment 8 Brent Fulgham 2016-11-10 10:59:10 PST
Note: This fix was rolled out in Bug 160169 (https://trac.webkit.org/changeset/203695).
Comment 9 Brent Fulgham 2016-11-10 10:59:42 PST
Change was rolled back in under r208550 <https://trac.webkit.org/changeset/208550>.
Comment 10 Darin Adler 2016-11-10 12:34:40 PST
Comment on attachment 274341 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=274341&action=review

> Source/WebCore/page/SecurityOrigin.cpp:379
> -    if (isLocal() && !m_universalAccess)
> +    if (isLocal() && !m_universalAccess && shouldAllowFromThirdParty != AlwaysAllowFromThirdParty)
>          return false;

A cleaner way to do this would be to move this check down *after* the shouldAllowFromThirdParty check below. The only downside is that this would change behavior for a case which should never happen, when !topOrigin is true. I suppose that makes the cleaner way slightly higher risk, so I suppose it’s safer to leave it this way. But otherwise, I feel it makes the logic a bit clearer by not repeating a check twice.