javascript - To stop ClickJacking, which one is more secure? breaking out of iframe vs X-Frame-Options to Deny or Same Origin -


to prevent clickjacking happenning website, have noticed several different methods. use javascript have website break out of iframe, other soltution set x-frame-options header deny or sameorigin. 1 of 2 method mentioned think more secure? here sample page using test clickjacking.

<html> <body> <h1>clickjacking test</h1> <iframe src="http://www.google.com/" height="500" width="500"></iframe> </body> </html> 

with iframe break code see firefox , safari slow out of iframe, meaning see clickjacking test , break out of iframe , show original website. ie , chrome fast not noticeable. x-frame-optiions solution not see website @ all. blocked. google in above example. questions 1 of solution better? blocking or breaking out of iframe(slow in 2 browsers)

in experience, setting x-frame-options (xfo) rules works better breaking out of iframes. when comes rules, depends on if absolutely have use iframes. if can remove iframes website completely, using deny rule best; however, if still have iframes in site, use sameorigin rules.

the differences between available rules outlined below (quoted ietf):

  1. deny browser receiving content header must not display content in frame.

  2. sameorigin browser receiving content header must not display content in frame page of different origin content itself. if browser or plugin can not reliably determine whether origin of content , frame have same origin, must treated "deny". [tbd]current implementations not display if origin of top-level-browsing-context different origin of page containing x-frame-options header.

  3. allow-from (followed uri of trusted origins) browser receiving content header must not display content in frame page of different origin listed origin. while can expose page risks trusted origin, in cases may necessary use content other domains. example: x-frame-options: allow-from https://www.domain.com/

i suggest reading, clickjack attack – hidden threat right in front of you troy hunt.

hope helps.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -