Skip to main content
Security guideReviewed

Clickjacking: what it is, and the two headers that decide who may frame your pages

Clickjacking shows one of your pages inside a frame on another site, so that a click the visitor meant for that site lands on your page instead.

This guide explains what a frame is, why the visitor's own session is what makes it work, how the Content-Security-Policy frame-ancestors directive and the older X-Frame-Options header differ, which one a browser follows when both are sent, and how to let one partner embed a page while refusing everyone else. It comes with a local harness and a browser evidence table you fill in yourself.

Framing harness, header check and browser evidence table

An illustration, not a client system: an invented account page served by a local Node.js harness under fourteen framing policies, with an embedding site that tries to frame each one. Part 1 is the six harness files.

How to use it

Part 2 is the header check, which applies the HTML Standard's and Content Security Policy Level 3's written rules to the headers each case sends; it is not a browser. Part 3 is the browser evidence table, with blanks for what your own browser shows, and a before-and-after pair. Part 4 is a regression test, shown passing and then failing when one case loses its header. For learning and for testing sites you own.

clickjacking.txt

Introduction32 lines

ILLUSTRATION ONLY. The account page, its owner Sam Example and its one setting are invented for this page. The harness runs on your own machine, binds to 127.0.0.1, keeps everything in memory and frames only its own pages. Use it to learn, and to test sites you own or are authorised in writing to test. What this asset is, and what it is not: Part 1 The harness: six files that run with Node.js alone. Part 2 The header check. It requests every case, prints the framing headers each response carried, and applies the written rules in framing-rules.mjs to say what a browser that follows them is expected to do. It reads headers and applies rules. It is not a browser, and nothing it prints shows what any browser does. Part 3 The browser evidence table, printed by serve.mjs, with blanks for what your own browser shows. Your browser is the evidence in that part. Part 4 The regression test: passing, then failing when one case loses its header. Part 5 Pointing it at your own site. Written and run on: Node.js 26.0.0, the only version it was run on. The harness imports only node:http, node:readline, node:test and node:assert, and installs no packages. Every output below was copied from that run by a script. Ports and timings will differ on your machine. Stack trace lines that held local paths were cut, and each cut is marked. The written rules, and where each comes from: HTML 7.7 WHATWG HTML Standard (Living Standard, last updated 13 November 2026), 7.7 The X-Frame-Options header: its values, its processing model, and when it is ignored. CSP3 6.4.2 W3C Content Security Policy Level 3, Working Draft of 27 October 2026 (a work in progress): 6.4.2 frame-ancestors and 6.4.2.1, its navigation response check. CSP3 6.7.2 The same draft, 6.7.2 URL Matching: 'none', 'self', schemes, hosts and ports. CSP3 2.2.1, 2.2.2 The same draft: how a header value is split into policies and directives. RFC 7034 section 4 RFC 7034, HTTP Header Field X-Frame-Options (Informational, October 2013): X-Frame-Options declared in a meta tag is ignored. The origins: Application http://127.0.0.1 on one port. It serves the account page for every case at /case/ID/account, and a page of its own that frames it at /case/ID/frame. Embedding site, as partner http://localhost on a second port. The partner cases name this origin. Embedding site, not named http://127.0.0.1 on that same second port. It is a different origin from the line above because the host differs (MDN Origin glossary), and no case names it. Why localhost: Level 3's host matching (6.7.2.10) returns no match for a host that is not a domain, while a note elsewhere in the same draft says 127.0.0.1 is the one address that will match. Naming the partner by host name keeps the expected results clear of that question. The four embeds checked for every case: E1 the partner page frames the account page /case/ID on the partner origin E2 the unnamed page frames the account page /case/ID on the unnamed origin E3 the application frames its own account page /case/ID/frame on the application E4 the partner page frames an application page that frames it /nested/ID on the partner origin The application's own framing page sends no framing headers on purpose, so that E4 can test a nested frame. The fourteen cases are listed in Part 2 with the headers each one sends. Case ids that start with xfo- are X-Frame-Options cases, and ids that start with csp- use Content-Security-Policy.

What clickjacking is

A frame is a web page shown inside another web page.

