Open phkavitha opened 9 years ago
Not only can we, we do access the parent window. (in order to update the address bar)
We are also running without a content security policy in place.
Valid point. I'm not sure we could keep the current architecture (using doc.write) if we host the iframe on another domain (right now, it's about:blank).
Could you write a test that demonstrates your point?
We might be able to use a different domain, combined with postmessage..
All versions of IE (other than Edge) have serious bugs in their postMessage support. Therefore we would likely have to limit our support to non IE browsers if we use postMessage. http://caniuse.com/#search=postMessage
Is a different domain absolutely necessary? What about sandboxed iframes? http://caniuse.com/#feat=iframe-sandbox
Whatever approach works is fine by me. The postMessage issues in IE mostly refer to other windows/tabs and lack of support for sending objects (which is not really an issue).
Whether we use a different origin or a sandbox, we will still need a way to communicate with the frame which will most likely be postMessage (which is also what the Ember Inspector uses).
Plan of action:
Request for comments.
:+1:
@rwjblue @stefanpenner Comments on plan of action?
All versions of IE (other than Edge) have serious bugs in their postMessage support. Therefore we would likely have to limit our support to non IE browsers if we use postMessage. http://caniuse.com/#search=postMessage
Although this is true, they will work fine for our use-case.
Is a different domain absolutely necessary? What about sandboxed iframes? http://caniuse.com/#feat=iframe-sandbox
Yes, I believe so. Sandboxing a frame (without just reenabling the parts that are dangerous) will break things that users are used to, like document.cookies, localstorage, indexdb, WebWoker etc.
for example:
Uncaught SecurityError: Failed to read the 'cookie' property from 'Document': The document is sandboxed and lacks the 'allow-same-origin' flag.
Uncaught SecurityError: Failed to read the 'localStorage' property from 'Window': The document is sandboxed and lacks the 'allow-same-origin' flag.(anonymous function) @ foo.html:2
@hjdivad is likely a good person to pull in, as he has done copious work with iframes postMessage/messageChannel
@Gaurav0 i do like your plan of attack, I would suggest it may need to be revised due to ^^.
Lets also see what @hjdivad has to say
I am ok with breaking document.cookies and localStorage. @joostdevries ?
@Gaurav0's plan looks good to me.
I would add IE conditional comments to make sure unprotected iframes aren't run in IE8
Also, I'd recommend using MessageChannel
over window.postMessage
. We had some users run into bugs with Oasis.js
because some libraries don't use window.postMessage
properly (ie they failed to check that they were processing their own messages). There's a polyfill for FF and IE9 support.
Also we might be able to get cookie
and localStorage
working with proxies (that sync-d async over MessageChannel
).
The vulnerability is now fixed and the fix is released but I'll keep this open because using a different domain is probably a better solution than the current fix (using sandbox
/srcdoc
)
@phkavitha Thanks for pointing this out! In the future though, any suspected vulnerabilities are best reported to security@emberjs.com so we can work on a fix before disclosing.
Firstly, the app is really cool. Hats off!!
In order to prevent XSS attacks and other security issues, should the iframe in ember-twiddle point to a different domain? Similar to JSFiddle. Currently, we can access the parent window from the iframe code and can access the browser cookies as well.
Correct me if my understanding is wrong.