Which header stops clickjacking, X-Frame-Options or frame-ancestors?
If no other site should ever show your pages in a frame, send Content-Security-Policy: frame-ancestors 'none' and X-Frame-Options: DENY on every HTML response. If both are set, browsers that support frame-ancestors ignore X-Frame-Options. Both must be HTTP response headers, because a <meta> tag version does not work.
What is clickjacking and why does it matter?
In a clickjacking attack, an attacker tricks a user into interacting with your site in a way they didn't intend.
The attacker builds a decoy page that embeds your site in a hidden <iframe> and lines up its own buttons over the ones on your page that do something sensitive. If the user is already signed in to your site, the click on the hidden page carries their real credentials and the request succeeds.
Picture Atlas, our example app at atlas.example, with a button that deletes every note a signed-in user has saved. If another site can frame that page, it can hide the page and line up a decoy button over the delete button.
Clickjacking depends on your site being embedded in the attacker's page inside an <iframe>, so the main defense is to disallow or restrict that.
Don't read a missing frame header as proof that anyone has framed your site or tricked your users.
How do X-Frame-Options and frame-ancestors differ?
Both X-Frame-Options and the CSP directive frame-ancestors can stop a browser loading your page in a frame.
The frame-ancestors directive specifies valid parents that may embed a page using <frame>, <iframe>, <object> or <embed>. With it, you can control exactly which other documents are allowed to embed yours.
X-Frame-Options is less fine-grained, since it can only disable embedding entirely or allow it for same-origin documents. X-Frame-Options is still supported by the major browsers, but it has been obsoleted in favor of the frame-ancestors directive from the CSP Level 2 specification. Sending X-Frame-Options as well still prevents embedding in browsers that don't support frame-ancestors.
A few details are easy to get wrong.
- The
frame-ancestorsdirective does not fall back todefault-src, so a policy that declaresdefault-src 'none'still lets anyone embed the page. - It also differs from
frame-src, which sets where iframes inside your page may load from. - The single quotes are required around
selfandnone, and may not occur around other source expressions.
Which header should I send?
| Your situation | What to send | Why |
|---|---|---|
| No site, including your own, should ever frame the page | frame-ancestors 'none' and X-Frame-Options: DENY | Setting frame-ancestors to 'none' is similar to X-Frame-Options: deny. |
| Only pages on your own site frame the page | frame-ancestors 'self' and X-Frame-Options: SAMEORIGIN | X-Frame-Options can allow embedding only for same-origin documents. |
| Your own site and one partner site both need to frame the page | frame-ancestors 'self' followed by the partner's full https:// origin | X-Frame-Options has no way to allow the current site and a third-party site to frame the same response. |
You planned to use X-Frame-Options: ALLOW-FROM | frame-ancestors with the allowed origin instead | The ALLOW-FROM option is obsolete and no longer works in modern browsers. |
Your host only lets you add a <meta> tag | Both settings moved to HTTP response headers | Meta tags that try to apply X-Frame-Options or frame-ancestors do not work. |
| Your app shows pages inside nested frames | frame-ancestors on the inner page that lists every ancestor | The frame-ancestors directive checks each ancestor, and if any ancestor doesn't match, the load is canceled. |
How do I check?
Fetch the response headers for a page on your site and look for a Content-Security-Policy header that contains frame-ancestors, and for an X-Frame-Options header. For Atlas, this command prints the headers of the homepage.
curl -sI https://atlas.exampleOn a page that no other site should frame, you want to see these two lines among the headers.
Content-Security-Policy: frame-ancestors 'none'
X-Frame-Options: DENYRun the same command against a signed-in page and any page with a button that changes data. Set the X-Frame-Options header on every response that contains HTML, not only the homepage.
If a web proxy strips the X-Frame-Options header, the site loses its framing protection. Check the headers that reach the browser, not only your config file.
Lockpick checks your site from the outside, reading only what it already shows the public. Security headers are part of what a scan reads. A Pulse scan sends at most 12 requests to your site. Anything a scan couldn't check is marked as not checked, never as passed. Read more on the framing protection check page.
How do I fix it?
- Pick your row in the table above. Use
'none'unless your own pages or a partner need to frame the page. - Add
frame-ancestorsto yourContent-Security-Policyresponse header. If you already send a policy, add the directive to it. Content Security Policy for Next.js apps walks through a full policy. - Add the matching
X-Frame-Optionsheader,DENYfor'none'orSAMEORIGINfor'self'. - Send both on every HTML response, as headers and never as
<meta>tags. - Set your session cookies to
SameSite=LaxorSameSite=Strict. - Deploy, then check again.
These defenses are independent of each other, and where possible you should use more than one for defense in depth.
Here is a vercel.json headers block for Atlas that sets both headers on every path.
{
"headers": [
{
"source": "/(.*)",
"headers": [
{ "key": "Content-Security-Policy", "value": "frame-ancestors 'none'" },
{ "key": "X-Frame-Options", "value": "DENY" }
]
}
]
}As an additional partial mitigation, set the SameSite attribute on session cookies to Lax or Strict. Requests from a cross-site <iframe> then leave those cookies out, so your server won't treat the request as coming from a signed-in user. See Your sign-in cookie is missing Secure, HttpOnly or SameSite for that fix.
Fix it with your AI
Add the HTTP response headers `Content-Security-Policy: frame-ancestors 'none'` and `X-Frame-Options: DENY` to every HTML page this app serves. Set them in the hosting or server configuration, never in a `<meta>` tag. If the app already sends a Content-Security-Policy, add `frame-ancestors 'none'` to that policy instead of creating a second one. Before changing anything, tell me whether any page is meant to be shown inside an iframe on another site, and if so, ask me which origins to allow. After deploying, show me the response headers for the homepage and for one signed-in page.Find where this project sets HTTP response headers for its deployed pages. Add `Content-Security-Policy: frame-ancestors 'none'` and `X-Frame-Options: DENY` to every HTML response. Do not use `<meta>` tags for either one. If a Content-Security-Policy already exists, add the `frame-ancestors 'none'` directive to it and keep the rest unchanged. If any page of this app needs to be embedded by another site, stop and ask me for the allowed origins first. Then show me the response headers from the deployed homepage.In this codebase, add framing protection to every HTML response. Send `Content-Security-Policy: frame-ancestors 'none'` and `X-Frame-Options: DENY` as HTTP response headers from the hosting config or server middleware, not from `<meta>` tags. Merge `frame-ancestors 'none'` into any existing Content-Security-Policy rather than adding a second header. Search the code for any iframe that embeds our own pages; if you find one, use `frame-ancestors 'self'` and `X-Frame-Options: SAMEORIGIN` instead and tell me. Also make sure session cookies are set with `SameSite=Lax` or `SameSite=Strict`. Finish by listing the files you changed.See Fix security issues with your AI builder for how to use these prompts.
What a check cannot tell you
Frame headers address frame-based clickjacking, and DoubleClickjacking, which uses separate windows, needs additional safeguards for sensitive actions. In DoubleClickjacking the target page is a top-level window, so X-Frame-Options and CSP frame-ancestors do not prevent it.
Lockpick never signs in to your site and never looks at anything behind a login. Check the headers on your signed-in pages yourself with the command above.
A Lockpick report is not a certificate and not a full penetration test. It covers what that scan could see on that day.
Questions people ask
Should I use X-Frame-Options or frame-ancestors?
Use both. If frame-ancestors and X-Frame-Options are both set, browsers that support frame-ancestors ignore X-Frame-Options. Sending X-Frame-Options as well still prevents embedding in browsers that don't support frame-ancestors.
Can I set X-Frame-Options or frame-ancestors in a meta tag?
No. Both must be configured as HTTP response headers, and a meta tag version will not work.
Does default-src 'none' in my CSP stop other sites framing my page?
No. The frame-ancestors directive does not fall back to default-src, so a policy that declares default-src 'none' still allows the page to be embedded by anyone. Add frame-ancestors to the policy yourself.
Is X-Frame-Options ALLOW-FROM still safe to use?
No. The ALLOW-FROM option is obsolete and no longer works in modern browsers. If you rely on it and the browser does not support it, you have no clickjacking defense in place. List the allowed origins in frame-ancestors instead.
Does a missing X-Frame-Options header mean my site was attacked?
No. Don't read a missing header as proof that anyone framed your site or tricked your users. Add the headers, deploy, then check again.
See what your site shows from outside
A quick check reads your homepage the way a visitor would and gives you a score. No account needed.
Check your siteSources
- Clickjacking - Security | MDN MDN Web Docs, read on October 22, 2026
- Clickjacking Defense - OWASP Cheat Sheet Series OWASP Cheat Sheet Series, read on October 22, 2026
- Content-Security-Policy: frame-ancestors directive - HTTP | MDN MDN Web Docs, read on October 22, 2026
- How we check · Docs · Lockpick Lockpick docs, read on November 4, 2026
- What we never do · Docs · Lockpick Lockpick docs, read on October 29, 2026