X-Frame-Options (X-Frame-Options)
Configuration Reference
| Value | Effect |
|---|---|
| DENY | Page cannot be displayed in any frame |
| SAMEORIGIN | Page can only be framed by pages on the same origin |
| ALLOW-FROM uri | Deprecated - use CSP frame-ancestors instead |
Why X-Frame-Options Is Important
Clickjacking attacks overlay a transparent iframe of your site on top of a malicious page. When users think they are clicking buttons on the visible page, they are actually clicking elements on your hidden site - potentially transferring money, changing account settings, or granting permissions.
X-Frame-Options is a simple, widely supported defense against this. Setting X-Frame-Options: DENY means your pages can never be embedded in frames on any site. SAMEORIGIN allows your own site to frame its own pages but blocks external sites.
While CSP's frame-ancestors directive is the modern replacement (and more flexible), X-Frame-Options should still be set for compatibility with older browsers that do not support CSP. Setting both provides defense in depth.
Checking Your Setup
A security audit checks for the X-Frame-Options header. Verify it is set to DENY or SAMEORIGIN. If your site needs to be embedded in specific third-party frames, use CSP frame-ancestors with the specific allowed origins instead.