The X-Frame-Options response header

  • Revision slug: The_X-FRAME-OPTIONS_response_header
  • Revision title: The X-Frame-Options response header
  • Revision id: 44943
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment add example for Apache; 36 words added, 4 words removed

Revision Content

{{ gecko_minversion_header("1.9.2.9") }}

The X-Frame-Options HTTP response header can be used to indicate whether or not a browser should be allowed to render a page in a {{ HTMLElement("frame") }} or {{ HTMLElement("iframe") }}. Sites can use this to avoid clickjacking attacks, by ensuring that their content is not embedded into other sites.

Using X-Frame-Options

There are two possible values for X-Frame-Options:

DENY
The page cannot be displayed in a frame, regardless of the site attempting to do so.
SAMEORIGIN
The page can only be displayed in a frame on the same origin as the page itself.

In other words, if you specify DENY, not only will attempts to load the page in a frame fail when loaded from other sites, attempts to do so will fail when loaded from the same site. On the other hand, if you specify SAMEORIGIN, you can still use the page in a frame as long as the site including it in a frame it is the same as the one serving the page.

Configuring Apache

To configure Apache to send the X-Frame-Options header for all pages, add this to your site's configuration:

Header always append X-Frame-Options SAMEORIGIN

Results

When an attempt is made to load content into a frame, and permission is denied by the X-Frame-Options header, Firefox currently renders about:blank into the frame. At some point, an error message of some kind will be displayed in the frame instead.

Browser compatibility

Browser Lowest version
Internet Explorer 8.0
Firefox (Gecko) 3.6.9 (1.9.2.9)
Opera 10.50
Safari 4.0
Chrome 4.1.249.1042

See also

Revision Source

<p>{{ gecko_minversion_header("1.9.2.9") }}</p>
<p>The X-Frame-Options HTTP response header can be used to indicate whether or not a browser should be allowed to render a page in a {{ HTMLElement("frame") }} or {{ HTMLElement("iframe") }}. Sites can use this to avoid clickjacking attacks, by ensuring that their content is not embedded into other sites.</p>
<h2>Using X-Frame-Options</h2>
<p>There are two possible values for X-Frame-Options:</p>
<dl> <dt><code>DENY</code></dt> <dd>The page cannot be displayed in a frame, regardless of the site attempting to do so.</dd> <dt><code>SAMEORIGIN</code></dt> <dd>The page can only be displayed in a frame on the same origin as the page itself.</dd>
</dl>
<p>In other words, if you specify <code>DENY</code>, not only will attempts to load the page in a frame fail when loaded from other sites, attempts to do so will fail when loaded from the same site. On the other hand, if you specify <code>SAMEORIGIN</code>, you can still use the page in a frame as long as the site including it in a frame it is the same as the one serving the page.</p>
<h3>Configuring Apache</h3>
<p>To configure Apache to send the X-Frame-Options header for all pages, add this to your site's configuration:</p>
<pre>Header always append X-Frame-Options SAMEORIGIN
</pre>
<h2>Results</h2>
<p>When an attempt is made to load content into a frame, and permission is denied by the X-Frame-Options header, Firefox currently renders about:blank into the frame. At some point, an error message of some kind will be displayed in the frame instead.</p>
<h2>Browser compatibility</h2>
<table class="standard-table"> <thead> <tr> <th scope="col">Browser</th> <th scope="col">Lowest version</th> </tr> </thead> <tbody> <tr> <td>Internet Explorer</td> <td>8.0</td> </tr> <tr> <td>Firefox (Gecko)</td> <td>3.6.9 (1.9.2.9)</td> </tr> <tr> <td>Opera</td> <td>10.50</td> </tr> <tr> <td>Safari</td> <td>4.0</td> </tr> <tr> <td>Chrome</td> <td>4.1.249.1042</td> </tr> </tbody>
</table>
<h2>See also</h2>
<ul> <li><a class=" external" href="http://blogs.msdn.com/b/ie/archive/2009/01/27/ie8-security-part-vii-clickjacking-defenses.aspx" title="http://blogs.msdn.com/b/ie/archive/2009/01/27/ie8-security-part-vii-clickjacking-defenses.aspx">ClickJacking Defenses - IEBlog</a></li>
</ul>
Revert to this revision