DEV Community

Masahiro Kurokawa
Masahiro Kurokawa

Posted on Originally published at ismyappok.com

Clickjacking protection: when another site embeds your pages

You have heard the word "clickjacking" and have no idea what to do about it. It shows up in scan results, but it is hard to connect to anything you recognize.

The short answer is one line: stop other sites from embedding your pages. Send Content-Security-Policy: frame-ancestors 'none' and the whole family of framing attacks stops working.

What clickjacking is

Picture a restaurant menu with a clear sheet laid over it. Your finger points at one dish, but a different dish is what gets ordered. That is clickjacking.

Clickjacking is an attack that shows your page inside the attacker's page using an iframe (a part that embeds one page inside another) and lays a transparent button or text on top. The visitor believes they are looking at your site, but the button they press belongs to the attacker.

Nothing about your site looks different. What changes is where the click lands.

Why it concerns you

The target is a visitor who is still signed in. They are made to press a button on your site against their intent.

  • confirming a payment or an order
  • deleting an account, switching a page between public and private
  • changing permissions or an email address
  • following, liking, posting

For example, the attacker's page says "You have won" in large letters. Your site's "Delete" button is laid over it, invisibly. The visitor thinks they pressed the prize button and presses Delete instead.

The more your site has forms, logins, or payments, the more this matters. Even a static profile page can be embedded somewhere else and shown out of context.

One line that refuses embedding

The answer is to refuse embedding in a response header. There are two ways to say it, and either one works.

  • Content-Security-Policy: frame-ancestors 'none'
  • X-Frame-Options: DENY

frame-ancestors is the current form, and X-Frame-Options is for old browsers. Sending both is fine. Modern browsers give frame-ancestors priority.

X-Frame-Options has an ALLOW-FROM form, but almost no current browser supports it, and it cannot list more than one origin. If you need to allow a partner, use frame-ancestors.

frame-ancestors does not work in an HTML meta tag. It has to come back as a header.

When you do want to allow embedding

Sometimes a payment or booking widget needs to be embedded on a partner's site. In that case, allow only that origin (the combination of scheme, host, and port).

Content-Security-Policy: frame-ancestors https://partner.example

'self' means "only this site". Add 'self' only if your own pages embed each other. 'none' means "no one may embed this", including yourself.

How it looks in vuln

vuln (a free check that runs on a public URL) shows clickjacking as one row, V04.

  • V04 Clickjacking (area: Headers, priority 3)

V04 looks at the response headers of the top page.

  • X-Frame-Options is present: pass
  • the CSP header has frame-ancestors: pass
  • neither is present: needs work

It only checks presence. It does not tell DENY from SAMEORIGIN, or look at which origins you allow. If you want to judge the strength of the value, read the headers yourself.

A CSP in a meta tag is not used for this check, because frame-ancestors does not work in meta. Even if it is written in the HTML, V04 treats it as absent.

The Evidence and fix column keeps what was observed as key=value lines. With neither header you see request=GET …, header=x-frame-options, and note=absent; csp frame-ancestors absent.

A measurement from our own site

On 22 November 2026 we checked this site's response headers with curl -sSI https://ismyappok.com.

The CSP header contains frame-ancestors 'none'. There is no x-frame-options line. V04 passes because of the CSP setting; we do not send X-Frame-Options.

Here is the main part of the CSP header (the nonce value, some sources, and some directives are omitted).

default-src 'self'; base-uri 'self'; object-src 'none'; frame-ancestors 'none'; …; upgrade-insecure-requests

frame-ancestors sits in the same header as the other CSP directives. You add one word inside CSP rather than adding another header.

How to fix it

Where you return the header depends on your hosting or framework. The official steps are here.

