The X-Frame-Options header controls whether a webpage can be embedded within <frame>, <iframe>, <embed>, or <object> elements, protecting against clickjacking attacks.
- Configuration Parameters
X-Frame-Options: <Policy>
– DENY → Prevents the page from being embedded in any context.
– SAMEORIGIN → Allows embedding only within the same origin.
– ALLOW-FROM origin → Permits embedding only from a specified origin (deprecated).
- Configuration Recommendations
1. Use DENY for sensitive pages that do not require embedding (e.g., login pages).
2. For basic protection, use SAMEORIGIN, but ensure proper mitigation of XSS attacks on same-origin sites.
3. ALLOW-FROM origin is deprecated—use the CSP frame-ancestors directive instead. For legacy browser support, both can be applied together.
- Configuration Examples
X-Frame-Options: DENY
X-Frame-Options: SAMEORIGIN