Monday, March 26, 2007

Partially stopping sites breaking out of frames in Mozilla

I've been looking for ways to stop sites breaking out of frames for a long time now, and haven't been able to find anything.

And I still haven't been able to get anything working the way I'd like it to, but since I don't have much time these days I thought I'd throw this out there to see if anyone could figure something out. What I'm trying here is to be able to execute XSS attacks within iframes against sites which break out of iframes at the top of each page, but sadly I'm having almost no real success.

Using the idea that I used to implement this;, it is possible to stop site breaking out of frames.

Using the following code:
function test(e) {
    window.setTimeout ("stop();", 1);


window.onbeforeunload = test;

<iframe src="" />

But while it is possible to stop from breaking out of an iframe, the moment we call the stop(); function, the iframe also stops loading. So any XSS attacks after the frame breaking code will not be executed.

So as you can see I haven't been able to figure anything out which will stop the top window being changed, but not stop the iframe being loaded. Hopefully someone else will have more luck.


Anonymous said...

try using security=restricted in your iframe.

note: this does not work in mozilla, only IE.

from and

kuza55 said...

Awesome! Thanks heaps Anonymous!

It also seems that this works in IE7 as well, which is cool.

Again - thanks, :)

Doug Miller said...

As mentioned, works great for IE. Anyone know a solution for firefox?