This site is the archived OWASP Foundation Wiki and is no longer accepting Account Requests.
To view the new OWASP Foundation website, please visit https://owasp.org

Difference between revisions of "Clickjacking"

From OWASP
Jump to: navigation, search
m (typo)
m (fixing references to be more "standard" (look & feel is less awkward) - also removed broken grc link)
Line 37: Line 37:
  
 
== References ==
 
== References ==
 +
* [http://www.sectheory.com/clickjacking.htm Clickjacking, Sec Theory]
 +
: A paper by Robert Hansen defining the term, its implications against Flash at the time of writing, and a disclosure timeline.
  
The original post by Robert Hansen defining this term and introducing the problem is here: http://ha.ckers.org/blog/20081007/clickjacking-details/
+
* [[ClickjackFilter_for_Java_EE|Anti-clickjacking J2EE filter]]
 
+
: A simple J2EE servlet filter that sends anti-framing headers to the browser.
Robert Hansen's more detailed post after he was 'allowed' to start talking about it: http://www.sectheory.com/clickjacking.htm
 
 
 
A list of other Clickjacking links: http://www.grc.com/sn/notes-168.htm
 
 
 
OWASP [[ClickjackFilter for Java EE]]
 

Revision as of 19:24, 29 March 2010

Clickjacking, also known as a "UI redress attack", is when an attacker uses multiple transparent or opaque layers to trick a user into clicking on a button or link on another page when they were intending to click on the the top level page. Thus, the attacker is "hijacking" clicks meant for their page and routing them to other another page, most likely owned by another application, domain, or both.

Using a similar technique, keystrokes can also be hijacked. With a carefully crafted combination of stylesheets, iframes, and text boxes, a user can be led to believe they are typing in the password to their email or bank account, but are instead typing into an invisible frame controlled by the attacker.

Examples

For example, imagine an attacker who builds a web site that has a button on it that says "click here for a free iPod". However, on top of that web page, the attacker has loaded an iframe with your mail account, and lined up exactly the "delete all messages" button directly on top of the "free iPod" button. The victim tries to click on the "free iPod" button but instead actually clicked on the invisible "delete all messages" button. In essence, the attacker has "hijacked" the user's click, hence the name "Clickjacking".

One of the most notorious examples of Clickjacking was an attack against the Adobe Flash plugin settings page. By loading this page into an invisible iframe, an attacker could trick a user into altering the security settings of Flash, giving permission for any Flash animation to utilize the computer's microphone and camera.

Clickjacking also made the news in the form of a Twitter worm. This clickjacking attack convinced users to click on a button which caused them to re-tweet the location of the malicious page, and propagated massively.

Defending against Clickjacking

There are two main ways to prevent clickjacking: employing defensive code in the UI to ensure that the current frame is the most top level window, and by sending the browser response headers that indicate an unwillingness to be framed.

Defending with frame breaking scripts

The most popular way to defend against clickjacking is to include a "frame-breaker" script in each page that should not be framed.

<script>if (top!=self) top.location.href=self.location.href</script>
* NOTE: this framebreaker is pretty simple. A better framebreaker will hide the entire page
and only redisplay if page is not being framed. An even better framebreaker than that will
not cause any change in the page-load experience. More to come soon!

This code ensures the page cannot be embedded into an iframe, and therefore cannot be used as part of a clickjacking attack.

Defending with X-FRAME-OPTIONS header

Recently, Microsoft introduced a non-standard header that may be simpler to implement in some applications. However, there's an alternative approach that may be simpler to implement. Microsoft has now included a defense in IE8 that allows developers to specify that pages should not be framed. They use a new (nonstandard) X-FRAME-OPTIONS header to mark responses that shouldn't be framed. There are two options with X-FRAME-OPTIONS. The first is DENY, which prevents everyone from framing the content. The other option is SAMEORIGIN, which only allows the current site to frame the content. Currently this works in IE8 RC1+, but will not affect users of other browsers until they decide to implement this feature. Firefox users may want to look at the protection in NoScript.

To implement this protection, you need to add the header to any page that you want to protect from being clickjacked. One way to do this is to add the header manually to every page. A possibly simpler way is to implement a filter that automatically adds the header to every page.

OWASP has an article and some code that provides all the details for implementing this in the Java EE environment.

The SDL blog has posted an article covering how to implement this in a .NET environment.

References

A paper by Robert Hansen defining the term, its implications against Flash at the time of writing, and a disclosure timeline.
A simple J2EE servlet filter that sends anti-framing headers to the browser.