Information Security Stack Exchange is a question and answer site for information security professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The Security attribute was implemented to prevent XSS attacks in iFrames by disabling any JS implemented in the iFrame source, therefore indeed eliminating XSS attacks, but also disabling any security scripts like frame busters, killers & etc.

For example, here are three pages:

Victims Page

<script type="text/javascript">
if(top != self) top.location.replace(location);
<body bgcolor="red">
<img src="kitten.jpg" width="100%" height="100%">

This page contains a very poor frame buster, but good enough for this demonstration. In case the page is not the top frame in his window it redirects the window to the page location.

Page A

<center><iframe src="noIFrame.htm" border=1>    </center>

This page contains an example, what happens when the attacker just add the page using iframe, without enabling the security attribute on. The result of opening this page is a quick glance at the click jackers page and then the browser redirection to the page location.

Page B

<center><iframe src="noIFrame.htm" security="restricted" border=1></center>

Finally, this page demonstrates implementing the security attribute. The iFrame is loaded, and since the attribute is set to restricted the frame busting script is not redirecting the browser to the victims page location. Note this attack is viable only in IE8 and above.

Now assuming a malicious user can upload files to the victims web server*, (disabling by my understanding the possible use of X-Frame-Options) how can the victim protect his website from click jacking attacks against his IE users?

*This is an hypothetical question, of course if attacker has access to the web server domain he would attack differently.

share|improve this question
up vote 3 down vote accepted

The only way to prevent clickjacking on a version of IE too old to support X-Frame-Options is to make the page dependent on JavaScript, so that it breaks when run with security="restricted". For example:

<style type="text/css">
   body.notframed #warning { display: none; }
   body.framed #content { display: none; }
<body class="framed">
   <script type="text/javascript">
       if (top==self)
           document.body.className= 'notframed';
   <div id="content">
   <div id="warning">
       This site cannot be used in a frame or with JavaScript disabled.

Obviously this has strongly negative accessibility implications. If the site in question already doesn't work without JS it might be acceptable, but it isn't usually worth it.

(It also demonstrates the tactic of making your page unusable instead of trying to redirect the top page as in the 'very poor' framebuster. Indeed, the redirect option cannot be made secure.)

I'm not sure what your last comment is referring to - X-Frame-Options doesn't prevent file uploads, but it works fine to protect against framing from any site (third- or first-party), the only problem with it is the lack of support in old versions of IE.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.