frame-ancestors CSP Directive (frame-ancestors)
Why frame-ancestors Matters
frame-ancestors is the modern, more flexible replacement for X-Frame-Options. While X-Frame-Options only supports DENY, SAMEORIGIN, and the deprecated ALLOW-FROM, frame-ancestors can specify multiple allowed origins with full URL pattern matching.
This directive is critical for preventing clickjacking attacks, where an attacker embeds your site in a transparent iframe and tricks users into clicking buttons on your site while thinking they are interacting with the visible page. Banks, social media sites, and any page with sensitive actions should use frame-ancestors 'none' or 'self'.
Unlike most CSP directives, frame-ancestors in an enforcing CSP takes precedence over X-Frame-Options. However, for backward compatibility with browsers that do not support CSP (mainly IE11), setting both frame-ancestors and X-Frame-Options is recommended.
Checking Your Setup
DomainOptic checks X-Frame-Options and basic CSP presence. Review frame-ancestors directly and test framing from allowed and disallowed origins because the scanner does not fully parse or exercise that directive.