Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to break out of a sandboxed iFrame?

1. What is the issue?

The sandbox attribute added for iFrame elements in HTML5 spec renders any frame breaking/busting/killing method null in modern browsers (tested with current version of Chrome & Safari) if the flag allow-top-navigation is not set, even if the flags allow-forms and allow-scripts are present.

2. What I have tried?

  • Any JavaScript method out there, such as if(top != self) top.location.replace(location);

  • Triggering a submit event on a form with the target="_top" attribute

  • Triggering a click event on an anchor element with the target="_top" attribute. In fact, anchor elements with the target="_top" attribute are rendered useless. So, a nice message to advice users to take action won't work either (as shown in this Flickr iFrame example).

3. What I want to achieve?

I want a way to break out of frames on modern browsers, which have implemented the sandbox attribute for iFrames with the flags allow-forms and allow-scripts present?

Seems like they have just given the missing pieces of a puzzle to all black hats with this attribute.

4. What I am not looking for?

I am looking for a solution, which will break out of frames. Not for a solution, which won't display the site inside frames (such as X-Frame-Options response header) or using CSS to hide the body and such.

like image 602
Shef Avatar asked Dec 09 '12 11:12

Shef


People also ask

How do I remove a sandbox attribute from a website?

On Android, open the Google Chrome menu, then tap on Settings > Privacy and security > Privacy Sandbox.

How do I remove a sandbox attribute from an iframe tag?

You can remove the sandbox attribute from the element using iframe. removeAttribute("sandbox") this will make the iframe non-sandboxed for the next content you load into it, not the currently loaded one.

Are iFrames sandboxed?

Given an iframe with an empty sandbox attribute, the framed document will be fully sandboxed, subjecting it to the following restrictions: JavaScript will not execute in the framed document. This not only includes JavaScript explicitly loaded via script tags, but also inline event handlers and javascript: URLs.


1 Answers

I am afraid that you won't find a solution, as the point of the sandbox is that you can't break out of it.

If there was a hack to break out, it would be classified as a security issue by the vendor and patched quickly.

like image 111
Jonathan Hedley Avatar answered Sep 22 '22 19:09

Jonathan Hedley