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

Prevent iframes from breaking out and redirecting the BrowserWindow hosting the iframe? #656

Closed
kirkouimet opened this issue Sep 18, 2014 · 6 comments · Fixed by #740
Closed

Comments

@kirkouimet
Copy link
Contributor

For example, if you try to create an atom-shell app that has an iframe that references github.com, Github uses an iframe breaking technique to redirect the top window to the src of the iframe.

<iframe src="http://www.github.com/" name="disable-x-frame-options" sandbox="none"></iframe>

Is there anyway to trick the iframe to make it think it is the top window?

If not, what is the best way to manage a bunch of individual BrowserWindows inside of a main window?

@thomasjo
Copy link
Contributor

node-webkit got support for this exact functionality a while ago, perhaps it could be used as inspiration?
rogerwang/WebKit_trimmed@12d8e15

@jhleath
Copy link

jhleath commented Oct 3, 2014

Based on this, I would assume that you could get the same functionality by adding the following attribute to your iframe:

sandbox="allow-forms allow-popups allow-pointer-lock allow-same-origin allow-scripts"

(Note the exclusion of allow-top-navigation.)

@frankhale
Copy link
Contributor

@huntaub, just tested this and it works nicely!

@TosinAdekoya
Copy link

@huntaub Thanks man.

@mb21
Copy link

mb21 commented Dec 2, 2018

From MDN:

When the embedded document has the same origin as the main page, it is strongly discouraged to use both allow-scripts and allow-same-origin at the same time, as that allows the embedded document to programmatically remove the sandbox attribute. Although it is accepted, this case is no more secure than not using the sandbox attribute.

@minecraftchest1
Copy link

I tried it and the page wouldn't work anymore.

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

Successfully merging a pull request may close this issue.

8 participants