Skip to content

Security headers

Clickjacking protection

Clickjacking protection stops other websites from showing your page inside a hidden frame and tricking visitors into clicking on it.

Scanetra rating: LowCheck HDR-02

Why it matters

An attacker's page can load yours invisibly on top of a harmless-looking button, so a visitor's click lands on your page instead: changing a setting, confirming a payment or granting access.

What Scanetra looks for

  • A valid X-Frame-Options header, or a CSP frame-ancestors directive.

It reads only your homepage's public response. How a scan works

How to fix it

nginx

In the server block that serves HTTPS. The always flag also adds it to error pages.

add_header Content-Security-Policy "frame-ancestors 'self'" always;

Apache

Needs mod_headers. In the VirtualHost or .htaccess.

Header always set Content-Security-Policy "frame-ancestors 'self'"

Cloudflare

Rules › Transform Rules › Modify Response Header: create a rule for all incoming requests that sets the static header Content-Security-Policy to the value below.

frame-ancestors 'self'

Vercel

In vercel.json at the root of the project.

{
  "headers": [
    {
      "source": "/(.*)",
      "headers": [{ "key": "Content-Security-Policy", "value": "frame-ancestors 'self'" }]
    }
  ]
}

Netlify

In a file named _headers in the publish directory.

/*
  Content-Security-Policy: frame-ancestors 'self'

Older option

X-Frame-Options does the same job and is still widely sent. Add frame-ancestors to an existing CSP rather than sending a second CSP header.

X-Frame-Options: DENY

Replace example.com with your own domain, and test changes on a staging copy first where you can.

Check that it worked

The response headers include frame-ancestors or X-Frame-Options. Then scan again.

Check your own site

A free scan tells you whether your site passes this check, and the 24 others.

Scan a website