<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://keepitlocked.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>KeepItLocked.net : Clickjacking, Framebusting</title><link>http://keepitlocked.net/archive/tags/Clickjacking/Framebusting/default.aspx</link><description>Tags: Clickjacking, Framebusting</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP2 (Build: 20611.960)</generator><item><title>Preventing Clickjacking with Framebusting</title><link>http://keepitlocked.net/archive/2008/11/07/preventing-clickjacking-with-framebusting.aspx</link><pubDate>Fri, 07 Nov 2008 17:26:00 GMT</pubDate><guid isPermaLink="false">a3f75fb5-0505-4d35-9795-aaa2ed659a71:43</guid><dc:creator>Alex</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://keepitlocked.net/rsscomments.aspx?PostID=43</wfw:commentRss><comments>http://keepitlocked.net/archive/2008/11/07/preventing-clickjacking-with-framebusting.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://www.schneier.com/blog/archives/2008/10/clickjacking.html" mce_href="http://www.schneier.com/blog/archives/2008/10/clickjacking.html"&gt;Clickjacking&lt;/a&gt; is a recently disclosed attack where users are fooled into unknowingly performing sensitive actions on external sites. It's been &lt;a href="http://blog.guya.net/2008/10/07/malicious-camera-spying-using-clickjacking/" mce_href="http://blog.guya.net/2008/10/07/malicious-camera-spying-using-clickjacking/"&gt;demonstrated&lt;/a&gt; in &lt;a href="http://vimeo.com/1912736" mce_href="http://vimeo.com/1912736"&gt;several&lt;/a&gt;
		&lt;a href="http://www.pirosoft.it/index.php/Security-News/Flash-pericolo-ClickJacking.html" mce_href="http://www.pirosoft.it/index.php/Security-News/Flash-pericolo-ClickJacking.html"&gt;videos&lt;/a&gt;. Although it's similar to &lt;a href="http://en.wikipedia.org/wiki/Cross-site_request_forgery" mce_href="http://en.wikipedia.org/wiki/Cross-site_request_forgery"&gt;cross-site request forgery&lt;/a&gt;, it can't be prevented using a &lt;a href="http://keepitlocked.net/archive/2008/10/17/preventing-csrf-the-right-way.aspx" mce_href="http://keepitlocked.net/archive/2008/10/17/preventing-csrf-the-right-way.aspx"&gt;secret token&lt;/a&gt; - all form submissions and link clicks look valid because the user is interacting with the actual site.
