Search
Lori MacVittie - Two Different Socks
You are here: DevCentral > Weblogs

posted on Tuesday, June 23, 2009 3:27 AM

But browser support is only half the solution, don’t forget to implement the server-side, too.

Clickjacking, unlike more well-known (and understood) web application vulnerabilities, has been given scant amount of attention despite its risks and its usage. Earlier this year, for example, it was used as an attack on Twitter, but never really discussed as being a clickjacking attack. Maybe because aside from bandaid rewriting applications to prevent CSRF (adding nonces and validation of the same to every page) or adding framekillers there just haven’t been many other options to prevent the attack technique from being utilized against users. Too, it is one of the more convoluted attack methods out there so it would be silly to expect non-technical media to understand it let alone explain how it works to their readers.

There is, however, a solution on the horizon. IE8 has introduced an opt-in measure that allows developers – or whomever might be in charge of network-side scripting implementations – to prevent clickjacking on vulnerable pages using a custom HTTP header to prevent them from being “framed” inappropriately: X-FRAME-OPTIONS.

The behavior is described in the aforementioned article as:

If the X-FRAME-OPTIONS value contains the token DENY, IE8 will prevent the page from rendering if it will be contained within a frame. If the value contains the token SAMEORIGIN, IE will block rendering only if the origin of the top level-browsing-context is different than the origin of the content containing the X-FRAME-OPTIONS directive. For instance, if http://shop.example.com/confirm.asp contains a DENY directive, that page will not render in a subframe, no matter where the parent frame is located. In contrast, if the X-FRAME-OPTIONS directive contains the SAMEORIGIN token, the page may be framed by any page from the exact http://shop.example.com origin.

But that’s only IE8, right? Well, natively, yes. But a development version of NoScript has been released that supports the X-FRAME-OPTIONS header and will provide the same protections as are natively achieved in IE8.

The problem is that this is only half the equation: the X-FRAME-OPTIONS header needs to exist before the browser can act on it and the preventive measure for clickjacking completed. As noted in the Register, “some critics have contended the protection will be ineffective because it will require millions of websites to update their pages with proprietary code.”

That’s not entirely true as there is another option that will provide support for X-FRAME-OPTIONS without updating pages/applications/sites with proprietary code: network-side scripting. The “proprietary” nature of custom HTTP headers is also debatable, as support for Firefox was provided quickly via NoScript and if the technique is successful will likely be adopted by other browser creators.


HOW-TO ADD X-FRAME-OPTIONS TO YOUR APPLICATION – WITH or WITHOUT CODE CHANGES


Step 1: Add the custom HTTP header “X-FRAME-OPTIONS” with a value of “DENY” or “SAMEORIGIN” before returning a response to the client

Really, that’s it. The browser takes care of the rest for you. OWASP has a great article on how to implement a ClickjackFilter for JavaEE and there are sure to be many more blogs and articles popping up describing how one can implement such functionality in their language-of-choice. Even without such direct “how-to” articles and code samples, it is merely a matter of adding a new custom HTTP header – examples of which ought to be easy enough to find.

Similarly a solution can be implemented using network-side scripting that requires no modification to applications.

In fact, this can be accomplished via iRules in just one line of code:

when HTTP_RESPONSE { 
    HTTP::header insert "X-FRAME-OPTIONS" “(DENY || SAMEORIGIN)”
}

I believe the mod_rewrite network-side script would be as simple, but as I am not an expert in mod_rewrite I will hope someone who is will leave an appropriate example as a comment or write up a blog/article and leave a pointer to it.

A good reason to utilize the agility of network-side scripting solutions in this case is that it is not necessary to modify each application requiring protection, which takes time to implement, test, and deploy. An even better reason is that a single network-side script can protect all applications, regardless of language and deployment platform, without a lengthy development and deployment cycle.

Regardless of how you add the header, it would be a wise idea to add it as a standard part of your secure-code deployment requirements (you do have those, don’t you?) because it doesn’t hurt anything for the custom HTTP header to exist and visitors using X-FRAME-OPTIONS enabled browsers/solutions will be a lot safer than without it.

 

Follow me on Twitter View Lori's profile on SlideShare friendfeedicon_facebook AddThis Feed Button Bookmark and Share

 

Related blogs & articles:



Feedback

6/29/2009 3:15 AM
Gravatar Being first to do something doesn
Lori MacVittie
6/29/2009 6:27 AM
Gravatar I don't think mod_rewrite would be effective--you'd use mod_header. Syntax is about as easy as it is for the irule above:

Header always[|onsuccess] append X-Frame-Options DENY[|SAMEORIGIN]
Chris M.
6/29/2009 7:00 AM
Gravatar @Chris M

Really? My understanding was mod_rewrite could do L7 (implied headers/payload) as well. Hmmmph. Learn something new every day.

I will look more into mod_header - that solution is very simple/elegant. Nice.

Lori
Lori MacVittie
3/9/2010 12:13 AM
Gravatar Really? My understanding was mod_rewrite could do L7 (implied headers/payload) as well. Hmmmph. Learn something new every day.
university partnerships
3/20/2010 1:15 AM
Gravatar Thanks for sharing this information.
logo design
3/21/2010 5:17 AM
Gravatar The artice is very interesting. Especially I liked the choice of the photo. Super!
Rapidshare SE
4/14/2010 6:52 AM
Gravatar Thanks for the info, i was just looking for it!
Nick
4/21/2010 4:50 AM
Gravatar Clickjacking is a nightmare.Personally i spend days to find a solution, yours is better for mine i think :)
Verified torrents
4/23/2010 7:47 PM
Gravatar Great! The information stated here is very useful, thanks! Like to read more.
adjustable beds
5/14/2010 1:57 AM
Gravatar The artice is very interesting. Especially I liked the choice of the photo. Super!
Jeux
5/24/2010 11:44 PM
Gravatar Thanks for the info,The information stated here is very useful, thanks! Like to read more.
cool boy
5/31/2010 6:50 AM
Gravatar We have been using the x-frame options with firefox for a while already, works together quite well, no big problems notices so far
mediafire search engine
6/12/2010 2:26 AM
Gravatar I will look more into mod_header - that solution is very simple/elegant. Nice.
rapidshare
7/28/2010 12:21 AM
Gravatar Very informative thanks, keep walking.
Predators
8/6/2010 1:04 AM
Gravatar Don’t use “sameorigin” if you have any page on your domain which accepts an arbitrary URL to frame .
Comedy torrents
7/18/2010 6:46 AM
Gravatar I will definitely look into using mod_header...
electronic treadmill
7/22/2010 9:18 AM
Gravatar I like the fact you can use this in Firefox, thanks for letting us know.
Ben 10 Games
8/4/2010 12:33 AM
Gravatar The artice is very interesting, Thanks for sharing this information.
annonces moto
10/10/2010 11:49 PM
Gravatar Hi and thanks for this awesome article, I just noticed your weblog by error while googling for something else, I love your post and i look foreword for your next posts.
Lingen
10/11/2010 7:26 PM
Gravatar Hey,

Oh this is pretty interesting information. The usefulness and significance is overwhelming. Thanks:-)
Fredrickson International
10/15/2010 1:06 AM
Gravatar Where can i download it? I have been searching for this long before but after finding it i was even scared to use it
School Grants
10/18/2010 9:10 PM
Gravatar Oh it seems like pretty interesting! Thanks I'll check this out.
Link Financial
10/19/2010 1:32 AM
Gravatar We have been using the x-frame options with firefox for a while already, works together quite well, no big problems notices so far
Wordpress themes
11/4/2010 4:07 PM
Gravatar It is very rare these days to find blogs that provide information someone is looking for.
Keep up the good post.
Money Managers
12/11/2010 6:56 PM
Gravatar The browser takes care of the rest for you. OWASP has a great article on how to implement a ClickjackFilter for JavaEE and there are sure to be many more blogs and articles popping up describing how one can implement such functionality in their language-of-choice. Even without such direct “how-to” articles and code samples, it is merely a matter of adding a new custom HTTP header – examples of which ought to be easy enough to find.
Hidden Cameras
12/15/2010 11:58 PM
Gravatar Perfect way to give an example on Xframes using simple steps.
Web Design Atlanta
12/24/2010 1:20 PM
Gravatar Thanks for your post and the irules,very helpful my friend!
online forex trading
2/1/2011 9:38 AM
Gravatar Is this method available for IE7/8/9 too?

Thank you.
rapidshare search
2/1/2011 7:41 PM
Gravatar I'm with Chris above, mod_header is probably easier.
CNA Certification
3/20/2011 6:57 PM
Gravatar I wanted to thank you for this great read!! I definitely enjoyed every little bit of it.
I have you bookmarked to check out new stuff on your post.
whiplash
4/14/2011 3:41 AM
Gravatar The x frames potions header was introduced by microsoft and is interpreted as of Internet explorer eight.Thanks for sharing the informative post.
Regards.
david77
new top level domains
5/8/2011 1:10 AM
Gravatar I'm with Chris above
best ab machine
10/19/2011 10:14 PM
Gravatar Every time we visit websites, we saw almost the same as the other article and topic but I am shocked when I first read the title from this page.
wescot
10/27/2011 5:42 AM
Gravatar A good reason the mod_rewrite network-side script would be as simple, but I am not an expert in mod_rewrite. I will hope someone who will leave an appropriate example as a comment or write up a blog/article and leave a pointer to it.
Jackey Worden

Let Me Know What You Think


Please use the form below if you have any comments, questions, or suggestions.

Title:
 
Name:
 
Email: (so we can show your gravatar)
Website:
Comment: Allowed tags: blockquote, a, strong, em, p, u, strike, super, sub, code
 
Please add 8 and 8 and type the answer here:

Blog Stats

Posts:975
Comments:1681
Stories:0
Trackbacks:582
  

Image Galleries

  

Application Delivery

  

Cloud Computing

  

Random

  

Security

  

Chat Catcher

82,243 Members in 102 Countries and Growing!

Join DevCentral Today!

About DevCentral

DevCentral has been a successful, thriving community for many years. We have always strived to bring you the best technical documentation, discussion forums, blogs, media and much more that we can.

So dive in, get familiar with DevCentral. We hope you like it, we hope it makes your job easier, and lets you get that much more power out of the community. To learn more, make sure to check out the Getting Started section. And if you have any problems, or think something could be easier to use, drop us a line to let us know.

Got It !

We've received your comment and transmitted it directly to DevCentral HQ.

Thanks for taking time to let us know what's on your mind. At DevCentral | Community Matters!

Get In Touch With Us

Have questions, suggestions or just want to get something off your chest?

Use our handy form below to Direct Connect with DevCentral Mission Control.

Send Us Feedback       or