Clickjacking protection: X-Frame-Options and frame-ancestors

Short answer

Clickjacking is when another website loads yours in an invisible frame and tricks visitors into clicking your buttons. Block it with X-Frame-Options: SAMEORIGIN or the modern CSP directive frame-ancestors 'self'. SiteShield passes either one (5 of 100 points).

Browser protectionWorth 5 of 100 pointsBy Mumshad JawadUpdated

What is Clickjacking protection?

Two headers control framing. The older X-Frame-Options accepts DENY (never frame me) or SAMEORIGIN (only my own site may). The newer frame-ancestors directive inside a Content-Security-Policy does the same job with an allow-list, and takes precedence in modern browsers when both are set.

Why it matters

Without it, another site can load yours in an invisible frame and trick visitors into clicking buttons they can't see.

An attacker builds a page with a tempting button, then places your real page on top of it in a transparent frame. The visitor thinks they are clicking "Play video" but actually clicks "Confirm transfer", "Delete account" or "Approve" on your site, using their own logged-in session. Anything a logged-in user can do with a click can be hijacked this way.

SiteShield maps this check to:

OWASP ASVS V14.4

See how these standards fit together in the UAE website security checklist.

How SiteShield grades it

This check, "Clickjacking protection", can cost up to 5 points: a fail loses all 5, a warning loses 3. Every scan starts at 100.

ResultWhenPoints lost
PassThe Content-Security-Policy contains a frame-ancestors directive.0
PassX-Frame-Options is DENY or SAMEORIGIN.0
FailNeither is set, so any site can frame your pages.5

How to check it yourself

Check both headers:

curl -sI https://example.com | grep -iE 'x-frame-options|content-security-policy'

Or run a free SiteShield scan, which checks this and 16 other settings in one go.

How to fix it

The quick version: Send X-Frame-Options: SAMEORIGIN, or add frame-ancestors 'self' to your Content-Security-Policy.

Cloudflare

Rules → Transform Rules → Modify Response Header: set static header X-Frame-Options to SAMEORIGIN.

Nginx

Either header works; adding both is fine:

add_header X-Frame-Options "SAMEORIGIN" always;
# or, inside your CSP:
# add_header Content-Security-Policy "frame-ancestors 'self'" always;

Apache

With mod_headers:

Header always set X-Frame-Options "SAMEORIGIN"

WordPress

WordPress already sends X-Frame-Options on the login and admin screens, but not on the public site. Set it at the server or CDN, or with this snippet:

add_action('send_headers', function () {
    header('X-Frame-Options: SAMEORIGIN');
});

FAQ

Should I use DENY or SAMEORIGIN?

Use DENY if your site never frames its own pages. Use SAMEORIGIN if it does (some page builders and previews do). Both pass in SiteShield.

What if a partner needs to embed my page?

Use CSP frame-ancestors with an allow-list, for example frame-ancestors 'self' https://partner.example. X-Frame-Options can't allow specific other sites in modern browsers.

Is X-Frame-Options deprecated?

frame-ancestors is the modern replacement, but X-Frame-Options is still widely supported and harmless to keep for older browsers.

Test your Clickjacking protection now

Run all 17 checks on your website and email domain in about 30 seconds. Free, no signup, passive checks only.

Rather not do it yourself? Fix it for me starts at AED 750 (about USD 205 by PayPal), quote agreed first. Monitoring re-scans weekly for AED 99/month or AED 990/year.

Related checks

See all 17 security checks →