On Netlify and Cloudflare Pages, you put a _headers file in the publish directory and list a path such as /* with the headers. On Vercel, you write them under headers in vercel.json. Next.js returns them from headers() in next.config. If you want to add the header at Cloudflare's proxy instead, you can do it with a Transform Rule ("Modify response header").

If you already send a CSP, do not add a new header; add frame-ancestors 'none' inside the existing policy. Deciding on one place to set it saves confusion later.

If you already followed Security headers, explained, this is one more line in the same place. CSP basics covers the bigger picture of the policy.

How it looks in the result screen

"3. Result" in vuln shows a pass-rate summary and the checklist. The table has six columns: ID, Item, Priority, Result, Area, and Evidence and fix.

V04 appears in the Headers area. If nothing blocks embedding, the result is "Needs work". The "Needs work only" filter keeps the row, and its priority of 3 puts it near the top.

What clickjacking protection does not prevent

vuln is not a penetration test. It checks the public face of a site from the outside.

Refusing embedding does not stop attacks that avoid frames: sending people to a fake site, or showing a look-alike screen in another tab. It does not look at scripts injected into the page (XSS) or holes on the server side either.

Finding nothing does not mean the site is safe.

Wrapping up

Clickjacking protection is one line, and it buys a lot, in my view. Even a site with no login or payment would rather not be embedded and shown out of context.

Start with V04 in vuln. If it says "Needs work", add frame-ancestors 'none' to the CSP and go from there.

The fixes are collected on these pages.

When you have changed the settings, run vuln again. You can check display and links before launch with audit (no login) as well.

This article is based on checking our own site's settings. We did not scan anyone else's site for it. The numbers are recommended values and implementation thresholds; the only measurements are the ones with the date and method given in the text.

Top comments (7)

Collapse
 
dosaygo profile image
dosaygo •

When your scanner verifies frame-ancestors and framing behavior across untrusted customer or third-party URLs, do you run those live browser checks inside a disposable remote browser container isolated from your host network and credentials?

Collapse
 
masahirokurokawa profile image
Masahiro Kurokawa •

No browser at all. The check is header-level and HTTP-only: we fetch the URL, no JS execution, no rendering, at 1 req/s with a 15s budget, request/byte caps, and no redirect following. So there is nothing to isolate — a customer page is never loaded in a browser.

Verifying actual framing behaviour ("does the browser really refuse to render this?") would need a disposable browser, and that's the layer I deliberately don't own. I'd rather keep the scanner honest about what it can and cannot see.

And one thing I'm taking from your question: I've been sloppy in how I describe this check. It reads as if we verify framing behaviour, when we only read response headers. I'll make the report and the article say plainly what is and isn't checked — "it passed" should never imply "it renders safely".

(The fetches themselves are still untrusted input, so every A/AAAA is resolved and private ranges are refused, and redirects aren't followed. But that's a different problem from the isolation you're describing.)

Collapse
 
dosaygo profile image
dosaygo •

Thanks for the detail on keeping the check HTTP-only with A/AAAA private-range blocks and making the report explicit that response headers alone don't verify live framing behavior. I'm building BrowserBox to run disposable remote browser containers isolated from your host network and credentials when you want to verify actual browser framing behavior alongside the HTTP header scan: browserbox.io/go/forum-20261128-de...

Collapse
 
parimalmakes profile image
Parimal Makes •

The reminder that frame-ancestors is ignored inside an HTML meta tag trips up a lot of static site setups. For Next.js or Cloudflare Pages where you set it via next.config headers() or _headers, do you usually drop X-Frame-Options completely or keep SAMEORIGIN around for older clients?

Collapse
 
masahirokurokawa profile image
Masahiro Kurokawa •

I'm not sure there's one right answer here — this is just how I think about it.

Current browsers ignore X-Frame-Options when frame-ancestors is present (per CSP3),so XFO only matters for IE11 and other old browsers. On ismyappok.com I currently send only frame-ancestors 'none', mostly because that traffic is close to zero for us.

That said, OWASP still recommends sending both as defense in depth, and it costs one line. If I add it, I keep the values aligned: 'none' with DENY, 'self' with SAMEORIGIN. Otherwise old and new browsers end up enforcing different rules, with no error to tell you, and nobody tests on IE11 to catch it. I'd also put both on the same rule in next.config headers() or _headers so they don't drift apart per route, and skip ALLOW-FROM - browsers that don't understand it end up with no protection.

So my lean: drop it if you know your audience, keep a matching DENY/SAMEORIGIN if you can't rule out old clients.

Collapse
 
userxnom profile image
Abdullah Naseer •

The most useful sentence in here is the honest one: V04 only checks presence, not strength. A site can pass the check with X-Frame-Options: SAMEORIGIN or a loose frame-ancestors list and still be framable by exactly the origins it trusts — and if any of those origins is ever compromised, the header does not save you. That distinction is what turns a green check into real protection.

Two things I would love your take on: V04 reads the response headers of the top page, but what about the paths that actually matter for a signed-in visitor — a login page, an OAuth callback, or an error page served by different middleware that quietly returns weaker headers? And for a site with no login at all, like a directory of free tools, is frame-ancestors 'none' still the right default, or is there a legitimate embed case (say a tool preview) where 'self' earns its keep?

Collapse
 
masahirokurokawa profile image
Masahiro Kurokawa •

Thanks — and yes, that's exactly the right reading: the headers can differ per route, so the login page, the OAuth callback, and error pages deserve their own check, not just the top page. Good advice, and I'll take it back to the scanner.

For vuln, I'm thinking about a bounded version rather than a crawl: let the user name a couple of extra paths on the same host, and check only the response headers there (no JS, no rendering, same 1 req/s and time budget). That keeps it honest about what it covers instead of implying "all routes are fine".