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

Uncaught SecurityError when using iframe #2703

Closed
naorye opened this issue Oct 15, 2015 · 25 comments
Closed

Uncaught SecurityError when using iframe #2703

naorye opened this issue Oct 15, 2015 · 25 comments
Assignees

Comments

@naorye
Copy link

naorye commented Oct 15, 2015

When using videoJS inside an iframe, the following code runs and cause an exception:

var hasAutomationEqualityBug = (function () {
    /* global window */
    if (typeof window === 'undefined') { return false; }
    for (var k in window) {
        if (!blacklistedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
            try {
                equalsConstructorPrototype(window[k]);
            } catch (e) {
                return true;
            }
        }
    }
    return false;
}());

The problem is that window.frameElement throwing the following example:

Uncaught SecurityError: Failed to read the 'frame' property from 'Window': Blocked a frame with origin "https://frontend.dev:8001" from accessing a frame with origin "http://frontend.dev:8000".  The frame requesting access has a protocol of "https", the frame being accessed has a protocol of "http". Protocols must match.
@jtwalters
Copy link

I have the same problem. Confirmed.

@mmcc
Copy link
Member

mmcc commented Oct 15, 2015

So the code snippet you're referencing comes from the ES5-shim, but is this really a VJS issue? Trying to access an HTTPS-origin frame from an HTTP-origin frame isn't ever going to work for obvious security reasons. Mind putting up an example?

@gkatsev
Copy link
Member

gkatsev commented Oct 15, 2015

Sounds like frame is another key that es5-shim might need to add to the blacklistedKeys array. See es-shims/es5-shim#322 for reference.

@jtwalters
Copy link

@mmcc in my case, the issue is occurring with an https iframe inside a cross-origin, https page. Of course we shouldn't expect it to work, but it's still a bug that is effectively breaking my iframe's JS behavior due to the generated SecurityError.

@gkatsev
Copy link
Member

gkatsev commented Oct 15, 2015

What version of videojs are you using? 5.0? Are you using our ie8 shim?

@jtwalters
Copy link

* Video.js 5.0.0 <http://videojs.com/>

I don't believe I'm using any IE8 shim. Not sure how to confirm that.

This SecurityError is with latest stable Google Chrome, BTW.

@gkatsev
Copy link
Member

gkatsev commented Oct 15, 2015

@jtwalters do you have an example?

@jtwalters
Copy link

I put together this jsfiddle which will give you a SecurityError viewable in the console.

@jtwalters
Copy link

Of course this is an oversimplified example and doesn't actually represent the error that I have.

@gkatsev
Copy link
Member

gkatsev commented Oct 15, 2015

Ah, I think i see where it's coming from. This is from our object.assign module which uses an older version of object-keys which has a newer version which has frameElement blacklisted.
Do you want to put together a PR that updates object.assign to the latest version?

@naorye
Copy link
Author

naorye commented Oct 15, 2015

I am using videoJS with npm and require it like this:
var videojs = require(video.js);
I didn't ask to include es5 shim.

@naorye
Copy link
Author

naorye commented Oct 18, 2015

Whenever videojs is inside an iframe, I get this error.

Any solution?

@richardbushell
Copy link
Contributor

Yes, me too, same problem. Videojs 5.0.0 produces the security error in Google Chrome, but the security error stops videojs from loading inside an iFrame. A quick fix would be HUGELY appreciated!

@andriidrebot
Copy link

Same issue, only in the latest chrome (v 46)

@rickyblaha
Copy link

If anyone needs a quick fix in the meantime, modifying this in your own hosted copy of Video.js works for me in Chrome 46:

var hasAutomationEqualityBug = (function () {
  ...
    for (var k in window) {
      if (k === 'frameElement') {
        continue;
      }
      ...
    }
}());

@jemoreno
Copy link

@rickyblaha I am using the CDN version of videojs and the quick fix doesn't fix that issue. Did you manually change the video.js file?

@gkatsev gkatsev self-assigned this Oct 19, 2015
@rickyblaha
Copy link

@jemoreno, just edited my comment to clarify. Since that is immediately invoked it would need to be changed within the library, so I did make that change on my own CDN-hosted copy.

@gkatsev
Copy link
Member

gkatsev commented Oct 19, 2015

Working on getting this fixed.

@gkatsev
Copy link
Member

gkatsev commented Oct 19, 2015

Waiting on ljharb/object-keys#17

@ljharb
Copy link
Contributor

ljharb commented Oct 19, 2015

Also note that the latest versions of es5-shim and object-keys have the blacklisting wrapped with a try/catch, so this should already be "fixed" in the latest version.

That said, thanks for the "frame" PR, as I'd still like to blacklist all throwing keys that I can :-)

@gkatsev
Copy link
Member

gkatsev commented Oct 19, 2015

@ljharb I tried updating to latest object.assign but it still caused problems. Since we're not using es5-shim directly.

@gkatsev
Copy link
Member

gkatsev commented Oct 19, 2015

Oh, removed all of node_modules and reinstalled and it's fixed with latest object.assign. Previously only installed updated version of object.assign.

@richardbushell
Copy link
Contributor

That's great if it's fixed! How long until we can get this in CDN version 5.0.1, or self-hosted release via download (for those of us mortals who can't do a build ourselves)?

@gkatsev
Copy link
Member

gkatsev commented Oct 19, 2015

Hopefully we'll get a fix out tomorrow but don't hold me to that.

gkatsev added a commit to gkatsev/video.js that referenced this issue Oct 19, 2015
gkatsev added a commit to gkatsev/video.js that referenced this issue Oct 20, 2015
@gkatsev
Copy link
Member

gkatsev commented Oct 24, 2015

We have a release available for you to download: https://github.com/videojs/video.js/releases/tag/v5.0.2 (https://github.com/videojs/video.js/tree/v5.0.2/dist) I'll probably push to the CDN on monday.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants