X-Frame-Options is a simple HTTP header to define if a website is allowed to be loaded in a frame by browser or not. It provides protection against click jacking attacks where attacker loads the legitimate website either from a malicious website or by embedding HTML frame code in side another website.
This header is depreciated and replaced by content-security-policy. Although it was never standardized, but since this is still supported by majority of the browsers and still widely being used, it is too soon to forget about it. The new header content-security-policy is not yet that popular, however it is still being adopted as security best practice against click jacking attacks. We will be discussing about it in a later article.
X-Frame-Options takes following directives:
Deny: It specifies that the page cannot be loaded in frame.
Same origin: It Specifies, browser can load the page in frame if the request is originating from the same parent domain.
Allow-from <uri>: Same as above except it for other domains. Basically it allows browser to load the page if the request is from the allowed domains. Be careful with this as its a new feature the support of this can vary according to the browser capability.
- Per page definition is required, no option to define it for a domain or for multiple-domains
- Support for allow-from is dicey and depends on browser types
- Multiple options not supported
- Problems with nested frames
- Depreciated and not good for website use for future
- Be aware of proxy header stripping
Following the the reference links for this articals, be sure to visit them for further details about the header:
Dont miss out on an awesome OWASP cheat sheet on click jacking for more information on X-frame-options, content-security-policy and click jacking: