Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Missing X-Frame-Options / frame-ancestors: how to fix clickjacking

OPS-171Medium impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

Clickjacking is a trick where an attacker loads your page inside an invisible frame (an iframe) on their own site. They put a bait button on top. The visitor thinks they are clicking the bait, but the click lands on your page: a form submit, a purchase button, a settings change.

Two response headers stop this. X-Frame-Options is the older one and accepts DENY or SAMEORIGIN. frame-ancestors is a directive of Content-Security-Policy and is the modern replacement. It lets you list exactly which sites may frame you. If both are sent, modern browsers follow frame-ancestors and ignore X-Frame-Options.

Why it costs you leads or sales

Clickjacking rarely shows up as a broken page, so the cost is indirect. Visitors can be tricked into submitting your forms, changing account settings or confirming actions they did not mean to. That produces junk leads, unwanted orders, refunds and complaints. Security scanners, enterprise buyers and some partners also flag the missing header in reviews, which can slow deals.

The risk is highest on pages with a single, high-value click: checkout confirmation, login, account settings, admin screens and one-click booking.

How a clickjacking attack plays out
  1. Visitor opens bait pageA page on another domain promises a prize or video
  2. Your page loads in hidden iframeNo X-Frame-Options or frame-ancestors to stop it
  3. Visitor clicks the baitThe click lands on your invisible button
  4. Unwanted actionForm sent, order placed or setting changed

Without a framing rule, the browser happily renders your page inside the attacker's page.

A button hidden under another one

The visitor sees the top button; the click goes to the one underneath.

How to check if your site has it

You can check in under a minute. Run the command below and look for x-frame-options or a content-security-policy line containing frame-ancestors. If neither appears, the page can be framed.

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

You can also use the browser: open DevTools, go to the Network tab, reload, click the main document and read Response Headers. Check your key pages separately, not just the homepage: the form page, checkout and login. Headers can differ by path, especially behind a CDN or on a hosted checkout.

Quick frame test (save as test.html and open locally)html
<!doctype html>
<iframe src="https://www.example.com/contact" width="800" height="600"></iframe>

If your page appears inside the frame, it is not protected. If the frame is blank or shows a browser error, the header is working. Open DevTools Console to see the exact refusal message.

How to fix it

Decide first who, if anyone, should be allowed to frame your pages. Most sites need nobody except themselves, so use 'self'. If you embed your own forms or booking widget inside a partner site, list that partner's domain instead.

Common values and what they allow
Header valueWho can frame your page
frame-ancestors 'none'Nobody, not even your own site
frame-ancestors 'self'Only your own origin
frame-ancestors 'self' https://partner.exampleYou and the listed partner
X-Frame-Options: DENYNobody (older browsers)
X-Frame-Options: SAMEORIGINOnly your own origin (older browsers)
Add the header on your platform
  1. Choose a method

    Use your host's header settings, a security plugin that offers HTTP header options, or add the code below to your child theme's functions.php.

  2. Add the header in PHP

    Paste: add_action('send_headers', function(){ header("Content-Security-Policy: frame-ancestors 'self'"); header('X-Frame-Options: SAMEORIGIN'); });

  3. Clear caches

    Purge your page cache and CDN so the new header is served.

nginx examplenginx
add_header Content-Security-Policy "frame-ancestors 'self'" always;
add_header X-Frame-Options SAMEORIGIN always;
Apache .htaccess example (needs mod_headers)htaccess
<IfModule mod_headers.c>
  Header always set Content-Security-Policy "frame-ancestors 'self'"
  Header always set X-Frame-Options "SAMEORIGIN"
</IfModule>
Response headers before and after

Before

  • No X-Frame-Options header
  • No frame-ancestors directive
  • Any site can embed your form or checkout page

After

  • frame-ancestors 'self' sent on every page
  • X-Frame-Options: SAMEORIGIN as fallback
  • Other sites see a blocked frame

How to confirm it's fixed

Verify the fix
  1. Re-run the header check

    Use the curl command on the homepage, a form page and checkout. Each should show your framing rule.

  2. Repeat the frame test

    Load the test.html file again. The frame should be blank and the Console should report a refusal to display the page.

  3. Test your own embeds

    Open any page where you intentionally embed your forms or widgets and make sure they still load.

  4. Run a full journey by hand

    Submit a test form and view a checkout page to be sure nothing else broke.

How to prevent it happening again

Keep framing protection in place
  • Set the header at one level (server or CDN) so it covers every page, including error pages
  • Document which partner domains are allowed to frame you and why
  • Re-run the curl check after theme, plugin, host, CDN or proxy changes
  • Check key paths, not only the homepage, since rules can differ by path
  • Add a header check to your regular security scan or release checklist
  • Review the allowed-domains list when you end a partnership

How FunnelGuard handles this

FunnelGuard does not check for missing X-Frame-Options or frame-ancestors today. It is a possible future check, not something you can switch on now.

What FunnelGuard does do is run your real customer journeys on a schedule, such as lead forms, checkouts and booking buttons. It verifies each step, the tracking hits sent to ad and analytics platforms, and whether test leads reach your inbox and CRM. That is useful after a header change: if a new framing rule breaks an embedded form or widget, a journey that depends on it can fail and you get an alert with a screenshot.

To watch for the missing header itself, run the curl command above on a schedule, add a header check to your CI pipeline, or use a header scanner such as the Mozilla Observatory or securityheaders.com. A free FunnelGuard plan (1 site, 2 journeys, daily checks, no card) can cover your main form and checkout while you do that.

Questions people ask

What is the X-Frame-Options header?

X-Frame-Options is an HTTP response header that tells browsers whether your page may be shown inside a frame or iframe on another site. The values are DENY (never) and SAMEORIGIN (only your own site). It protects visitors from clickjacking.

What is the difference between X-Frame-Options and frame-ancestors?

frame-ancestors is a Content-Security-Policy directive and the modern replacement for X-Frame-Options. It can list several allowed domains, while X-Frame-Options cannot. If both are sent, modern browsers follow frame-ancestors, so sending both covers old and new browsers.

How do I check if my website is vulnerable to clickjacking?

Run curl -sI https://yoursite.com/ and look for x-frame-options or frame-ancestors in the headers. Then load your page in an iframe from a local HTML file. If the page displays in the frame, it can be clickjacked.

Why is my page blank after adding X-Frame-Options?

The page is probably being embedded somewhere that the header now blocks, such as a partner site, a page builder preview or your own widget on another domain. Add the embedding domain to frame-ancestors instead of using DENY or SAMEORIGIN.

How do I add X-Frame-Options in WordPress?

Use your host's header settings or a security plugin with HTTP header options, or add a send_headers action in a child theme's functions.php that sends the header. Clear caches afterwards and check with curl.

Can I fix clickjacking with Google Tag Manager or JavaScript?

No. Tag Manager and page scripts run after the page loads, and framing protection must come from the HTTP response header. Frame-busting scripts are unreliable. Set the header on your server, CDN or host.

Does FunnelGuard detect missing X-Frame-Options?

No. FunnelGuard does not check this yet; it is a possible future check. It does run your forms and checkouts on a schedule, so it can reveal a journey broken by a new framing rule. Use curl or a header scanner for the header itself.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: site safety (Stage 26, daily): X-Frame-Options / frame-ancestors.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.