A short guide to clickjacking attacks

I recently read an article from JavaScript Weekly (part of the Cooper Press series I subscribe to), and it included a good rundown on clickjacking attacks:

https://auth0.com/blog/preventing-clickjacking-attacks/

It's a good article and worth reading.  Here's a summary.

What clickjacking attacks are

Malicious sites put hidden iframes over a decoy site.  When a user tries to click on something on the decoy site, he or she actually clicks on something in the hidden iframe.  The assumption is that the action taken by the hidden iframe is malicious.

How to prevent them

Front end

There are some workarounds, but these are mostly ineffective.

Back end

Note: if you're using Node.js and Express, the helmet library does 1 and 2 by default.

If both X-Frame-Options and Content-Security-Policy are set, the CSP setting prevails.
  1. Set the X-Frame-Options header to SAMEORIGIN (helmet's default) or DENY.  This is a widely-recognized standard, but it isn't an official standard. 
  2. Set the Content-Security-Policy frame-ancestors option to self or none.  This is an actual standard.
  3. If you use session cookies, set the sameSite attribute on the cookie to Strict.  The article says that this is a more recent standard and doesn't have universal support, but caniuse says that (as of 11/9/2020) there's 86% adoption.  Even recent versions of IE support it.  So unless you're writing an application for a very niche market you should be fine.

Comments

Popular posts from this blog

Optional object property access

A short guide to cross-site request forgery attacks

How is an application like a bride's outfit? - 1 minute read