Guides · Security headers

Clickjacking protection (frame-ancestors / X-Frame-Options)

One of the checks in every audibot report. This page says exactly what audibot reads, what passes, and how to fix it.

What audibot checks

Whether the home page sends an X-Frame-Options header, or an enforced Content-Security-Policy containing frame-ancestors. A report-only policy does not count.

Why it matters

Clickjacking loads a page in an invisible frame on top of another site and lines a button up under the visitor's cursor, so a click meant for the visible page lands on yours — while they are signed in to it.

How do I stop my site from being framed (clickjacking)?

frame-ancestors is the current mechanism; X-Frame-Options is the older one that every browser still honours. Sending both is harmless. Use 'none' / DENY if the site is never framed, 'self' / SAMEORIGIN if it frames itself.

nginx

add_header Content-Security-Policy "frame-ancestors 'self'" always;
add_header X-Frame-Options "SAMEORIGIN" always;

Apache (mod_headers)

Header always set Content-Security-Policy "frame-ancestors 'self'"
Header always set X-Frame-Options "SAMEORIGIN"

Caddy

header {
	Content-Security-Policy "frame-ancestors 'self'"
	X-Frame-Options "SAMEORIGIN"
}

If you already send a CSP

Add the directive to it rather than sending a second header:
Content-Security-Policy: default-src 'self'; frame-ancestors 'self'

Related tools

Other checks in Security headers

Security headers in the methodology ·All guides

This check is one step of the website launch checklist.

Check your site

audibot runs this check and every other one in a single audit, and publishes the report with a recommendation for each finding.