CSP Frame-Ancestors is the frame-ancestors directive of the Content-Security-Policy header, which lists the origins allowed to embed a page in a frame, iframe, object or embed element. Setting it to 'none' or 'self' blocks clickjacking by hostile sites. It must be sent as an HTTP header, as browsers ignore it in a meta tag.
How CSP frame-ancestors works
The frame-ancestors directive tells the browser which origins may embed a page in a frame, iframe, object, or embed. When set correctly, it limits who can present the content inside another site’s surface and prevents hostile framing from turning a trusted page into an attack target.
Unlike many other CSP directives, frame-ancestors is enforced at embedding time. That matters because the protected page is not just defending its own scripts, it is controlling whether its UI can be placed inside another document at all.
In practice, this makes the directive a framing policy, not a general content-loading policy. It is commonly paired with other browser controls, but its specific job is to decide which parent origins are allowed to wrap the page.
Why it blocks clickjacking
Clickjacking works by persuading a user to interact with a page they can see, while a different site controls the surrounding frame and visual context. A strict frame-ancestors policy closes that channel by refusing to render the page inside unauthorized frames, so the attacker cannot overlay controls, hide real destinations, or misdirect clicks.
This protection is especially important for pages that expose account actions, approvals, purchases, settings changes, or other state-changing functions. If those pages can be framed by an untrusted origin, the attacker may not need script execution at all, only the ability to manipulate what the user thinks they are clicking.
Because the control operates in the browser, it addresses a UI redressing problem rather than a server-side authorization problem. It reduces exposure created by embedding, but it does not replace session hardening, anti-CSRF controls, or robust authorization checks on the underlying action.
For broader context on how framing protections fit into a layered browser defense model, see the Security Headers Guide and the Clickjacking Guide.
How to deploy it correctly
frame-ancestors must be sent in the HTTP response header, because browsers ignore it when it appears in a meta tag. That implementation detail matters: if teams place it in the wrong location, they may believe framing is blocked when the browser is actually ignoring the policy.
The directive is usually set to 'none' when a page should never be framed, or to 'self' when only same-origin framing is acceptable. More selective allow-lists are possible for approved partner embeds, but they need to be deliberate and tightly reviewed because every additional origin expands the trusted framing surface.
Rollout should be tested against the exact pages that handle sensitive user actions, not just a homepage. A site can have a strong default posture and still leave one high-value path frameable through inheritance, inconsistent configuration, or a missed template.
Where framing is part of an approved integration, the policy should be treated as part of the embedding contract and reviewed alongside the surrounding security headers. The goal is to make framing explicit rather than accidental.
How it differs from related browser controls
frame-ancestors is often confused with X-Frame-Options, but they are not the same thing. X-Frame-Options is the older framing control, while frame-ancestors is the CSP mechanism that gives finer control and fits naturally into a modern header policy.
It also does not replace CORS. CORS governs whether browser JavaScript may read cross-origin responses, while frame-ancestors governs whether the browser may render the page inside a frame. Those are different trust decisions, and one does not imply the other.
That separation matters during incident review and hardening work. A site may have correct API access controls and still be vulnerable to hostile framing if the UI layer is not protected separately.
For a deeper comparison of these browser policy boundaries, the CSP vs CORS guide is a useful companion resource, and the W3C provides the underlying web platform standards context at W3C.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP ASVS, CIS Controls v8 and NIST SP 800-53 Rev 5 set the technical controls, while ISO/IEC 27001:2022 defines the regulatory obligations.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP ASVS | V3 — Web Frontend Security | frame-ancestors is a browser-side UI control for framed web pages |
| Recommendation — Verify framing restrictions and related browser controls for pages that must not be embedded. | ||
| CIS Controls v8 | CIS-9 — Email and Web Browser Protections | browser hardening includes protections against web-based UI redressing and unsafe browsing |
| Recommendation — Harden browser-facing controls and validate web defenses that reduce clickjacking exposure. | ||
| NIST SP 800-53 Rev 5 | SC-18 — Mobile Code | the header constrains browser-delivered content behavior in a user-facing context |
| Recommendation — Apply browser content restrictions where web-delivered behavior must be limited by policy. | ||
| ISO/IEC 27001:2022 | A.8.23 — Web filtering | web filtering and web access controls support reducing exposure to hostile web interaction paths |
| Recommendation — Implement web access protections that reduce exposure to hostile framing and web abuse. | ||
Related resources from NHI Mgmt Group
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on November 26, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org