&lt;/p&gt;&lt;p&gt;Several proposed fixes are outlined nicely &lt;a href="http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2008-September/016284.html" mce_href="http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2008-September/016284.html"&gt;here&lt;/a&gt;. I'd like to focus on framebusting, which is the simplest solution.
&lt;/p&gt;&lt;p&gt;Framebusting uses JavaScript to "bust" out of any top-level frame, usually:
&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;if (top != self) top.location.href = location.href;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Attempts to load a page that has this code into a frame will result in the framed page "busting" out of the frame and taking over the full browser window. It works – but there are some problems.
&lt;/p&gt;&lt;ol&gt;&lt;li&gt;It's opt-in. No one is protected by default.
&lt;/li&gt;&lt;li&gt;It doesn't work for pages that need to be in frames legitimately.
&lt;/li&gt;&lt;li&gt;JavaScript needs to be enabled.
&lt;/li&gt;&lt;li&gt;It may cause a performance hit.
&lt;/li&gt;&lt;li&gt;It can be defeated in Internet Explorer (6 and up) using the &lt;a href="http://msdn.microsoft.com/en-us/library/ms534622%28VS.85%29.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ms534622(VS.85).aspx"&gt;&lt;span style="font-family: Courier New;"&gt;security=restricted&lt;/span&gt;&lt;/a&gt; attribute.
&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;This last issue is troubling – the browser with the largest market share has a non-standard "feature" that looks like a security flaw. But the &lt;span style="font-family: Courier New;"&gt;security=restricted &lt;/span&gt;attribute was implemented for a valid security reason. According to &lt;a href="http://blogs.msdn.com/ie/default.aspx" mce_href="http://blogs.msdn.com/ie/default.aspx"&gt;the project manager for IE&lt;/a&gt;, it was meant to protect against malicious advertisements in frames which may attempt to forward the user to unintended sites through JavaScript. Whether or not the net security "profit" of the feature is positive or negative is subjective, but it certainly has pros and cons.
&lt;/p&gt;&lt;p&gt;As a side note, some researchers have found ways to &lt;a href="http://crypto.stanford.edu/framebust/" mce_href="http://crypto.stanford.edu/framebust/"&gt;bypass the &lt;span style="font-family: Courier New;"&gt;security=restricted&lt;/span&gt; attribute&lt;/a&gt;, but it requires control of the outer frame, which doesn't prevent clickjacking.
&lt;/p&gt;&lt;p&gt;One way to deal with the problem of clickjacking when your site is placed in a &lt;span style="font-family: Courier New;"&gt;security=restricted&lt;/span&gt; frame is to hide all content and then display it with JavaScript, along these lines:
&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;&amp;lt;head&amp;gt;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;&amp;lt;script type="text/javascript"&amp;gt;
&lt;/span&gt;&lt;/p&gt;&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New;"&gt;document.getElementById('all').style.display = 'block';
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;&amp;lt;/script&amp;gt;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;&amp;lt;/head&amp;gt;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;&amp;lt;body&amp;gt;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;&amp;lt;div id="all" style="display:none;"&amp;gt;
&lt;/span&gt;&lt;/p&gt;&lt;p style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New;"&gt;[Site content goes here]
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;&amp;lt;/div&amp;gt;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family: Courier New;"&gt;&amp;lt;/body&amp;gt;
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;This works because pages in frames that are set with a &lt;span style="font-family: Courier New;"&gt;security=restricted&lt;/span&gt; attribute are placed in a zone that doesn't execute script, by default, and the controls that the attacker would need to get you to click on are hidden. Many sites use a similar approach to give a friendly error message to people who don't use JavaScript.
&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Not a perfect solution, but it does make it more difficult for the attacker. Until we have a complete solution, it's what I'll recommend and include in the &lt;a href="http://www.owasp.org/index.php/.NET_ESAPI" mce_href="http://www.owasp.org/index.php/.NET_ESAPI"&gt;.NET ESAPI&lt;/a&gt;.
&lt;/p&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://keepitlocked.net/archive/2008/11/07/preventing-clickjacking-with-framebusting.aspx&amp;amp;;subject=Preventing+Clickjacking+with+Framebusting" target="_blank" title = "Post http://keepitlocked.net/archive/2008/11/07/preventing-clickjacking-with-framebusting.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://keepitlocked.net/archive/2008/11/07/preventing-clickjacking-with-framebusting.aspx&amp;amp;;title=Preventing+Clickjacking+with+Framebusting" target="_blank" title = "Post http://keepitlocked.net/archive/2008/11/07/preventing-clickjacking-with-framebusting.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://keepitlocked.net/archive/2008/11/07/preventing-clickjacking-with-framebusting.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://keepitlocked.net/archive/2008/11/07/preventing-clickjacking-with-framebusting.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://keepitlocked.net/archive/2008/11/07/preventing-clickjacking-with-framebusting.aspx&amp;amp;title=Preventing+Clickjacking+with+Framebusting" target="_blank" title = "Post http://keepitlocked.net/archive/2008/11/07/preventing-clickjacking-with-framebusting.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://keepitlocked.net/archive/2008/11/07/preventing-clickjacking-with-framebusting.aspx&amp;amp;;title=Preventing+Clickjacking+with+Framebusting" target="_blank" title = "Post http://keepitlocked.net/archive/2008/11/07/preventing-clickjacking-with-framebusting.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://keepitlocked.net/archive/2008/11/07/preventing-clickjacking-with-framebusting.aspx&amp;amp;;title=Preventing+Clickjacking+with+Framebusting&amp;amp;;top=1" target="_blank" title = "Post http://keepitlocked.net/archive/2008/11/07/preventing-clickjacking-with-framebusting.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://keepitlocked.net/aggbug.aspx?PostID=43" width="1" height="1"&gt;</description><category domain="http://keepitlocked.net/archive/tags/Software+Security/default.aspx">Software Security</category><category domain="http://keepitlocked.net/archive/tags/Clickjacking/default.aspx">Clickjacking</category><category domain="http://keepitlocked.net/archive/tags/Framebusting/default.aspx">Framebusting</category></item></channel></rss>