MDN describes the iframe element as a nested browsing context that embeds another document into the current one, and MDN's page on the same-origin policy says that embedding across origins is typically allowed. So unless your server says otherwise, another website can put one of your pages inside a frame on its own page.

MDN's X-Frame-Options reference states the default plainly: if that header is not sent and the site has no other mechanism to restrict embedding, such as the frame-ancestors directive, the browser will allow other sites to embed the document.

Clickjacking turns that default against the framed site. OWASP's Web Security Testing Guide, in test WSTG-CLNT-09, describes it as a technique that deceives a user into interacting, in most cases by clicking, with something other than what the user believes they are interacting with.

MDN's outline is the same: an attacker builds a decoy site that embeds the target site in an iframe, and the visitor ends up interacting with the target site in a way they did not intend.

The page in the frame is your real page, served by your server, so a click on its button is a real click on your button.

The weakness goes by several names. MITRE catalogues it as CWE-1021, Improper Restriction of Rendered UI Layers or Frames, with the alternate terms clickjacking, UI redress attack and tapjacking, and describes it as a web application that does not restrict, or incorrectly restricts, frame objects or UI layers that belong to another application or domain.

The W3C Content Security Policy specification calls the family UI redressing attacks. CWE-1021 says the impact varies widely with what the application does, and its example is a social media application where clickjacking could trick the user into changing privacy settings.

This page describes the attack at the level a defender needs: a page shown inside a frame on another site, so that a click meant for one thing lands on another. It does not show how a decoy page is laid out, and the harness on this page frames only its own pages, on your own machine.

Why the visitor's own session is what makes it work

The click happens in the visitor's own browser, on your real page, so it carries whatever that browser normally sends to your site.

MDN's clickjacking page makes the point with a bank: if the user is already signed in, the request the click makes includes the user's real credentials, and the request succeeds. WSTG-CLNT-09 says a common prerequisite is that the victim is authenticated against the target website, and RFC 7034, which documented X-Frame-Options in 2013, calls clickjacking an attack on both the user and the framed server, one that can potentially use an existing session context.

That is also why some forged-request defences do not help. WSTG-CLNT-09 explains that the actions are originated from the hidden but authentic target page, so some of the anti-CSRF protections developers deploy could be bypassed, and that the attack is often designed to induce actions even where anti-CSRF tokens are in use.

Cross-site request forgery has its own guide in this library; framing is a different route to a similar result.

Cookie settings can narrow the damage. OWASP's Clickjacking Defense Cheat Sheet says cookies marked SameSite=Strict or SameSite=Lax are withheld from cross-site iframe requests, which can prevent clickjacking that depends on those cookies for authentication, and MDN's Set-Cookie reference lists navigations inside an iframe among the cross-site requests that Lax leaves the cookie off.

ASVS 5.0 requirement 3.3.2, at Level 2, asks that each cookie's SameSite value is set according to the purpose of the cookie, to limit exposure to user interface redress attacks and cross-site request forgery. The cookie security guide covers those attributes as a whole.

SameSite is not a framing control, and OWASP spells out its limits. It does not block framing, and it does not withhold cookies from same-site requests, so an attacker-controlled sibling subdomain with the same scheme can be same-site while remaining a different origin. It gives no protection when the attack does not need the visitor to be signed in, and the cheat sheet says it should not be relied on as the sole protective measure.

MDN calls it an additional partial mitigation. What decides whether your page appears in someone else's frame at all is a response header.

Which pages matter, and why the default should be no framing

The pages that matter most are the ones where one click, or a few keystrokes, change something for a signed-in visitor: account and security settings, a payment or order confirmation, a button that grants another app access, deleting a record, changing who can see something, or an admin action.

In its section on DoubleClickjacking, OWASP's cheat sheet gives consent screens, payment confirmations and account security settings as examples of pages your application controls where high-risk actions need extra steps. Sign-in pages belong on the list too, because visitors type into them.

That list is useful when you test. It is a poor way to decide which pages get the header, and the sources set the default the other way round. OWASP recommends frame-ancestors 'none', and X-Frame-Options DENY, unless a specific need for framing has been identified, and says to set X-Frame-Options on all responses containing HTML content.

ASVS 5.0 requirement 3.4.6, at Level 2, asks that the frame-ancestors directive is used on every HTTP response, so that the application cannot be embedded by default and embedding of specific resources is allowed only when necessary. Start from no framing anywhere, then list the few pages a partner genuinely needs to embed.

The two headers that decide whether a page may be framed

A browser decides whether to show a page in a frame from the headers on that page's own response, not from anything on the framing site.

Two headers do the job: the frame-ancestors directive in a Content-Security-Policy header, and the older X-Frame-Options header. Both work only as HTTP response headers. The Content Security Policy Level 3 specification says frame-ancestors MUST be ignored when contained in a policy declared via a meta element, and RFC 7034 says X-Frame-Options is explicitly ignored when declared with a meta http-equiv tag. Case C14 in the harness puts both in meta elements and nothing in the headers.

Content-Security-Policy: frame-ancestors

Content Security Policy Level 3 is a W3C Working Draft. 1 min read

X-Frame-Options

X-Frame-Options came first. 1 min read

What each value means

X-Frame-Options: DENY. 1 min read

Why X-Frame-Options cannot name a list of partner sites

RFC 7034 says its three values are mutually exclusive and the header must be set to exactly one of them, and that wildcards or lists of domains in one ALLOW-FROM statement are not permitted.

Its design pattern for a site with several partners was to have the framing page pass its origin in a query string, have the server verify that it meets its criteria, for example by looking it up in a list of trusted domain names, and send back that one origin in ALLOW-FROM if the criteria were met. The same RFC recorded that not all browsers supported ALLOW-FROM.

That design pattern no longer helps, because ALLOW-FROM itself is gone. The HTML Standard says the variant is not to be implemented and treats a lone value it does not recognise as if the header were omitted; its own table gives ALLOW-FROM the result "embedding allowed (from anywhere)".

OWASP warns that if you apply ALLOW-FROM and the browser does not support it, you will have no clickjacking defence in place, and adds that X-Frame-Options gives no way to allow both your own site and a third-party site to frame the same response.

Case C4 in the harness sends ALLOW-FROM naming the partner, and the written rules expect every embed to be displayed, the unnamed origin included.

frame-ancestors was built for this job. OWASP notes that it lets a site authorise multiple domains using the normal Content Security Policy semantics, and MDN's examples list more than one origin in a single directive.

Why frame-ancestors checks every ancestor

Frames can nest: a page can frame a page that frames your page.

If only the top of that chain were checked, a hostile page sitting in the middle would be invisible to the rule. RFC 7034 describes exactly that gap. Its security considerations say the implementations it documented compared the framed page with the top-level browsing context only, so untrusted content from another origin, embedded in your page, could embed another of your SAMEORIGIN pages and pass the check.

It also records that implementations varied: the ones it knew of compared against the top-level page, and it says others may consider the immediate framing page, or might evaluate the whole chain of nested frames in between.

The newer directive closes that gap by design. Content Security Policy Level 2, a W3C Recommendation of 15 December 2016, said many user agents implemented SAMEORIGIN against the top-level document only, while frame-ancestors checks each ancestor and cancels the load if any one does not match. Level 3's algorithm walks up the chain the same way, taking each container document's origin in turn and returning Blocked at the first one that does not match.

MDN gives the practical consequence: with nested frames, every ancestor should be allowed by the frame-ancestors directive of the innermost page.

The HTML Standard's current processing model applies the same idea to SAMEORIGIN: it walks every container document and refuses if any one is not the same origin as the page. Embed E4 in the harness is the nested case: your partner's page frames one of your own pages, which frames the account page.

Under 'self' or SAMEORIGIN the written rules expect the account page to be blocked, because the outermost page is on another origin.

Which header a browser follows when both are sent

When a response carries both, the specifications say frame-ancestors decides.

Content Security Policy Level 2 used SHOULD for both halves: if a resource has both policies, the frame-ancestors policy SHOULD be enforced and the X-Frame-Options policy SHOULD be ignored. Its status section says the Working Group expects Level 3 to obsolete it.

Level 3, the current Working Draft, says that to allow backwards-compatible deployment the directive overrides the X-Frame-Options header, and that when a resource is delivered with an enforced frame-ancestors directive, X-Frame-Options will be ignored, per HTML's processing model.

The HTML Standard's processing model is where that happens. Before it reads X-Frame-Options at all, it looks through the response's Content Security Policies, skips any whose disposition is not enforce, and returns early if one contains frame-ancestors, leaving that directive to decide. Its own summary is that if both are used in the same response, X-Frame-Options is ignored.

Three consequences follow, and the harness has a case for each. A strict X-Frame-Options does not overrule a looser frame-ancestors: in case C11 the policy names your own origin and the partner while X-Frame-Options says DENY, and the written rules expect the partner's embed to be displayed.

A looser X-Frame-Options does not relax a strict frame-ancestors either: in case C12, frame-ancestors 'none' sits beside SAMEORIGIN and even your own pages are refused. And a report-only policy does not count, because the HTML Standard skips policies that are not enforced and Level 3 describes Content-Security-Policy-Report-Only as monitoring, not enforcing. In case C13 a report-only frame-ancestors 'none' sits beside SAMEORIGIN, and SAMEORIGIN still applies.

Browsers have not always followed the rule. OWASP's cheat sheet notes that older browser versions, giving Chrome 40 and Firefox 35 as examples, ignored it and followed X-Frame-Options instead. MDN's clickjacking page says that when both are set, browsers that support frame-ancestors will ignore X-Frame-Options. The evidence table in the asset is there so you can record what your own browsers do.

What to send while older browsers still matter

Send both, with values that agree.

MDN's clickjacking page says that by setting X-Frame-Options as well as frame-ancestors you can prevent embedding in browsers that do not support frame-ancestors, and that because browser support for frame-ancestors is very good, this is not a major concern; its defence checklist lists both headers.

ASVS 5.0 requirement 3.4.6 makes frame-ancestors the requirement and notes that X-Frame-Options, although supported by browsers, is obsolete and may not be relied upon. The Next.js headers reference likewise says X-Frame-Options has been superseded by frame-ancestors.

  • No page needs to be framed: Content-Security-Policy: frame-ancestors 'none' and X-Frame-Options: DENY. OWASP recommends both values unless a specific need for framing has been identified.
  • Your own pages frame it and nobody else does: frame-ancestors 'self' and X-Frame-Options: SAMEORIGIN.
  • One partner embeds it: frame-ancestors 'self' https://partner.example.com, with X-Frame-Options: SAMEORIGIN for any browser that does not read frame-ancestors. Under RFC 7034 section 2.1, a browser receiving SAMEORIGIN MUST NOT display the content in any frame from a page of a different origin than the content itself. The header therefore asks that browser to refuse the partner's embed too, which fails closed rather than open. Do not use ALLOW-FROM.

Adding frame-ancestors to a policy you already send

If your site already sends a Content Security Policy for its scripts, add frame-ancestors to that policy. A second enforced policy works too, because Level 3 notes that adding policies to the list a browser enforces can only further restrict what the page may do, but one policy is easier to read and to test.

A policy's script directives are a defence against injected script, which is the XSS guide's subject; frame-ancestors governs only who may embed the page.

Why script that tries to break out of a frame is not relied on

The older defence is script in the page that checks whether the page is in a frame and, if so, tries to take over the whole window.

WSTG-CLNT-09 calls it frame busting. RFC 7034 cites a study showing that frame-breaking JavaScript has weaknesses that allow its protection to be circumvented, and CWE-1021 says the frame-breaker can be circumvented or bypassed and does not intuitively account for multiple nested frames. OWASP's cheat sheet marks the simple version of the script as insecure and not to be used, because multiple ways of defeating it have been made public, one of them a frame in which the page's script is not allowed to run, such as a sandboxed iframe.

Browsers now limit the break-out itself. MDN's iframe reference says a cross-origin frame may redirect the top-level page only if the frame has sticky activation, meaning the user must have interacted with the frame or granted permission, and that a sandboxed frame blocks top navigation unless the sandbox allows it. MDN calls this restriction the framebusting intervention.

The headers do not depend on any of that. Both specifications check the navigation response, the framed page's response as it arrives. Those checks read the framing headers delivered with that response and the origins of the documents that frame the page.

On this page's reading, that means the decision does not wait on any script in the page. OWASP still gives a frame-breaking script for legacy browsers that do not support X-Frame-Options, one that hides the page until it confirms it is the top-level document, and says the defences are independent and that more than one should be implemented where possible. Treat any such script as an extra for old browsers, not as the control you rely on.

How to let one partner embed a page and refuse the rest

Some embeds are legitimate: a booking widget on a partner's site, a quote form inside a franchise network's pages, or a customer portal shown inside another product.

The aim is to allow exactly that and nothing more.

  • Give the embed its own route, such as /booking/embed, and allow framing there only, while every other route keeps frame-ancestors 'none' or 'self'. In Next.js, the headers reference says that when two rules match a path and set the same header, the last one overrides the first. On this page's reading, a specific rule placed after a site-wide one can therefore relax a single route.
  • Name the partner as a full origin: scheme, host and, if it is not the default, port. Under Level 3's matching rules, a source with no port matches only the default port for the scheme, and a source written with http also matches https on the same host. A wildcard such as https://*.example.com matches subdomains but not example.com itself, as OWASP's cheat sheet points out.
  • Keep 'self' in the list if your own pages frame the route. Case C9 names only the partner, and the written rules then refuse your own framing page as well.
  • Use host names, not IP addresses. Level 3's host matching returns no match for a host that is not a domain, while a note elsewhere in the same draft says 127.0.0.1 is the one address that will match, and the draft says authors ought to prefer host names whenever possible. The harness names its partner as localhost for that reason.
  • Do not widen the list to https: or *, since either lets any matching page frame the route.
  • Keep X-Frame-Options: SAMEORIGIN on the route for browsers that do not read frame-ancestors, and accept that the header asks those browsers not to show the partner's embed: under RFC 7034 section 2.1, a browser receiving SAMEORIGIN MUST NOT display the content in any frame from a page of a different origin than the content itself.
  • Inside the embed, keep high-risk actions behind a step the server checks. OWASP's guidance on DoubleClickjacking, which uses a separate top-level window that framing restrictions do not stop, is to require the user to review the action's details and complete transaction authorisation, enforced on the server.

Setting the headers on every response, error pages and redirects included

A framing header protects only the responses that carry it.

OWASP's cheat sheet suggests a filter that adds the header to every page, or setting it at the web application firewall or the web or application server, rather than adding it page by page. MDN's CSP guide says a policy should be set on all responses to all requests, not just the main document.

Server configuration can still drop it from responses you did not think about, and two of the places to look are error pages and redirects.

Error pages and redirects in nginx and Apache

nginx's add_header directive adds a header only when the response code is 200, 201, 204, 206, 301, 302, 303, 304, 307 or 308, unless the always parameter is given. Neither 404 nor 500 is in that list, so without always a 404 or 500 page that shows a form goes out with no framing header. nginx's documentation also says add_header directives are inherited from the level above only if the current level defines none of its own, and that those inheritance rules can be redefined with the add_header_inherit directive, which it says appeared in version 1.29.3.

Under the default rule, a location block that adds one header of its own loses the server-wide framing header.

In Apache, the Header directive uses the onsuccess table by default; headers in the always table are added even on error and persist across internal redirects such as ErrorDocument handlers, and for a locally generated non-2xx response such as a redirect, only the always table is used. MDN's examples use add_header X-Frame-Options SAMEORIGIN always for nginx and Header always set X-Frame-Options "SAMEORIGIN" for Apache.

Apache's documentation also warns that its two header tables can leave a response with the same header duplicated. When the copies hold different values and one of them is DENY, SAMEORIGIN or ALLOWALL, the HTML Standard refuses framing altogether, which is case C5. That fails closed, but it still means the configuration is not doing what you meant.

Next.js

In Next.js, the headers key in next.config.js sets response headers by path pattern, and the reference says headers are checked before the filesystem, which includes pages and /public files. The Next.js Content Security Policy guide's example policies include frame-ancestors 'none', and its example for applications that do not need nonces sets the header in next.config.js for the source pattern /(.*).

Check error pages and redirects in your own build rather than assuming they match. The Next.js guide in this library covers how a Next.js application is tested route by route.

Proxies, CDNs and other hostnames

OWASP's cheat sheet and WSTG-CLNT-09 both warn that web proxies add and strip headers, and that a proxy which strips X-Frame-Options takes the site's framing protection with it. WSTG adds that because the header has to be set on every page, a mobile version of a site may be left without it.

