Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different file:// paths are not treated as different origins #21260

Closed
moughxyz opened this issue Nov 22, 2019 · 3 comments
Closed

Different file:// paths are not treated as different origins #21260

moughxyz opened this issue Nov 22, 2019 · 3 comments

Comments

@moughxyz
Copy link

moughxyz commented Nov 22, 2019

Issue Details

Electron Version: 7.1.2 (but also same behavior on 5.x and 6.x)
Operating System: macOS 10.14.6

Expected Behavior

Different file:// paths should be treated as different origins, according to @MarshallOfSound's post here:

Unique file:// URLs are all considered on different origins for security reasons, this is the same behavior as a browser

However, different files appear to be able to share localStorage. I've attached a simple demo project.

index.html:

localStorage.setItem("foo", "bar");
console.log("Read value from index.html:", localStorage.getItem("foo"));
// Outputs "bar"

child.html (as iframe):

console.log("Read value from child.html:", localStorage.getItem("foo"));
// Outputs "bar", but should be null.

We expect child.html, which has a different file:// location, to not be able to read index.html's localStorage values.

Actual Behavior

child.html iframe is able to read the localStorage values that index.html set.

To Reproduce

Run this project:
electron-same-origin.zip

Screen Shot 2019-11-22 at 11 05 56 AM

@moughxyz
Copy link
Author

For the record, both the latest versions of Chrome and Safari behave similarly. They treat all files as having same origin. However, Firefox handles this correctly and gives a unique localStorage context to each unique file path.

Chrome:
Screen Shot 2019-11-22 at 1 40 05 PM

Firefox:
Screen Shot 2019-11-22 at 1 43 27 PM

@nornagon
Copy link
Member

Unfortunately it's beyond the scope of the Electron project to change this behavior in Chromium. Please raise a bug upstream: https://crbug.com/new

@moughxyz
Copy link
Author

moughxyz commented Nov 22, 2019

Related threads:

https://bugs.chromium.org/p/chromium/issues/detail?id=794098, https://bugs.chromium.org/p/chromium/issues/detail?id=957695#c8

https://bugzilla.mozilla.org/show_bug.cgi?id=1500453

Looks like this issue is being actively discussed on the Chromium side, and just recently merged in Firefox 68.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants