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.
In this guide
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 itHide the instructions
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
Part 1: The harness files850 lines
Part 2: The header check148 lines
Part 3: The browser evidence table220 lines
Part 4: The regression test107 lines
Part 5: Point it at your own site5 lines
Whole template1,392 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.
================================================================
PART 1: THE HARNESS FILES
================================================================
Make an empty folder, save the six files below into it with the names shown, and open a terminal in that folder.
==== File 1 of 6: framing-cases.mjs ====
// framing-cases.mjs: the framing policies the harness serves, one case each.
// Illustration only. Each case lists the response headers the invented
// account page is sent with. partnerOrigin is the one embedding origin that
// the partner cases name; the harness passes it in once it knows its port.
const X_FRAME_OPTIONS = 'X-Frame-Options'
const CONTENT_SECURITY_POLICY = 'Content-Security-Policy'
const REPORT_ONLY_POLICY = 'Content-Security-Policy-Report-Only'
export const CASES = [
{
id: 'none',
kind: 'baseline',
label: 'no framing headers',
buildHeaders: function () { return [] },
},
{
id: 'xfo-deny',
kind: 'legacy header',
label: 'X-Frame-Options DENY',
buildHeaders: function () { return [[X_FRAME_OPTIONS, 'DENY']] },
},
{
id: 'xfo-sameorigin',
kind: 'legacy header',
label: 'X-Frame-Options SAMEORIGIN',
buildHeaders: function () { return [[X_FRAME_OPTIONS, 'SAMEORIGIN']] },
},
{
id: 'xfo-allow-from',
kind: 'legacy header',
label: 'X-Frame-Options ALLOW-FROM naming the partner',
buildHeaders: function (partnerOrigin) { return [[X_FRAME_OPTIONS, 'ALLOW-FROM ' + partnerOrigin]] },
},
{
id: 'xfo-two-values',
kind: 'legacy header',
label: 'two X-Frame-Options headers, SAMEORIGIN and DENY',
buildHeaders: function () { return [[X_FRAME_OPTIONS, 'SAMEORIGIN'], [X_FRAME_OPTIONS, 'DENY']] },
},
{
id: 'csp-none',
kind: 'denied embed',
label: "frame-ancestors 'none'",
buildHeaders: function () { return [[CONTENT_SECURITY_POLICY, "frame-ancestors 'none'"]] },
},
{
id: 'csp-self',
kind: 'denied embed',
label: "frame-ancestors 'self'",
buildHeaders: function () { return [[CONTENT_SECURITY_POLICY, "frame-ancestors 'self'"]] },
},
{
id: 'csp-partner',
kind: 'allowed embed',
label: "frame-ancestors 'self' and the partner",
buildHeaders: function (partnerOrigin) { return [[CONTENT_SECURITY_POLICY, "frame-ancestors 'self' " + partnerOrigin]] },
},
{
id: 'csp-partner-only',
kind: 'allowed embed',
label: "frame-ancestors naming the partner, without 'self'",
buildHeaders: function (partnerOrigin) { return [[CONTENT_SECURITY_POLICY, 'frame-ancestors ' + partnerOrigin]] },
},
{
id: 'both-agree',
kind: 'both headers',
label: "frame-ancestors 'self' with X-Frame-Options SAMEORIGIN",
buildHeaders: function () { return [[CONTENT_SECURITY_POLICY, "frame-ancestors 'self'"], [X_FRAME_OPTIONS, 'SAMEORIGIN']] },
},
{
id: 'disagree-partner-deny',
kind: 'headers disagree',
label: "frame-ancestors 'self' and the partner, with X-Frame-Options DENY",
buildHeaders: function (partnerOrigin) {
return [[CONTENT_SECURITY_POLICY, "frame-ancestors 'self' " + partnerOrigin], [X_FRAME_OPTIONS, 'DENY']]
},
},
{
id: 'disagree-none-sameorigin',
kind: 'headers disagree',
label: "frame-ancestors 'none' with X-Frame-Options SAMEORIGIN",
buildHeaders: function () { return [[CONTENT_SECURITY_POLICY, "frame-ancestors 'none'"], [X_FRAME_OPTIONS, 'SAMEORIGIN']] },
},
{
id: 'report-only-with-xfo',
kind: 'trial policy',
label: "report-only frame-ancestors 'none' with X-Frame-Options SAMEORIGIN",
buildHeaders: function () { return [[REPORT_ONLY_POLICY, "frame-ancestors 'none'"], [X_FRAME_OPTIONS, 'SAMEORIGIN']] },
},
{
id: 'meta-only',
kind: 'common mistake',
label: 'both policies in meta elements, no headers',
buildHeaders: function () { return [] },
metaTags: [[X_FRAME_OPTIONS, 'DENY'], [CONTENT_SECURITY_POLICY, "frame-ancestors 'none'"]],
},
]
// The live account page used for the before-and-after pair. The harness
// starts with one of these and can switch between them while it runs.
export const LIVE_POLICIES = {
none: function () { return [] },
restrictive: function () { return [[CONTENT_SECURITY_POLICY, "frame-ancestors 'self'"], [X_FRAME_OPTIONS, 'SAMEORIGIN']] },
partner: function (partnerOrigin) {
return [[CONTENT_SECURITY_POLICY, "frame-ancestors 'self' " + partnerOrigin], [X_FRAME_OPTIONS, 'SAMEORIGIN']]
},
}
export const LIVE_POLICY_ORDER = ['none', 'restrictive', 'partner']
export function findCase(caseId) {
return CASES.find(function (framingCase) { return framingCase.id === caseId })
}
export function caseNumber(caseId) {
const index = CASES.findIndex(function (framingCase) { return framingCase.id === caseId })
return 'C' + (index + 1)
}
==== File 2 of 6: framing-rules.mjs ====
// framing-rules.mjs: the written rules for whether a page may be shown in a
// frame, applied to the response headers the page was sent with.
// It is not a browser. It reads headers and follows the text of:
// HTML 7.7 WHATWG HTML Standard, 7.7 The X-Frame-Options header
// CSP3 W3C Content Security Policy Level 3 (Working Draft),
// 6.4.2 frame-ancestors and 6.7.2 URL Matching
// It covers only what this harness sends: policies in response headers,
// source expressions with no path, and ancestors given as origins.
// The four embeds the harness offers. Ancestors are listed from the parent
// outwards, the order both rules walk them in.
export const EMBEDS = [
{ id: 'E1', label: 'the partner page frames the account page', ancestors: ['partner'] },
{ id: 'E2', label: 'the unnamed page frames the account page', ancestors: ['unnamed'] },
{ id: 'E3', label: 'the application frames its own account page', ancestors: ['app'] },
{ id: 'E4', label: 'the partner page frames an application page that frames the account page', ancestors: ['app', 'partner'] },
]
// Collects the three framing headers from Node's rawHeaders list
// (name, value, name, value ...), keeping each header line separate.
export function readFramingHeaders(rawHeaders) {
const framing = { xFrameOptions: [], enforced: [], reportOnly: [] }
for (let index = 0; index < rawHeaders.length; index += 2) {
const name = rawHeaders[index].toLowerCase()
const value = rawHeaders[index + 1]
if (name === 'x-frame-options') framing.xFrameOptions.push(value)
if (name === 'content-security-policy') framing.enforced.push(value)
if (name === 'content-security-policy-report-only') framing.reportOnly.push(value)
}
return framing
}
// Policies a page declares in meta elements instead of headers. The rules do
// not read them, because neither standard lets a meta element do this job.
export const META_RULE = 'a meta element does not count: frame-ancestors there MUST be ignored (CSP3 6.4.2) and X-Frame-Options there is ignored (RFC 7034 section 4)'
export function findMetaPolicies(body) {
const found = []
for (const match of body.matchAll(/<meta http-equiv="([^"]+)" content="([^"]+)">/g)) found.push(match[1] + ' ' + match[2])
return found
}
// A header value can hold several policies separated by commas, and each
// policy several directives separated by semicolons. A repeated directive
// is ignored, so the first frame-ancestors counts (CSP3 2.2.1 and 2.2.2).
function readFrameAncestorLists(headerValues) {
const lists = []
for (const headerValue of headerValues) {
for (const policy of headerValue.split(',')) {
const list = findFrameAncestors(policy)
if (list) lists.push(list)
}
}
return lists
}
function findFrameAncestors(policy) {
for (const directive of policy.split(';')) {
const tokens = directive.trim().split(/\s+/).filter(Boolean)
if (tokens.length > 0 && tokens[0].toLowerCase() === 'frame-ancestors') return tokens.slice(1)
}
return null
}
// The decision for one embed: { result: 'displayed' or 'blocked', why }.
export function expectFraming(framing, ancestorOrigins, pageOrigin) {
const enforcedLists = readFrameAncestorLists(framing.enforced)
if (enforcedLists.length > 0) return checkFrameAncestors(enforcedLists, framing, ancestorOrigins, pageOrigin)
const decision = checkXFrameOptions(framing.xFrameOptions, ancestorOrigins, pageOrigin)
if (readFrameAncestorLists(framing.reportOnly).length > 0) {
decision.why += '; the report-only frame-ancestors is not enforced and does not stop X-Frame-Options applying (HTML 7.7)'
}
return decision
}
// CSP3 6.4.2.1: every ancestor must match the list, in every enforced policy.
// HTML 7.7 then returns before it reads X-Frame-Options at all.
function checkFrameAncestors(lists, framing, ancestorOrigins, pageOrigin) {
for (const list of lists) {
for (const ancestor of ancestorOrigins) {
if (!matchesSourceList(ancestor, list, pageOrigin)) {
return { result: 'blocked', why: 'ancestor ' + ancestor + ' does not match frame-ancestors ' + list.join(' ') + ' (CSP3 6.4.2.1)' }
}
}
}
let why = 'every ancestor matches frame-ancestors ' + lists.map(function (list) { return list.join(' ') }).join(' and ') + ' (CSP3 6.4.2.1)'
if (framing.xFrameOptions.length > 0) why += '; X-Frame-Options is not consulted (HTML 7.7)'
return { result: 'displayed', why: why }
}
// HTML 7.7, step by step.
function checkXFrameOptions(headerValues, ancestorOrigins, pageOrigin) {
const values = new Set()
for (const headerValue of headerValues) {
for (const part of headerValue.split(',')) values.add(part.trim().toLowerCase())
}
const hasKnownValue = values.has('deny') || values.has('allowall') || values.has('sameorigin')
if (values.size > 1 && hasKnownValue) {
return { result: 'blocked', why: 'more than one X-Frame-Options value, one of them deny, allowall or sameorigin (HTML 7.7)' }
}
if (values.size > 1) return { result: 'displayed', why: 'several invalid X-Frame-Options values count as no header (HTML 7.7)' }
if (values.size === 0) return { result: 'displayed', why: 'no enforced frame-ancestors and no X-Frame-Options (HTML 7.7)' }
const onlyValue = [...values][0]
if (onlyValue === 'deny') return { result: 'blocked', why: 'X-Frame-Options DENY (HTML 7.7)' }
if (onlyValue === 'sameorigin') return checkSameOrigin(ancestorOrigins, pageOrigin)
return { result: 'displayed', why: 'a lone invalid X-Frame-Options value, such as ALLOW-FROM, counts as no header (HTML 7.7)' }
}
function checkSameOrigin(ancestorOrigins, pageOrigin) {
for (const ancestor of ancestorOrigins) {
if (ancestor !== pageOrigin) {
return { result: 'blocked', why: 'X-Frame-Options SAMEORIGIN and ancestor ' + ancestor + ' is another origin (HTML 7.7)' }
}
}
return { result: 'displayed', why: 'X-Frame-Options SAMEORIGIN and every ancestor is the same origin (HTML 7.7)' }
}
// CSP3 6.7.2.7: 'none' on its own, or an empty list, matches nothing.
function matchesSourceList(ancestorOrigin, list, pageOrigin) {
if (list.length === 0) return false
if (list.length === 1 && list[0].toLowerCase() === "'none'") return false
for (const expression of list) {
if (matchesExpression(new URL(ancestorOrigin), expression, new URL(pageOrigin))) return true
}
return false
}
// CSP3 6.7.2.8, for the expression forms frame-ancestors allows.
function matchesExpression(url, expression, pageUrl) {
if (expression === '*') return url.protocol === 'http:' || url.protocol === 'https:' || url.protocol === pageUrl.protocol
if (expression.toLowerCase() === "'self'") return matchesSelf(url, pageUrl)
if (/^[a-z][a-z0-9+.-]*:$/i.test(expression)) return schemePartMatches(expression.slice(0, -1), url.protocol.slice(0, -1))
return matchesHostSource(url, expression, pageUrl)
}
// 'self' is the page's own origin, plus a same-host upgrade to a secure
// scheme. URL leaves port empty for a scheme's default port, so equal ports
// here means the same port or the default port for each scheme.
function matchesSelf(url, pageUrl) {
if (url.origin === pageUrl.origin) return true
const sameHost = url.hostname === pageUrl.hostname
const portsMatch = url.port === pageUrl.port
const urlScheme = url.protocol.slice(0, -1)
const pageScheme = pageUrl.protocol.slice(0, -1)
const isSafeUpgrade = urlScheme === 'https' || urlScheme === 'wss' || (pageScheme === 'http' && (urlScheme === 'http' || urlScheme === 'ws'))
return sameHost && portsMatch && isSafeUpgrade
}
function matchesHostSource(url, expression, pageUrl) {
const parts = /^(?:([a-z][a-z0-9+.-]*):\/\/)?([^:/]+)(?::(\d+|\*))?$/i.exec(expression)
if (!parts) return false
const scheme = parts[1]
const host = parts[2]
const port = parts[3] || null
const urlScheme = url.protocol.slice(0, -1)
if (scheme && !schemePartMatches(scheme, urlScheme)) return false
if (!scheme && !schemePartMatches(pageUrl.protocol.slice(0, -1), urlScheme)) return false
if (!hostPartMatches(host, url.hostname)) return false
return portPartMatches(port, url)
}
// CSP3 6.7.2.9: a scheme also matches its secure upgrade.
function schemePartMatches(expressionScheme, urlScheme) {
const allowed = expressionScheme.toLowerCase()
const actual = urlScheme.toLowerCase()
if (allowed === actual) return true
if (allowed === 'http' && actual === 'https') return true
if (allowed === 'ws' && (actual === 'wss' || actual === 'http' || actual === 'https')) return true
return allowed === 'wss' && actual === 'https'
}
// CSP3 6.7.2.10. Its first step returns no match for a host that is not a
// domain, such as an IP address, which is why the harness names the partner
// as localhost rather than 127.0.0.1.
function hostPartMatches(pattern, host) {
if (!isDomain(host)) return false
if (pattern === '*') return true
if (pattern.startsWith('*.')) return host.toLowerCase().endsWith(pattern.slice(1).toLowerCase())
return pattern.toLowerCase() === host.toLowerCase()
}
// A simplified test: an IPv4 address is digits and dots, an IPv6 address
// is written in square brackets. Anything else is treated as a domain.
function isDomain(host) {
if (/^[0-9.]+$/.test(host)) return false
return !host.startsWith('[')
}
// CSP3 6.7.2.11: no port in the expression means the scheme's default port.
function portPartMatches(port, url) {
if (port === '*') return true
if (port === null) return url.port === ''
return Number(port) === effectivePort(url)
}
function effectivePort(url) {
if (url.port !== '') return Number(url.port)
if (url.protocol === 'https:' || url.protocol === 'wss:') return 443
return 80
}
==== File 3 of 6: harness.mjs ====
// harness.mjs: two small servers on 127.0.0.1, each on a port the system
// picks, so they are two different origins.
// The application serves an invented account page under every framing
// case, plus a page of its own that frames it.
// The embedding site serves one page per case that tries to frame the
// application's account page. Open it as http://localhost:PORT and it is
// the partner that some cases name; open it as http://127.0.0.1:PORT and
// it is an origin no case names.
// Illustration only. Everything is kept in memory, the account is invented,
// and the one button changes a made-up setting and nothing else.
import { createServer, request as sendHttpRequest } from 'node:http'
import { CASES, LIVE_POLICIES, findCase } from './framing-cases.mjs'
// options: livePolicy ('none', 'restrictive' or 'partner'), dropHeadersFor
// (a case id served without its headers, to show a regression) and
// logRequests (print one line for each press of the button).
export async function startHarness(options) {
const settings = Object.assign({ livePolicy: 'none', dropHeadersFor: null, logRequests: false }, options)
const state = { settings: settings, paperless: new Map(), origins: null }
const appServer = createServer(function (request, response) { routeAppRequest(state, request, response) })
const embedServer = createServer(function (request, response) { routeEmbedRequest(state, request, response) })
const appPort = await listenOnLoopback(appServer)
const embedPort = await listenOnLoopback(embedServer)
state.origins = {
app: 'http://127.0.0.1:' + appPort,
partner: 'http://localhost:' + embedPort,
unnamed: 'http://127.0.0.1:' + embedPort,
}
return {
origins: state.origins,
setLivePolicy: function (name) { state.settings.livePolicy = name },
close: function () { return Promise.all([closeServer(appServer), closeServer(embedServer)]) },
}
}
function listenOnLoopback(server) {
return new Promise(function (resolve) {
server.listen(0, '127.0.0.1', function () { resolve(server.address().port) })
})
}
function closeServer(server) {
return new Promise(function (resolve) { server.close(resolve) })
}
// The framing headers for one case, or none when that case is being dropped.
function headersForCase(state, framingCase) {
if (state.settings.dropHeadersFor === framingCase.id) return []
return framingCase.buildHeaders(state.origins.partner)
}
function headersForLivePage(state) {
return LIVE_POLICIES[state.settings.livePolicy](state.origins.partner)
}
// ---------- the application ----------
function routeAppRequest(state, request, response) {
const path = new URL(request.url, 'http://127.0.0.1').pathname
const caseMatch = /^\/case\/([a-z-]+)\/(account|frame)$/.exec(path)
const framingCase = caseMatch ? findCase(caseMatch[1]) : null
if (framingCase && caseMatch[2] === 'account') return serveAccount(state, request, response, framingCase.id, headersForCase(state, framingCase), framingCase.metaTags)
if (framingCase && caseMatch[2] === 'frame') return sendHtml(response, 200, [], buildAppFramePage('/case/' + framingCase.id + '/account'))
if (path === '/account') return serveAccount(state, request, response, 'live', headersForLivePage(state), null)
if (path === '/frame') return sendHtml(response, 200, [], buildAppFramePage('/account'))
sendHtml(response, 404, headersForLivePage(state), '<!doctype html><title>Not found</title><p>Not found.</p>')
}
// GET shows the account page. POST is the button: it flips the setting and
// redirects back, and the redirect carries the same framing headers.
function serveAccount(state, request, response, key, framingHeaders, metaTags) {
const accountPath = key === 'live' ? '/account' : '/case/' + key + '/account'
if (request.method === 'POST') {
const isOn = !state.paperless.get(key)
state.paperless.set(key, isOn)
if (state.settings.logRequests) logButtonPress(request, accountPath, isOn)
response.writeHead(303, toHeaderObject(framingHeaders, { Location: accountPath }))
return response.end()
}
sendHtml(response, 200, framingHeaders, buildAccountPage(key, accountPath, Boolean(state.paperless.get(key)), metaTags))
}
function logButtonPress(request, accountPath, isOn) {
const origin = request.headers.origin || '(none)'
const fetchSite = request.headers['sec-fetch-site'] || '(none)'
console.log('POST ' + accountPath + ' | Origin: ' + origin + ' | Sec-Fetch-Site: ' + fetchSite + ' | paperless statements now ' + (isOn ? 'on' : 'off'))
}
function buildAccountPage(key, accountPath, isOn, metaTags) {
const metaHtml = (metaTags || []).map(function (tag) {
return '<meta http-equiv="' + tag[0] + '" content="' + tag[1] + '">'
}).join('')
return '<!doctype html><meta charset="utf-8">' + metaHtml +
'<title>Account settings (' + key + ')</title>' +
'<h1>Account settings</h1>' +
'<p>Invented account: Sam Example. Case: ' + key + '.</p>' +
'<p>Paperless statements: <strong>' + (isOn ? 'on' : 'off') + '</strong></p>' +
'<form method="post" action="' + accountPath + '"><button>Turn paperless statements ' + (isOn ? 'off' : 'on') + '</button></form>'
}
// The application framing its own account page. This page sends no framing
// headers on purpose, so the embedding site can frame it for the nested case.
function buildAppFramePage(accountPath) {
return '<!doctype html><meta charset="utf-8"><title>Application page with a frame</title>' +
'<p>Application page. The frame below loads ' + accountPath + ' from this same origin.</p>' +
'<iframe src="' + accountPath + '" width="520" height="260" title="Account page"></iframe>'
}
// ---------- the embedding site ----------
function routeEmbedRequest(state, request, response) {
const path = new URL(request.url, 'http://127.0.0.1').pathname
const app = state.origins.app
const caseMatch = /^\/(case|nested)\/([a-z-]+)$/.exec(path)
const framingCase = caseMatch ? findCase(caseMatch[2]) : null
if (framingCase && caseMatch[1] === 'case') return sendHtml(response, 200, [], buildEmbedPage(app + '/case/' + framingCase.id + '/account'))
if (framingCase && caseMatch[1] === 'nested') return sendHtml(response, 200, [], buildEmbedPage(app + '/case/' + framingCase.id + '/frame'))
if (path === '/live') return sendHtml(response, 200, [], buildEmbedPage(app + '/account'))
if (path === '/live-nested') return sendHtml(response, 200, [], buildEmbedPage(app + '/frame'))
if (path === '/') return sendHtml(response, 200, [], buildEmbedIndex())
sendHtml(response, 404, [], '<!doctype html><title>Not found</title><p>Not found.</p>')
}
function buildEmbedPage(frameSource) {
return '<!doctype html><meta charset="utf-8"><title>Embedding site</title>' +
'<p>Embedding site. Check the address bar for which origin this page is on. The frame below asks for ' + frameSource + '</p>' +
'<iframe src="' + frameSource + '" width="560" height="340" title="Framed page"></iframe>'
}
function buildEmbedIndex() {
const links = CASES.map(function (framingCase) {
return '<li>' + framingCase.id + ': <a href="/case/' + framingCase.id + '">direct</a>, <a href="/nested/' + framingCase.id + '">nested</a></li>'
}).join('')
return '<!doctype html><meta charset="utf-8"><title>Embedding site</title><h1>Embedding site</h1>' +
'<ul>' + links + '<li>live account page: <a href="/live">direct</a>, <a href="/live-nested">nested</a></li></ul>'
}
// ---------- shared ----------
function toHeaderObject(framingHeaders, extra) {
const headers = Object.assign({}, extra)
for (const [name, value] of framingHeaders) {
if (headers[name]) headers[name] = [].concat(headers[name], value)
else headers[name] = value
}
return headers
}
function sendHtml(response, status, framingHeaders, html) {
response.writeHead(status, toHeaderObject(framingHeaders, { 'Content-Type': 'text/html; charset=utf-8' }))
response.end(html)
}
// A plain HTTP client used by the checker and the test. It returns the raw
// header lines, so two headers with the same name stay separate.
export function fetchPage(url, method) {
return new Promise(function (resolve, reject) {
const outgoing = sendHttpRequest(url, { method: method || 'GET' }, function (incoming) {
let body = ''
incoming.setEncoding('utf8')
incoming.on('data', function (chunk) { body += chunk })
incoming.on('end', function () { resolve({ status: incoming.statusCode, rawHeaders: incoming.rawHeaders, body: body }) })
})
outgoing.on('error', reject)
outgoing.end()
})
}
==== File 4 of 6: check-headers.mjs ====
// check-headers.mjs: requests every case from the harness, 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.
// Run: node check-headers.mjs
import { CASES, LIVE_POLICY_ORDER, caseNumber } from './framing-cases.mjs'
import { EMBEDS, META_RULE, expectFraming, findMetaPolicies, readFramingHeaders } from './framing-rules.mjs'
import { fetchPage, startHarness } from './harness.mjs'
const FRAMING_HEADER_NAMES = ['x-frame-options', 'content-security-policy', 'content-security-policy-report-only']
function listFramingHeaderLines(rawHeaders) {
const lines = []
for (let index = 0; index < rawHeaders.length; index += 2) {
if (FRAMING_HEADER_NAMES.includes(rawHeaders[index].toLowerCase())) lines.push(rawHeaders[index] + ': ' + rawHeaders[index + 1])
}
return lines
}
function printSent(rawHeaders, body) {
const lines = listFramingHeaderLines(rawHeaders)
if (lines.length === 0) console.log(' sent: no X-Frame-Options, Content-Security-Policy or Content-Security-Policy-Report-Only header')
for (const line of lines) console.log(' sent: ' + line)
const metaPolicies = findMetaPolicies(body)
for (const meta of metaPolicies) console.log(' page: meta http-equiv ' + meta)
if (metaPolicies.length > 0) console.log(' note: ' + META_RULE)
}
// Works out E1 to E4 for one response and prints them, grouping embeds that
// share a reason.
function printExpectations(rawHeaders, origins) {
const framing = readFramingHeaders(rawHeaders)
const results = []
const reasons = new Map()
for (const embed of EMBEDS) {
const ancestorOrigins = embed.ancestors.map(function (name) { return origins[name] })
const decision = expectFraming(framing, ancestorOrigins, origins.app)
results.push(decision.result)
const key = decision.result + ': ' + decision.why
reasons.set(key, (reasons.get(key) || []).concat(embed.id))
}
console.log(' ' + EMBEDS.map(function (embed, index) { return embed.id + ' ' + results[index] }).join(' | '))
for (const [reason, embedIds] of reasons) console.log(' ' + embedIds.join(', ') + ' ' + reason)
return results
}
async function checkCases(origins) {
for (const framingCase of CASES) {
const page = await fetchPage(origins.app + '/case/' + framingCase.id + '/account')
console.log('')
console.log(caseNumber(framingCase.id) + ' ' + framingCase.id + ': ' + framingCase.label + ' (' + framingCase.kind + ')')
printSent(page.rawHeaders, page.body)
printExpectations(page.rawHeaders, origins)
}
}
function sameFramingHeaders(first, second) {
return listFramingHeaderLines(first).join('\n') === listFramingHeaderLines(second).join('\n')
}
async function checkLiveStep(harness, policyName, stepNumber) {
harness.setLivePolicy(policyName)
const origins = harness.origins
const page = await fetchPage(origins.app + '/account')
const redirect = await fetchPage(origins.app + '/account', 'POST')
const notFound = await fetchPage(origins.app + '/no-such-page')
console.log('')
console.log('Step ' + stepNumber + ', policy ' + policyName)
printSent(page.rawHeaders, page.body)
const results = printExpectations(page.rawHeaders, origins)
console.log(' the redirect after the button (' + redirect.status + ') carries the same framing headers: ' + (sameFramingHeaders(page.rawHeaders, redirect.rawHeaders) ? 'yes' : 'no'))
console.log(' the not-found page (' + notFound.status + ') carries the same framing headers: ' + (sameFramingHeaders(page.rawHeaders, notFound.rawHeaders) ? 'yes' : 'no'))
return results
}
function printChanges(resultsByStep) {
console.log('')
console.log('Rows across the three steps:')
EMBEDS.forEach(function (embed, index) {
const sequence = resultsByStep.map(function (results) { return results[index] })
const changed = new Set(sequence).size > 1
console.log(' ' + embed.id + ' ' + sequence.join(', then ') + (changed ? '' : ' (no change)'))
})
}
async function checkBeforeAndAfter(harness) {
console.log('')
console.log('BEFORE AND AFTER: one account page, ' + harness.origins.app + '/account, under three policies in turn')
const resultsByStep = []
for (let index = 0; index < LIVE_POLICY_ORDER.length; index++) {
resultsByStep.push(await checkLiveStep(harness, LIVE_POLICY_ORDER[index], index + 1))
}
printChanges(resultsByStep)
}
function printIntroduction(origins) {
console.log('FRAMING HEADER CHECK')
console.log('Reads response headers and applies the written rules named on each line. It is not a browser.')
console.log('Application: ' + origins.app)
console.log('Embedding site, as partner: ' + origins.partner)
console.log('Embedding site, not named: ' + origins.unnamed)
for (const embed of EMBEDS) console.log(embed.id + ' ' + embed.label)
}
const harness = await startHarness({ livePolicy: 'none' })
try {
printIntroduction(harness.origins)
await checkCases(harness.origins)
await checkBeforeAndAfter(harness)
} finally {
await harness.close()
}
==== File 5 of 6: serve.mjs ====
// serve.mjs: starts the harness for your own browser and prints the browser
// evidence table: each address to open, what the written rules expect, and
// blanks for what you see. The expected results come from framing-rules.mjs
// applied to the headers this run actually serves.
// Run: node serve.mjs (or: node serve.mjs restrictive, node serve.mjs partner)
// While it runs, type none, restrictive or partner and press Enter to switch
// the live account page's policy without changing any port. Ctrl+C stops it.
import { createInterface } from 'node:readline'
import { CASES, LIVE_POLICIES, LIVE_POLICY_ORDER, caseNumber } from './framing-cases.mjs'
import { EMBEDS, META_RULE, expectFraming, findMetaPolicies, readFramingHeaders } from './framing-rules.mjs'
import { fetchPage, startHarness } from './harness.mjs'
const startPolicy = process.argv[2] || 'none'
if (!LIVE_POLICIES[startPolicy]) throw new Error('Use one of: ' + LIVE_POLICY_ORDER.join(', '))
function embedAddresses(origins, directPath, nestedPath, ownFramePath) {
return {
E1: origins.partner + directPath,
E2: origins.unnamed + directPath,
E3: origins.app + ownFramePath,
E4: origins.partner + nestedPath,
}
}
// The decision for each of E1 to E4: { result, why }.
function expectAll(rawHeaders, origins) {
const framing = readFramingHeaders(rawHeaders)
return EMBEDS.map(function (embed) {
const ancestorOrigins = embed.ancestors.map(function (name) { return origins[name] })
return expectFraming(framing, ancestorOrigins, origins.app)
})
}
// The rule references inside the reasons, such as "HTML 7.7", each listed once.
function listRules(decisions) {
const rules = new Set()
for (const decision of decisions) {
for (const match of decision.why.matchAll(/\(([^)]+)\)/g)) rules.add(match[1])
}
return [...rules].join('; ')
}
function describeSent(rawHeaders) {
const lines = []
for (let index = 0; index < rawHeaders.length; index += 2) {
const name = rawHeaders[index].toLowerCase()
if (name === 'x-frame-options' || name.startsWith('content-security-policy')) lines.push(rawHeaders[index] + ': ' + rawHeaders[index + 1])
}
return lines.length > 0 ? lines : ['no framing headers']
}
async function printCaseRows(origins) {
for (const framingCase of CASES) {
const id = framingCase.id
const page = await fetchPage(origins.app + '/case/' + id + '/account')
const decisions = expectAll(page.rawHeaders, origins)
const addresses = embedAddresses(origins, '/case/' + id, '/nested/' + id, '/case/' + id + '/frame')
console.log('')
console.log(caseNumber(id) + ' ' + id + ' (' + framingCase.kind + ')')
for (const line of describeSent(page.rawHeaders)) console.log(' sent: ' + line)
for (const meta of findMetaPolicies(page.body)) console.log(' page: meta http-equiv ' + meta)
console.log(' rule: ' + listRules(decisions))
if (findMetaPolicies(page.body).length > 0) console.log(' note: ' + META_RULE)
EMBEDS.forEach(function (embed, index) {
console.log(' ' + embed.id + ' ' + addresses[embed.id])
console.log(' expected ' + decisions[index].result.padEnd(11) + 'shown? ____ console: ________________________')
})
}
}
async function printLiveRows(harness) {
const origins = harness.origins
const addresses = embedAddresses(origins, '/live', '/live-nested', '/frame')
const resultsByPolicy = {}
for (const policyName of LIVE_POLICY_ORDER) {
harness.setLivePolicy(policyName)
const page = await fetchPage(origins.app + '/account')
resultsByPolicy[policyName] = expectAll(page.rawHeaders, origins).map(function (decision) { return decision.result })
}
harness.setLivePolicy(startPolicy)
console.log('')
console.log('BEFORE AND AFTER: the live account page, ' + origins.app + '/account')
console.log('Type none, restrictive or partner and press Enter to switch its policy, then reload each address.')
EMBEDS.forEach(function (embed, index) {
const expected = LIVE_POLICY_ORDER.map(function (policyName) { return policyName + ' ' + resultsByPolicy[policyName][index] }).join(', ')
console.log(' ' + embed.id + ' ' + addresses[embed.id])
console.log(' expected: ' + expected)
console.log(' shown? none ____ restrictive ____ partner ____ console: ______________')
})
}
function listenForPolicySwitch(harness) {
const input = createInterface({ input: process.stdin })
input.on('line', function (line) {
const name = line.trim()
if (!LIVE_POLICIES[name]) return console.log('Unknown policy. Use one of: ' + LIVE_POLICY_ORDER.join(', '))
harness.setLivePolicy(name)
console.log('Live account page policy is now: ' + name)
})
}
function printIntroduction(origins) {
console.log('FRAMING HARNESS: running until you press Ctrl+C')
console.log('Application: ' + origins.app)
console.log('Embedding site, as partner: ' + origins.partner)
console.log('Embedding site, not named: ' + origins.unnamed)
console.log('Live account page policy: ' + startPolicy)
console.log('')
console.log('BROWSER EVIDENCE TABLE')
console.log('Expected: framing-rules.mjs applied to the headers each case sends (HTML Standard 7.7; CSP Level 3, 6.4.2 and 6.7.2).')
console.log('Browser and version: ______________________________ Date: ______________')
console.log('shown? = is the invented account page, with its button, displayed inside the frame? Write yes or no.')
console.log('console = what the developer tools console reports for the page you opened, if anything.')
for (const embed of EMBEDS) console.log(embed.id + ' ' + embed.label)
}
const harness = await startHarness({ livePolicy: startPolicy, logRequests: true })
printIntroduction(harness.origins)
await printCaseRows(harness.origins)
await printLiveRows(harness)
console.log('')
console.log('Each press of the account page button prints one line below.')
listenForPolicySwitch(harness)
==== File 6 of 6: framing.test.mjs ====
// framing.test.mjs: pins the framing headers every case sends and the
// expected result for every embed, so a change to either fails the test.
// Run: node framing.test.mjs (every test should pass)
// node framing.test.mjs drop csp-self (serves that case without its
// headers, as a regression would)
// With no argument it is the passing run, which is what node --test runs.
import assert from 'node:assert/strict'
import { after, before, test } from 'node:test'
import { CASES, caseNumber } from './framing-cases.mjs'
import { EMBEDS, expectFraming, readFramingHeaders } from './framing-rules.mjs'
import { fetchPage, startHarness } from './harness.mjs'
const dropHeadersFor = process.argv[2] === 'drop' ? process.argv[3] : null
// The headers each case must send. The partner origin depends on the port.
function pinnedHeaders(partner) {
return {
'none': [],
'xfo-deny': ['X-Frame-Options: DENY'],
'xfo-sameorigin': ['X-Frame-Options: SAMEORIGIN'],
'xfo-allow-from': ['X-Frame-Options: ALLOW-FROM ' + partner],
'xfo-two-values': ['X-Frame-Options: SAMEORIGIN', 'X-Frame-Options: DENY'],
'csp-none': ["Content-Security-Policy: frame-ancestors 'none'"],
'csp-self': ["Content-Security-Policy: frame-ancestors 'self'"],
'csp-partner': ["Content-Security-Policy: frame-ancestors 'self' " + partner],
'csp-partner-only': ['Content-Security-Policy: frame-ancestors ' + partner],
'both-agree': ["Content-Security-Policy: frame-ancestors 'self'", 'X-Frame-Options: SAMEORIGIN'],
'disagree-partner-deny': ["Content-Security-Policy: frame-ancestors 'self' " + partner, 'X-Frame-Options: DENY'],
'disagree-none-sameorigin': ["Content-Security-Policy: frame-ancestors 'none'", 'X-Frame-Options: SAMEORIGIN'],
'report-only-with-xfo': ["Content-Security-Policy-Report-Only: frame-ancestors 'none'", 'X-Frame-Options: SAMEORIGIN'],
'meta-only': [],
}
}
// E1 to E4 for each case: D is displayed, B is blocked.
const PINNED_RESULTS = {
'none': 'D D D D',
'xfo-deny': 'B B B B',
'xfo-sameorigin': 'B B D B',
'xfo-allow-from': 'D D D D',
'xfo-two-values': 'B B B B',
'csp-none': 'B B B B',
'csp-self': 'B B D B',
'csp-partner': 'D B D D',
'csp-partner-only': 'D B B B',
'both-agree': 'B B D B',
'disagree-partner-deny': 'D B D D',
'disagree-none-sameorigin': 'B B B B',
'report-only-with-xfo': 'B B D B',
'meta-only': 'D D D D',
}
const FRAMING_NAMES = ['x-frame-options', 'content-security-policy', 'content-security-policy-report-only']
function framingLines(rawHeaders) {
const lines = []
for (let index = 0; index < rawHeaders.length; index += 2) {
if (FRAMING_NAMES.includes(rawHeaders[index].toLowerCase())) lines.push(rawHeaders[index] + ': ' + rawHeaders[index + 1])
}
return lines
}
function resultLetters(rawHeaders, origins) {
const framing = readFramingHeaders(rawHeaders)
return EMBEDS.map(function (embed) {
const ancestorOrigins = embed.ancestors.map(function (name) { return origins[name] })
return expectFraming(framing, ancestorOrigins, origins.app).result === 'displayed' ? 'D' : 'B'
}).join(' ')
}
let harness
before(async function () {
harness = await startHarness({ livePolicy: 'restrictive', dropHeadersFor: dropHeadersFor })
})
after(async function () {
await harness.close()
})
for (const framingCase of CASES) {
const name = caseNumber(framingCase.id) + ' ' + framingCase.id
test(name + ': sends exactly its pinned framing headers', async function () {
const page = await fetchPage(harness.origins.app + '/case/' + framingCase.id + '/account')
assert.deepEqual(framingLines(page.rawHeaders), pinnedHeaders(harness.origins.partner)[framingCase.id])
})
test(name + ': E1 to E4 give the pinned results', async function () {
const page = await fetchPage(harness.origins.app + '/case/' + framingCase.id + '/account')
assert.equal(resultLetters(page.rawHeaders, harness.origins), PINNED_RESULTS[framingCase.id])
})
}
test('live page: the redirect after the button and the not-found page carry the same headers', async function () {
const page = await fetchPage(harness.origins.app + '/account')
const redirect = await fetchPage(harness.origins.app + '/account', 'POST')
const notFound = await fetchPage(harness.origins.app + '/no-such-page')
assert.equal(redirect.status, 303)
assert.equal(notFound.status, 404)
assert.deepEqual(framingLines(redirect.rawHeaders), framingLines(page.rawHeaders))
assert.deepEqual(framingLines(notFound.rawHeaders), framingLines(page.rawHeaders))
})
================================================================
PART 2: THE HEADER CHECK
================================================================
Command: node check-headers.mjs
FRAMING HEADER CHECK
Reads response headers and applies the written rules named on each line. It is not a browser.
Application: http://127.0.0.1:57838
Embedding site, as partner: http://localhost:57839
Embedding site, not named: http://127.0.0.1:57839
E1 the partner page frames the account page
E2 the unnamed page frames the account page
E3 the application frames its own account page
E4 the partner page frames an application page that frames the account page
C1 none: no framing headers (baseline)
sent: no X-Frame-Options, Content-Security-Policy or Content-Security-Policy-Report-Only header
E1 displayed | E2 displayed | E3 displayed | E4 displayed
E1, E2, E3, E4 displayed: no enforced frame-ancestors and no X-Frame-Options (HTML 7.7)
C2 xfo-deny: X-Frame-Options DENY (legacy header)
sent: X-Frame-Options: DENY
E1 blocked | E2 blocked | E3 blocked | E4 blocked
E1, E2, E3, E4 blocked: X-Frame-Options DENY (HTML 7.7)
C3 xfo-sameorigin: X-Frame-Options SAMEORIGIN (legacy header)
sent: X-Frame-Options: SAMEORIGIN
E1 blocked | E2 blocked | E3 displayed | E4 blocked
E1, E4 blocked: X-Frame-Options SAMEORIGIN and ancestor http://localhost:57839 is another origin (HTML 7.7)
E2 blocked: X-Frame-Options SAMEORIGIN and ancestor http://127.0.0.1:57839 is another origin (HTML 7.7)
E3 displayed: X-Frame-Options SAMEORIGIN and every ancestor is the same origin (HTML 7.7)
C4 xfo-allow-from: X-Frame-Options ALLOW-FROM naming the partner (legacy header)
sent: X-Frame-Options: ALLOW-FROM http://localhost:57839
E1 displayed | E2 displayed | E3 displayed | E4 displayed
E1, E2, E3, E4 displayed: a lone invalid X-Frame-Options value, such as ALLOW-FROM, counts as no header (HTML 7.7)
C5 xfo-two-values: two X-Frame-Options headers, SAMEORIGIN and DENY (legacy header)
sent: X-Frame-Options: SAMEORIGIN
sent: X-Frame-Options: DENY
E1 blocked | E2 blocked | E3 blocked | E4 blocked
E1, E2, E3, E4 blocked: more than one X-Frame-Options value, one of them deny, allowall or sameorigin (HTML 7.7)
C6 csp-none: frame-ancestors 'none' (denied embed)
sent: Content-Security-Policy: frame-ancestors 'none'
E1 blocked | E2 blocked | E3 blocked | E4 blocked
E1 blocked: ancestor http://localhost:57839 does not match frame-ancestors 'none' (CSP3 6.4.2.1)
E2 blocked: ancestor http://127.0.0.1:57839 does not match frame-ancestors 'none' (CSP3 6.4.2.1)
E3, E4 blocked: ancestor http://127.0.0.1:57838 does not match frame-ancestors 'none' (CSP3 6.4.2.1)
C7 csp-self: frame-ancestors 'self' (denied embed)
sent: Content-Security-Policy: frame-ancestors 'self'
E1 blocked | E2 blocked | E3 displayed | E4 blocked
E1, E4 blocked: ancestor http://localhost:57839 does not match frame-ancestors 'self' (CSP3 6.4.2.1)
E2 blocked: ancestor http://127.0.0.1:57839 does not match frame-ancestors 'self' (CSP3 6.4.2.1)
E3 displayed: every ancestor matches frame-ancestors 'self' (CSP3 6.4.2.1)
C8 csp-partner: frame-ancestors 'self' and the partner (allowed embed)
sent: Content-Security-Policy: frame-ancestors 'self' http://localhost:57839
E1 displayed | E2 blocked | E3 displayed | E4 displayed
E1, E3, E4 displayed: every ancestor matches frame-ancestors 'self' http://localhost:57839 (CSP3 6.4.2.1)
E2 blocked: ancestor http://127.0.0.1:57839 does not match frame-ancestors 'self' http://localhost:57839 (CSP3 6.4.2.1)
C9 csp-partner-only: frame-ancestors naming the partner, without 'self' (allowed embed)
sent: Content-Security-Policy: frame-ancestors http://localhost:57839
E1 displayed | E2 blocked | E3 blocked | E4 blocked
E1 displayed: every ancestor matches frame-ancestors http://localhost:57839 (CSP3 6.4.2.1)
E2 blocked: ancestor http://127.0.0.1:57839 does not match frame-ancestors http://localhost:57839 (CSP3 6.4.2.1)
E3, E4 blocked: ancestor http://127.0.0.1:57838 does not match frame-ancestors http://localhost:57839 (CSP3 6.4.2.1)
C10 both-agree: frame-ancestors 'self' with X-Frame-Options SAMEORIGIN (both headers)
sent: Content-Security-Policy: frame-ancestors 'self'
sent: X-Frame-Options: SAMEORIGIN
E1 blocked | E2 blocked | E3 displayed | E4 blocked
E1, E4 blocked: ancestor http://localhost:57839 does not match frame-ancestors 'self' (CSP3 6.4.2.1)
E2 blocked: ancestor http://127.0.0.1:57839 does not match frame-ancestors 'self' (CSP3 6.4.2.1)
E3 displayed: every ancestor matches frame-ancestors 'self' (CSP3 6.4.2.1); X-Frame-Options is not consulted (HTML 7.7)
C11 disagree-partner-deny: frame-ancestors 'self' and the partner, with X-Frame-Options DENY (headers disagree)
sent: Content-Security-Policy: frame-ancestors 'self' http://localhost:57839
sent: X-Frame-Options: DENY
E1 displayed | E2 blocked | E3 displayed | E4 displayed
E1, E3, E4 displayed: every ancestor matches frame-ancestors 'self' http://localhost:57839 (CSP3 6.4.2.1); X-Frame-Options is not consulted (HTML 7.7)
E2 blocked: ancestor http://127.0.0.1:57839 does not match frame-ancestors 'self' http://localhost:57839 (CSP3 6.4.2.1)
C12 disagree-none-sameorigin: frame-ancestors 'none' with X-Frame-Options SAMEORIGIN (headers disagree)
sent: Content-Security-Policy: frame-ancestors 'none'
sent: X-Frame-Options: SAMEORIGIN
E1 blocked | E2 blocked | E3 blocked | E4 blocked
E1 blocked: ancestor http://localhost:57839 does not match frame-ancestors 'none' (CSP3 6.4.2.1)
E2 blocked: ancestor http://127.0.0.1:57839 does not match frame-ancestors 'none' (CSP3 6.4.2.1)
E3, E4 blocked: ancestor http://127.0.0.1:57838 does not match frame-ancestors 'none' (CSP3 6.4.2.1)
C13 report-only-with-xfo: report-only frame-ancestors 'none' with X-Frame-Options SAMEORIGIN (trial policy)
sent: Content-Security-Policy-Report-Only: frame-ancestors 'none'
sent: X-Frame-Options: SAMEORIGIN
E1 blocked | E2 blocked | E3 displayed | E4 blocked
E1, E4 blocked: X-Frame-Options SAMEORIGIN and ancestor http://localhost:57839 is another origin (HTML 7.7); the report-only frame-ancestors is not enforced and does not stop X-Frame-Options applying (HTML 7.7)
E2 blocked: X-Frame-Options SAMEORIGIN and ancestor http://127.0.0.1:57839 is another origin (HTML 7.7); the report-only frame-ancestors is not enforced and does not stop X-Frame-Options applying (HTML 7.7)
E3 displayed: X-Frame-Options SAMEORIGIN and every ancestor is the same origin (HTML 7.7); the report-only frame-ancestors is not enforced and does not stop X-Frame-Options applying (HTML 7.7)
C14 meta-only: both policies in meta elements, no headers (common mistake)
sent: no X-Frame-Options, Content-Security-Policy or Content-Security-Policy-Report-Only header
page: meta http-equiv X-Frame-Options DENY
page: meta http-equiv Content-Security-Policy frame-ancestors 'none'
note: a meta element does not count: frame-ancestors there MUST be ignored (CSP3 6.4.2) and X-Frame-Options there is ignored (RFC 7034 section 4)
E1 displayed | E2 displayed | E3 displayed | E4 displayed
E1, E2, E3, E4 displayed: no enforced frame-ancestors and no X-Frame-Options (HTML 7.7)
BEFORE AND AFTER: one account page, http://127.0.0.1:57838/account, under three policies in turn
Step 1, policy none
sent: no X-Frame-Options, Content-Security-Policy or Content-Security-Policy-Report-Only header
E1 displayed | E2 displayed | E3 displayed | E4 displayed
E1, E2, E3, E4 displayed: no enforced frame-ancestors and no X-Frame-Options (HTML 7.7)
the redirect after the button (303) carries the same framing headers: yes
the not-found page (404) carries the same framing headers: yes
Step 2, policy restrictive
sent: Content-Security-Policy: frame-ancestors 'self'
sent: X-Frame-Options: SAMEORIGIN
E1 blocked | E2 blocked | E3 displayed | E4 blocked
E1, E4 blocked: ancestor http://localhost:57839 does not match frame-ancestors 'self' (CSP3 6.4.2.1)
E2 blocked: ancestor http://127.0.0.1:57839 does not match frame-ancestors 'self' (CSP3 6.4.2.1)
E3 displayed: every ancestor matches frame-ancestors 'self' (CSP3 6.4.2.1); X-Frame-Options is not consulted (HTML 7.7)
the redirect after the button (303) carries the same framing headers: yes
the not-found page (404) carries the same framing headers: yes
Step 3, policy partner
sent: Content-Security-Policy: frame-ancestors 'self' http://localhost:57839
sent: X-Frame-Options: SAMEORIGIN
E1 displayed | E2 blocked | E3 displayed | E4 displayed
E1, E3, E4 displayed: every ancestor matches frame-ancestors 'self' http://localhost:57839 (CSP3 6.4.2.1); X-Frame-Options is not consulted (HTML 7.7)
E2 blocked: ancestor http://127.0.0.1:57839 does not match frame-ancestors 'self' http://localhost:57839 (CSP3 6.4.2.1)
the redirect after the button (303) carries the same framing headers: yes
the not-found page (404) carries the same framing headers: yes
Rows across the three steps:
E1 displayed, then blocked, then displayed
E2 displayed, then blocked, then blocked
E3 displayed, then displayed, then displayed (no change)
E4 displayed, then blocked, then displayed
Reading the output:
C1, C14 No header, or policies only in meta elements: nothing restricts framing, so every embed is expected to be displayed. C14's meta elements are ignored (CSP3 6.4.2; RFC 7034 section 4).
C2 to C5 The legacy header. DENY refuses every embed, your own included. SAMEORIGIN allows only E3. ALLOW-FROM counts as no header, so the rules expect even the unnamed origin to be displayed. Two different values refuse every embed.
C6, C7 'none' refuses every embed. 'self' allows only E3, and E4 is refused because its outermost page is the partner.
C8, C9 The named partner is allowed and the unnamed origin refused. Without 'self' (C9), your own framing page is refused as well.
C10 to C12 With both headers sent, frame-ancestors decides and X-Frame-Options is not consulted. C11 shows the partner allowed despite DENY, and C12 shows your own page refused despite SAMEORIGIN.
C13 A report-only frame-ancestors is not enforced, so SAMEORIGIN applies.
Before and after: E1, E2 and E4 change and E3 stays displayed. Under all three policies, the redirect after the button and the not-found page carried the same framing headers as the page itself.
================================================================
PART 3: THE BROWSER EVIDENCE TABLE
================================================================
Command: node serve.mjs
FRAMING HARNESS: running until you press Ctrl+C
Application: http://127.0.0.1:58621
Embedding site, as partner: http://localhost:58622
Embedding site, not named: http://127.0.0.1:58622
Live account page policy: none
BROWSER EVIDENCE TABLE
Expected: framing-rules.mjs applied to the headers each case sends (HTML Standard 7.7; CSP Level 3, 6.4.2 and 6.7.2).
Browser and version: ______________________________ Date: ______________
shown? = is the invented account page, with its button, displayed inside the frame? Write yes or no.
console = what the developer tools console reports for the page you opened, if anything.
E1 the partner page frames the account page
E2 the unnamed page frames the account page
E3 the application frames its own account page
E4 the partner page frames an application page that frames the account page
C1 none (baseline)
sent: no framing headers
rule: HTML 7.7
E1 http://localhost:58622/case/none
expected displayed shown? ____ console: ________________________
E2 http://127.0.0.1:58622/case/none
expected displayed shown? ____ console: ________________________
E3 http://127.0.0.1:58621/case/none/frame
expected displayed shown? ____ console: ________________________
E4 http://localhost:58622/nested/none
expected displayed shown? ____ console: ________________________
C2 xfo-deny (legacy header)
sent: X-Frame-Options: DENY
rule: HTML 7.7
E1 http://localhost:58622/case/xfo-deny
expected blocked shown? ____ console: ________________________
E2 http://127.0.0.1:58622/case/xfo-deny
expected blocked shown? ____ console: ________________________
E3 http://127.0.0.1:58621/case/xfo-deny/frame
expected blocked shown? ____ console: ________________________
E4 http://localhost:58622/nested/xfo-deny
expected blocked shown? ____ console: ________________________
C3 xfo-sameorigin (legacy header)
sent: X-Frame-Options: SAMEORIGIN
rule: HTML 7.7
E1 http://localhost:58622/case/xfo-sameorigin
expected blocked shown? ____ console: ________________________
E2 http://127.0.0.1:58622/case/xfo-sameorigin
expected blocked shown? ____ console: ________________________
E3 http://127.0.0.1:58621/case/xfo-sameorigin/frame
expected displayed shown? ____ console: ________________________
E4 http://localhost:58622/nested/xfo-sameorigin
expected blocked shown? ____ console: ________________________
C4 xfo-allow-from (legacy header)
sent: X-Frame-Options: ALLOW-FROM http://localhost:58622
rule: HTML 7.7
E1 http://localhost:58622/case/xfo-allow-from
expected displayed shown? ____ console: ________________________
E2 http://127.0.0.1:58622/case/xfo-allow-from
expected displayed shown? ____ console: ________________________
E3 http://127.0.0.1:58621/case/xfo-allow-from/frame
expected displayed shown? ____ console: ________________________
E4 http://localhost:58622/nested/xfo-allow-from
expected displayed shown? ____ console: ________________________
C5 xfo-two-values (legacy header)
sent: X-Frame-Options: SAMEORIGIN
sent: X-Frame-Options: DENY
rule: HTML 7.7
E1 http://localhost:58622/case/xfo-two-values
expected blocked shown? ____ console: ________________________
E2 http://127.0.0.1:58622/case/xfo-two-values
expected blocked shown? ____ console: ________________________
E3 http://127.0.0.1:58621/case/xfo-two-values/frame
expected blocked shown? ____ console: ________________________
E4 http://localhost:58622/nested/xfo-two-values
expected blocked shown? ____ console: ________________________
C6 csp-none (denied embed)
sent: Content-Security-Policy: frame-ancestors 'none'
rule: CSP3 6.4.2.1
E1 http://localhost:58622/case/csp-none
expected blocked shown? ____ console: ________________________
E2 http://127.0.0.1:58622/case/csp-none
expected blocked shown? ____ console: ________________________
E3 http://127.0.0.1:58621/case/csp-none/frame
expected blocked shown? ____ console: ________________________
E4 http://localhost:58622/nested/csp-none
expected blocked shown? ____ console: ________________________
C7 csp-self (denied embed)
sent: Content-Security-Policy: frame-ancestors 'self'
rule: CSP3 6.4.2.1
E1 http://localhost:58622/case/csp-self
expected blocked shown? ____ console: ________________________
E2 http://127.0.0.1:58622/case/csp-self
expected blocked shown? ____ console: ________________________
E3 http://127.0.0.1:58621/case/csp-self/frame
expected displayed shown? ____ console: ________________________
E4 http://localhost:58622/nested/csp-self
expected blocked shown? ____ console: ________________________
C8 csp-partner (allowed embed)
sent: Content-Security-Policy: frame-ancestors 'self' http://localhost:58622
rule: CSP3 6.4.2.1
E1 http://localhost:58622/case/csp-partner
expected displayed shown? ____ console: ________________________
E2 http://127.0.0.1:58622/case/csp-partner
expected blocked shown? ____ console: ________________________
E3 http://127.0.0.1:58621/case/csp-partner/frame
expected displayed shown? ____ console: ________________________
E4 http://localhost:58622/nested/csp-partner
expected displayed shown? ____ console: ________________________
C9 csp-partner-only (allowed embed)
sent: Content-Security-Policy: frame-ancestors http://localhost:58622
rule: CSP3 6.4.2.1
E1 http://localhost:58622/case/csp-partner-only
expected displayed shown? ____ console: ________________________
E2 http://127.0.0.1:58622/case/csp-partner-only
expected blocked shown? ____ console: ________________________
E3 http://127.0.0.1:58621/case/csp-partner-only/frame
expected blocked shown? ____ console: ________________________
E4 http://localhost:58622/nested/csp-partner-only
expected blocked shown? ____ console: ________________________
C10 both-agree (both headers)
sent: Content-Security-Policy: frame-ancestors 'self'
sent: X-Frame-Options: SAMEORIGIN
rule: CSP3 6.4.2.1; HTML 7.7
E1 http://localhost:58622/case/both-agree
expected blocked shown? ____ console: ________________________
E2 http://127.0.0.1:58622/case/both-agree
expected blocked shown? ____ console: ________________________
E3 http://127.0.0.1:58621/case/both-agree/frame
expected displayed shown? ____ console: ________________________
E4 http://localhost:58622/nested/both-agree
expected blocked shown? ____ console: ________________________
C11 disagree-partner-deny (headers disagree)
sent: Content-Security-Policy: frame-ancestors 'self' http://localhost:58622
sent: X-Frame-Options: DENY
rule: CSP3 6.4.2.1; HTML 7.7
E1 http://localhost:58622/case/disagree-partner-deny
expected displayed shown? ____ console: ________________________
E2 http://127.0.0.1:58622/case/disagree-partner-deny
expected blocked shown? ____ console: ________________________
E3 http://127.0.0.1:58621/case/disagree-partner-deny/frame
expected displayed shown? ____ console: ________________________
E4 http://localhost:58622/nested/disagree-partner-deny
expected displayed shown? ____ console: ________________________
C12 disagree-none-sameorigin (headers disagree)
sent: Content-Security-Policy: frame-ancestors 'none'
sent: X-Frame-Options: SAMEORIGIN
rule: CSP3 6.4.2.1
E1 http://localhost:58622/case/disagree-none-sameorigin
expected blocked shown? ____ console: ________________________
E2 http://127.0.0.1:58622/case/disagree-none-sameorigin
expected blocked shown? ____ console: ________________________
E3 http://127.0.0.1:58621/case/disagree-none-sameorigin/frame
expected blocked shown? ____ console: ________________________
E4 http://localhost:58622/nested/disagree-none-sameorigin
expected blocked shown? ____ console: ________________________
C13 report-only-with-xfo (trial policy)
sent: Content-Security-Policy-Report-Only: frame-ancestors 'none'
sent: X-Frame-Options: SAMEORIGIN
rule: HTML 7.7
E1 http://localhost:58622/case/report-only-with-xfo
expected blocked shown? ____ console: ________________________
E2 http://127.0.0.1:58622/case/report-only-with-xfo
expected blocked shown? ____ console: ________________________
E3 http://127.0.0.1:58621/case/report-only-with-xfo/frame
expected displayed shown? ____ console: ________________________
E4 http://localhost:58622/nested/report-only-with-xfo
expected blocked shown? ____ console: ________________________
C14 meta-only (common mistake)
sent: no framing headers
page: meta http-equiv X-Frame-Options DENY
page: meta http-equiv Content-Security-Policy frame-ancestors 'none'
rule: HTML 7.7
note: a meta element does not count: frame-ancestors there MUST be ignored (CSP3 6.4.2) and X-Frame-Options there is ignored (RFC 7034 section 4)
E1 http://localhost:58622/case/meta-only
expected displayed shown? ____ console: ________________________
E2 http://127.0.0.1:58622/case/meta-only
expected displayed shown? ____ console: ________________________
E3 http://127.0.0.1:58621/case/meta-only/frame
expected displayed shown? ____ console: ________________________
E4 http://localhost:58622/nested/meta-only
expected displayed shown? ____ console: ________________________
BEFORE AND AFTER: the live account page, http://127.0.0.1:58621/account
Type none, restrictive or partner and press Enter to switch its policy, then reload each address.
E1 http://localhost:58622/live
expected: none displayed, restrictive blocked, partner displayed
shown? none ____ restrictive ____ partner ____ console: ______________
E2 http://127.0.0.1:58622/live
expected: none displayed, restrictive blocked, partner blocked
shown? none ____ restrictive ____ partner ____ console: ______________
E3 http://127.0.0.1:58621/frame
expected: none displayed, restrictive displayed, partner displayed
shown? none ____ restrictive ____ partner ____ console: ______________
E4 http://localhost:58622/live-nested
expected: none displayed, restrictive blocked, partner displayed
shown? none ____ restrictive ____ partner ____ console: ______________
Each press of the account page button prints one line below.
The table above is what serve.mjs printed when it started. It then keeps running, printing one line for each press of the account page button, until you press Ctrl+C. Your browser is the evidence in this part. These are steps for you to carry out, and nothing in them is a result captured for this page.
1. Write your browser's name and version, and the date, at the top of the table.
2. Open the partner address (http://localhost and the second port) first. If it does not load, localhost is not reaching 127.0.0.1 on your machine, and the E1 and E4 rows cannot be checked as written.
3. Open the developer tools and choose the Console. For each case, open its four addresses in turn. Write yes under shown? if the invented account page and its button appear inside the frame, and no if they do not. Copy any message the console shows for that page.
4. Where a frame shows the account page, press its button. The terminal prints a line with the Origin and Sec-Fetch-Site headers the request carried. Then open the same account page directly on the application, press its button, and compare the two lines.
5. For the before-and-after rows, fill in the none column, type restrictive in the terminal and press Enter, reload the four addresses and fill in the restrictive column, then do the same with partner.
6. Where your browser does something the expected column does not predict, record it as it is, with the browser and version. MDN's compatibility data for X-Frame-Options and frame-ancestors is the place to look next.
7. Stop the harness with Ctrl+C.
================================================================
PART 4: THE REGRESSION TEST
================================================================
Command: node framing.test.mjs
✔ C1 none: sends exactly its pinned framing headers (11.914208ms)
✔ C1 none: E1 to E4 give the pinned results (0.804875ms)
✔ C2 xfo-deny: sends exactly its pinned framing headers (0.494916ms)
✔ C2 xfo-deny: E1 to E4 give the pinned results (0.410916ms)
✔ C3 xfo-sameorigin: sends exactly its pinned framing headers (0.417ms)
✔ C3 xfo-sameorigin: E1 to E4 give the pinned results (0.3535ms)
✔ C4 xfo-allow-from: sends exactly its pinned framing headers (0.2825ms)
✔ C4 xfo-allow-from: E1 to E4 give the pinned results (0.319958ms)
✔ C5 xfo-two-values: sends exactly its pinned framing headers (0.37675ms)
✔ C5 xfo-two-values: E1 to E4 give the pinned results (0.429416ms)
✔ C6 csp-none: sends exactly its pinned framing headers (0.290875ms)
✔ C6 csp-none: E1 to E4 give the pinned results (0.4ms)
✔ C7 csp-self: sends exactly its pinned framing headers (0.251958ms)
✔ C7 csp-self: E1 to E4 give the pinned results (0.331ms)
✔ C8 csp-partner: sends exactly its pinned framing headers (0.243709ms)
✔ C8 csp-partner: E1 to E4 give the pinned results (0.53875ms)
✔ C9 csp-partner-only: sends exactly its pinned framing headers (0.223458ms)
✔ C9 csp-partner-only: E1 to E4 give the pinned results (0.251417ms)
✔ C10 both-agree: sends exactly its pinned framing headers (0.272ms)
✔ C10 both-agree: E1 to E4 give the pinned results (0.245125ms)
✔ C11 disagree-partner-deny: sends exactly its pinned framing headers (0.204917ms)
✔ C11 disagree-partner-deny: E1 to E4 give the pinned results (0.242833ms)
✔ C12 disagree-none-sameorigin: sends exactly its pinned framing headers (0.201959ms)
✔ C12 disagree-none-sameorigin: E1 to E4 give the pinned results (0.19275ms)
✔ C13 report-only-with-xfo: sends exactly its pinned framing headers (0.205833ms)
✔ C13 report-only-with-xfo: E1 to E4 give the pinned results (0.198709ms)
✔ C14 meta-only: sends exactly its pinned framing headers (0.204167ms)
✔ C14 meta-only: E1 to E4 give the pinned results (0.6635ms)
✔ live page: the redirect after the button and the not-found page carry the same headers (0.668083ms)
ℹ tests 29
ℹ suites 0
ℹ pass 29
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 27.895041
The process exits with code 0. Run with node --test in the same folder, which by default runs files whose names end in .test.mjs, the same 29 tests passed.
Command: node framing.test.mjs drop csp-self
✔ C1 none: sends exactly its pinned framing headers (11.705208ms)
✔ C1 none: E1 to E4 give the pinned results (0.744708ms)
✔ C2 xfo-deny: sends exactly its pinned framing headers (0.461958ms)
✔ C2 xfo-deny: E1 to E4 give the pinned results (0.4125ms)
✔ C3 xfo-sameorigin: sends exactly its pinned framing headers (0.392959ms)
✔ C3 xfo-sameorigin: E1 to E4 give the pinned results (0.352375ms)
✔ C4 xfo-allow-from: sends exactly its pinned framing headers (0.27625ms)
✔ C4 xfo-allow-from: E1 to E4 give the pinned results (0.281125ms)
✔ C5 xfo-two-values: sends exactly its pinned framing headers (0.350541ms)
✔ C5 xfo-two-values: E1 to E4 give the pinned results (0.4155ms)
✔ C6 csp-none: sends exactly its pinned framing headers (0.2885ms)
✔ C6 csp-none: E1 to E4 give the pinned results (0.372334ms)
✖ C7 csp-self: sends exactly its pinned framing headers (1.414542ms)
✖ C7 csp-self: E1 to E4 give the pinned results (0.387916ms)
✔ C8 csp-partner: sends exactly its pinned framing headers (0.248166ms)
✔ C8 csp-partner: E1 to E4 give the pinned results (0.551375ms)
✔ C9 csp-partner-only: sends exactly its pinned framing headers (0.232834ms)
✔ C9 csp-partner-only: E1 to E4 give the pinned results (0.25425ms)
✔ C10 both-agree: sends exactly its pinned framing headers (0.251875ms)
✔ C10 both-agree: E1 to E4 give the pinned results (0.239125ms)
✔ C11 disagree-partner-deny: sends exactly its pinned framing headers (0.21175ms)
✔ C11 disagree-partner-deny: E1 to E4 give the pinned results (0.23375ms)
✔ C12 disagree-none-sameorigin: sends exactly its pinned framing headers (0.19225ms)
✔ C12 disagree-none-sameorigin: E1 to E4 give the pinned results (0.196209ms)
✔ C13 report-only-with-xfo: sends exactly its pinned framing headers (0.199333ms)
✔ C13 report-only-with-xfo: E1 to E4 give the pinned results (0.336375ms)
✔ C14 meta-only: sends exactly its pinned framing headers (0.658042ms)
✔ C14 meta-only: E1 to E4 give the pinned results (0.222417ms)
✔ live page: the redirect after the button and the not-found page carry the same headers (0.57225ms)
ℹ tests 29
ℹ suites 0
ℹ pass 27
ℹ fail 2
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 28.533166
✖ failing tests:
test at framing.test.mjs:84:3
✖ C7 csp-self: sends exactly its pinned framing headers (1.414542ms)
AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
+ actual - expected
+ []
- [
- "Content-Security-Policy: frame-ancestors 'self'"
- ]
(stack trace and error properties removed here)
test at framing.test.mjs:89:3
✖ C7 csp-self: E1 to E4 give the pinned results (0.387916ms)
AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
+ actual - expected
+ 'D D D D'
- 'B B D B'
(stack trace and error properties removed here)
The process exits with code 1. Case C7 was served with no header, as a release that lost it would be. Its first test shows the header missing. Its second shows the written rules now expect D D D D, every embed displayed, where B B D B was pinned.
================================================================
PART 5: POINT IT AT YOUR OWN SITE
================================================================
1. Copy framing-rules.mjs and framing.test.mjs into your project's tests.
2. Replace startHarness with requests to a staging copy of your site, and replace the fourteen cases with your own routes: every page where a click or a few keystrokes change something while signed in, the sign-in page, one error page, and the page each redirect lands on.
3. Pin the framing headers each route should send and the expected result for E1 to E4, with your partner's real origin in place of localhost.
4. Request signed-in routes with a test account's session, so you read the headers of the page itself rather than those of a redirect to the sign-in page.
5. Run it in the pipeline that deploys the site, and fill in the browser table again after any change to the headers, in each browser your customers use.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 Level 3 is a W3C Working Draft. The version published today is dated 27 October 2026, and its status section says publication as a Working Draft does not imply W3C endorsement and that the document should be cited only as a work in progress.
Its section 6.4.2 says frame-ancestors restricts the URLs that can embed the resource using frame, iframe, object or embed, which resources can use to avoid many UI redressing attacks. The value is either 'none' or a list of sources, each one a scheme such as https:, a host with an optional scheme, port and path, or 'self'. MDN marks the directive as Baseline, widely available across browsers since January 2018.
Three details from the specification catch people out. The directive is matched against the origin of each document that frames the page, not against a full address. It does not fall back to default-src, so the specification notes that a policy declaring default-src 'none' will still let anyone embed the resource.
And 'self' matches the page's own origin, plus the same host upgraded to a secure scheme when the ports are the same or are the default ports for their schemes (section 6.7.2.8).
A policy that names only a partner, without 'self', refuses your own framing pages, as case C9 shows.
X-Frame-Options came first. RFC 7034 says many browser vendors introduced it in 2009 and 2010, and the RFC, published in October 2013, is in the Informational category: it says it is not an Internet Standards Track specification.
It described three values, DENY, SAMEORIGIN and ALLOW-FROM followed by one origin. The HTML Standard now defines the header and its processing model, and says that definition supersedes RFC 7034. For web developers it allows two values, DENY and SAMEORIGIN, and it says the ALLOW-FROM variant is not to be implemented. MDN marks the header as Baseline, widely available across browsers since July 2015.
Two rules in the HTML Standard's processing model are worth knowing. More than one different value, whether in one comma-separated header or in two headers, is treated as a refusal if any of them is DENY, SAMEORIGIN or ALLOWALL, which case C5 shows.
And a lone value the standard does not recognise, which it says could be the legacy ALLOWALL or ALLOW-FROM forms, is treated as if the header were omitted.
- X-Frame-Options: DENY. No frame may show the page, your own included (RFC 7034 section 2.1; HTML Standard 7.7).
- X-Frame-Options: SAMEORIGIN. Only pages on the same origin may frame it. The HTML Standard checks every frame up the chain, and MDN describes the value the same way: all ancestor frames must have the same origin as the page.
- X-Frame-Options: ALLOW-FROM followed by an origin. Obsolete. MDN says modern browsers that encounter it ignore the header completely, and the HTML Standard's table gives the result as embedding allowed from anywhere.
- frame-ancestors 'none'. No frame may show the page. The specification calls it roughly equivalent to DENY.
- frame-ancestors 'self'. Only pages on the page's own origin may frame it, roughly equivalent to SAMEORIGIN, and every ancestor must match.
- frame-ancestors 'self' https://partner.example.com. Your own pages and that one partner origin. Each ancestor must match one of the listed sources.
- frame-ancestors https: or frame-ancestors *. Any HTTPS page, or any web page at all. Either matches far more than a partner list should, so neither belongs on a sensitive page.
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.