Check the headers the browser actually receives on each hostname, through every CDN or proxy in front of it. OWASP's Top 10:2025 lists a server that does not send security headers or directives, or does not set them to secure values, under A02 Security Misconfiguration, which has its own guide in this library. The free security headers checker in this library compares the headers a site sends with recommended values.

How to test for clickjacking on a site you own

WSTG-CLNT-09 starts simply: create a web page containing an iframe of the target page and see whether it loads.

If it does, the guide says the page has no protection against clickjacking; if it does not, the site probably has some form of protection, which the guide says is not a guarantee that the page is immune. Its two objectives are to understand the measures in place, and to assess how strict they are and whether they can be bypassed.

Do the looking yourself rather than through script on the test page. MDN's iframe reference says browsers do not fire the error event on iframes and always fire the load event, even when the content fails to load.

On this page's reading, the load event therefore does not tell the framing page whether the frame was refused. Look at the frame, and read the developer tools console of the page you opened.

  • List the pages where a click or a few keystrokes change something while signed in, plus the sign-in page, and include the error pages and the page each redirect lands on.
  • For each one, read the response headers in the developer tools network panel: X-Frame-Options, Content-Security-Policy and Content-Security-Policy-Report-Only. OWASP's CSP cheat sheet notes that a report-only policy is not enforced.
  • Frame each page from an origin you control that is not your site, then from one of your own pages, then through a nested frame. Those are embeds E1 to E4 in the harness.
  • Repeat while signed in, because a page that sends signed-out visitors to the sign-in page shows you the sign-in page's headers, not its own.
  • Record the browser and version beside every result, and test only sites you own or are authorised in writing to test.

Running the framing harness on your own machine

The harness is an illustration: six small files, an invented account page with one button that switches a made-up setting, and nothing to install.

The harness imports only node:http, node:readline, node:test and node:assert, and installs no packages. It was written and run on Node.js 26.0.0, the only version it was run on, and every output in the asset comes from that run.

It starts two servers on 127.0.0.1, each listening on port 0. The Node.js HTTP documentation says its server.listen() is identical to server.listen() from net.Server, and the net documentation says that when the port is 0 the operating system will assign an arbitrary unused port.

Different ports make different origins, because MDN's origin glossary defines an origin by its scheme, host name and port. The embedding site is opened two ways. As http://localhost with its port, it is the partner that the partner cases name; as http://127.0.0.1 with the same port, it is an origin no case names. That is how two servers give you both an allowed embed and a refused one.

Be clear about what the header check is. node check-headers.mjs requests every case, prints the framing headers each response carried, and applies the written rules in framing-rules.mjs, which follow the HTML Standard's section 7.7 and Level 3's sections 6.4.2 and 6.7.2, to say what a browser that follows them is expected to do for each embed.

It reads headers and applies rules. It is not a browser, and none of its output shows what any browser does. Your own browser, and the evidence table you fill in, are the evidence for that.

  • node check-headers.mjs printed all fourteen cases and the before-and-after pair, and every line of reasoning ends with the rule it applied.
  • node serve.mjs starts the harness and prints the browser evidence table: each address to open, the expected result and blanks for what you see. It keeps running until you press Ctrl+C, and typing none, restrictive or partner switches the live page's policy without changing any port.
  • node framing.test.mjs ran 29 tests that pin the headers every case sends and the expected result for every embed, and all 29 passed.
  • node framing.test.mjs drop csp-self serves case C7 with no header, as a release that lost it would. Both of C7's tests failed and the other 27 passed. The Node.js documentation says the process exit code is set to 1 when any test fails. A pipeline step that treats a non-zero exit code as a failure then fails with it.

Filling in the browser evidence table

These are steps for you to carry out in your own browser, not results captured for this page. Start the harness with node serve.mjs and keep its terminal open. Open the partner address first; if it does not load, localhost is not reaching 127.0.0.1 on your machine and the partner rows cannot be checked as written.

Then open each address in the table with the developer tools console open, note whether the invented account page and its button appear inside the frame, and copy any message the console shows.

Write the browser name and version at the top, and where a result differs from the expected one, record it as it is.

Where a frame shows the account page, press its button. The terminal prints the Origin and Sec-Fetch-Site headers the request carried. Compare that line with the one printed when you open the same account page directly on the application and press the button there.

The before-and-after pair

The live account page starts with no framing headers. Fill in its four rows, type restrictive and press Enter, reload each address and fill them in again, then do the same for partner. The written rules expect E1 and E4 to go from displayed to blocked and back to displayed, E2 to go from displayed to blocked and stay blocked, and E3, your own page framing it, to stay displayed throughout.

The header check prints the same three steps, and confirmed that under each policy the redirect after the button and the not-found page carried the same framing headers as the page itself.

Pointing the test at your own site

Keep framing-rules.mjs and the test, and change what they request. List your sensitive routes in place of the fourteen cases, pin the headers each should send, include an error page and a redirect for each, and run it against a staging copy in the pipeline that deploys the site, so a release that drops a header fails before it ships.

What a Clever Ops check covers for framing

In the Clever Ops website security check, which does not sign in, framing is one of the twelve checks.

It follows WSTG-CLNT-09 and reviews the site's Content Security Policy against the OWASP Content Security Policy Cheat Sheet, reading the headers your public pages send. A good result is that other sites cannot load your pages inside a frame, with a frame-ancestors directive in an enforced policy. The check sees headers on public pages; pages behind the sign-in are covered by an authenticated test.

Each finding comes with its evidence, a fix and the criteria the retest will use. A report is evidence for your decisions, not a certificate. If a tender or contract requires a CREST-accredited provider, Clever Ops is not CREST accredited, so we refer that work to a provider that is.

If Clever Ops built or hosts your site, the work is a security review rather than an independent test, and the report says who built it and who hosts it.

Frequently asked questions

Clickjacking is when another site shows one of your pages inside a frame and arranges things so that a click the visitor means for that site lands on your page instead. Because the framed page is your real page, in the visitor's own browser, the click can change a setting or confirm an action as if the visitor had meant it. OWASP's testing guide describes it as deceiving a user into interacting, in most cases by clicking, with something other than what they believe they are interacting with.

Both are response headers that tell the browser whether a page may be framed. X-Frame-Options is the older one, and the HTML Standard defines two values for it, DENY and SAMEORIGIN, so it can refuse all framing or allow your own origin but cannot name a partner. frame-ancestors is a Content Security Policy directive that can list several origins, and it checks every ancestor in a chain of nested frames.

Yes, with values that agree, such as frame-ancestors 'none' with DENY, or 'self' with SAMEORIGIN. MDN says that by setting X-Frame-Options as well as frame-ancestors you can prevent embedding in browsers that do not support frame-ancestors, and that browsers which do support frame-ancestors ignore X-Frame-Options when both are set. On this page's reading, the newer directive therefore decides wherever it is understood.

No. MDN calls it obsolete and says modern browsers that encounter it ignore the header completely, and the HTML Standard says it is not to be implemented. In a browser that ignores it, a page relying on ALLOW-FROM can be framed by any site, which OWASP describes as having no clickjacking defence in place. Use frame-ancestors with the partner's origin instead.

No. The Content Security Policy Level 3 draft says frame-ancestors MUST be ignored in a policy declared through a meta element, RFC 7034 says X-Frame-Options declared with a meta http-equiv tag is ignored, and MDN says setting it in a meta element has no effect. Both have to be sent as HTTP response headers.

They help, and they are not enough on their own. OWASP says cookies marked SameSite=Strict or Lax are withheld from cross-site iframe requests, which can prevent clickjacking that depends on those cookies for authentication. It also says SameSite does not block framing, gives no protection when the attack does not need a signed-in visitor, and should not be the only measure. Send the framing headers as well.

Put the page you want to check inside an iframe on a simple test page and see whether it appears, as WSTG-CLNT-09 describes. Serve that test page from another origin you control. Then read the page's response headers, check your own framing pages and a nested frame, and record the browser and version. The harness on this page does this on your own machine for fourteen header combinations. Test only sites you own or are authorised in writing to test.

Scope the right test for your application

Tell us what you have built, who uses it and when it needs to launch. You will get a plain-English recommendation: a website audit, a web application test or a referral to a specialist.