X-Frame-Options Header Not Set: Fix on Every Server

, by xura.tools team

TL;DR: Add this header to every page:

X-Frame-Options: SAMEORIGIN

Use DENY if your site never frames its own pages. For modern browsers, also send Content-Security-Policy: frame-ancestors 'self', which does the same job and is more flexible. You can check your site with our security headers tool.

What the warning means

Scanners flag this when your response has no X-Frame-Options header. Older tools call it "X-Frame-Options Header Not Set". ZAP now calls it "Missing Anti-clickjacking Header" and is happy with either X-Frame-Options or a CSP frame-ancestors directive.

Without one of those, any other website can load your page inside an <iframe>. MDN says it plainly: if this header is not sent and no other embedding restriction is set, the browser allows other sites to embed the document.

The real risk: clickjacking

An attacker builds a page that loads your site in invisible iframe on top of their own buttons. The user thinks they click "Play video" but they actually click "Delete account" or "Confirm payment" on your site, where they are already logged in.

How much this matters depends on your site. If you have logins, settings pages or one-click actions, its a real issue. For a static brochure site with no forms, the risk is low. The fix is one line either way, so just add it.

X-Frame-Options vs frame-ancestors

Both control who can put your page in a frame. The differences:

X-Frame-Options CSP frame-ancestors
Values DENY, SAMEORIGIN 'none', 'self', a list of origins
Allow a specific other site No (ALLOW-FROM is obsolete) Yes, e.g. 'self' https://partner.example
Works in <meta> tag No No
Old browser support Wider Modern browsers

A few facts from MDN worth knowing:

When a browser gets both headers and supports CSP, the CSP spec says frame-ancestors wins and X-Frame-Options is ignored. So sending both is safe. Put your real rules in frame-ancestors and keep X-Frame-Options for older browsers and for scanners.

GitHub does exactly this. On December 5, 2026, curl -sI https://github.com showed x-frame-options: deny and a CSP with frame-ancestors 'none'. You can see it in our live check for github.com.

If you need to allow one partner site to embed you, X-Frame-Options can't express that. Drop it for those pages and use only frame-ancestors 'self' https://partner.example. Our CSP guide covers setting up a full policy.

How to add it on your server

nginx

server {
    listen 443 ssl;
    server_name example.com;

    add_header X-Frame-Options "SAMEORIGIN" always;
}

always sends it on error pages too. The big nginx gotcha: add_header is only inherited from the parent block if the current block has no add_header of its own. Add one header in a location and the server-level X-Frame-Options is gone for that location. Repeat the line there, use an include file with all your headers, or on nginx 1.29.3+ set add_header_inherit merge; (nginx docs).

Apache (.htaccess)

Header always set X-Frame-Options "SAMEORIGIN"

This is the same line MDN shows. Needs mod_headers enabled and AllowOverride FileInfo.

Caddy

example.com {
    header X-Frame-Options "SAMEORIGIN"
    reverse_proxy localhost:3000
}

IIS (web.config)

<configuration>
  <system.webServer>
    <httpProtocol>
      <customHeaders>
        <add name="X-Frame-Options" value="SAMEORIGIN" />
      </customHeaders>
    </httpProtocol>
  </system.webServer>
</configuration>

If your ASP.NET app also sets the header in code, you'll get it twice. Pick one place.

Cloudflare (Transform Rules / _headers for Pages)

Go to Rules > Overview > Create rule > Response Header Transform Rule, apply it to all requests, choose Set static, name X-Frame-Options, value SAMEORIGIN, then Deploy. Cloudflare also has a managed transform called Add security headers that sets x-frame-options: SAMEORIGIN with a few others.

On Cloudflare Pages, add _headers to your build output:

/*
  X-Frame-Options: SAMEORIGIN
  Content-Security-Policy: frame-ancestors 'self'

Next.js (next.config.js headers())

// next.config.js
module.exports = {
  async headers() {
    return [
      {
        source: '/(.*)',
        headers: [
          { key: 'X-Frame-Options', value: 'SAMEORIGIN' },
          { key: 'Content-Security-Policy', value: "frame-ancestors 'self'" },
        ],
      },
    ];
  },
};

The Next.js headers docs note that X-Frame-Options has been superseded by frame-ancestors. If you already send a full CSP, add frame-ancestors to it instead of sending a second CSP header.

Express (helmet)

import express from 'express';
import helmet from 'helmet';

const app = express();
app.use(helmet()); // X-Frame-Options: SAMEORIGIN and CSP frame-ancestors 'self'

For DENY: helmet({ xFrameOptions: { action: 'deny' } }). Helmet doesn't support ALLOW-FROM, on purpose.

Spring Boot

Spring Security already sends X-Frame-Options: DENY by default. If a scanner says it's missing, look for frameOptions().disable() or frameOptions(f -> f.disable()) in your config. People often add it to make the H2 database console work and forget to remove it. To allow same-site framing:

http.headers(headers -> headers
    .frameOptions(frame -> frame.sameOrigin()));

WordPress (plugin-free option)

WordPress already sends X-Frame-Options: SAMEORIGIN on the login and admin pages, but not on the public site. It has a built-in function for it, so you can hook that to every page. Add this to your child theme's functions.php or a file in wp-content/mu-plugins/:

add_action( 'send_headers', 'send_frame_options_header', 10, 0 );

That sends X-Frame-Options: SAMEORIGIN on every page PHP renders.

How to check it worked

curl -sI https://example.com | grep -i x-frame-options

You want exactly one line. To check frame-ancestors too:

curl -sI https://example.com | grep -i content-security-policy

Then run your domain through the security headers tool. It counts frame protection as present if you have either header. Test the CSP part with the CSP evaluator.

Common mistakes

  1. Using ALLOW-FROM. Browsers ignore the whole header. Use frame-ancestors.
  2. Setting it in a <meta> tag. MDN says it has no effect there. Same for frame-ancestors.
  3. Two different values. X-Frame-Options: DENY from the app and SAMEORIGIN from the proxy. ZAP flags multiple headers as a separate problem. Set it in one place.
  4. Breaking your own iframes. DENY blocks your own site too. If you frame your own pages (some CMS previews and payment flows do), use SAMEORIGIN.
  5. nginx inheritance. One add_header in a location and the rest vanish there.

FAQ

X-Frame-Options SAMEORIGIN or DENY?

DENY if nothing should ever frame your pages, including your own site. SAMEORIGIN if your own pages frame each other. Most sites are fine with SAMEORIGIN.

X-Frame-Options vs frame-ancestors, which one should I use?

Both. frame-ancestors is the modern one and takes priority in browsers that support it. X-Frame-Options covers old browsers and keeps scanners quiet.

How do I set X-Frame-Options in Next.js?

Use headers() in next.config.js with source: '/(.*)', like the example above.

Is "X-Frame-Options header not set" a high risk?

Usually not. It's a missing protection against clickjacking, not a hole by itself. It matters more if users log in and can take actions with one click.

While you're fixing headers, X-Content-Type-Options is another one-line fix that scanners report next to this one.


Is your site affected? Run the free P-256 check.