Wiki / Security headers

Warning: X-Frame-Optionsheader not set

Any other website can show your page in an invisible frame and trick a visitor into clicking your button without knowing it. One line and 5 minutes fix it, and it almost never breaks anything.

What it does not mean. It does not mean someone is framing the site already. And if you already send CSP with frame-ancestors, the protection is there: browsers then ignore X-Frame-Options.

Aleksandr IzmalkovFacts checked:

In our report
Warning (yellow), category weight 1.0 of 2.0
Time to fix
5 minutes
Can it break things
Only if another site shows your pages on purpose (a partner frame, a widget)

How to fix it

nginx (tested on 1.26.3)

add_header X-Frame-Options "SAMEORIGIN" always;

Apache (tested on 2.4.59, also works in .htaccess)

Header always set X-Frame-Options "SAMEORIGIN"

The modern equivalent in CSP

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

Both headers can be sent together: old browsers read X-Frame-Options, new ones read frame-ancestors.

How to check

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

Expected

x-frame-options: SAMEORIGIN

There must be one line. Two lines mean two sources send the header.

What can break

  • If both the server and a plugin or .htaccess add the header, the visitor gets two. On the test server Apache with Header always set in the server config and Header set in .htaccess sent both: SAMEORIGIN and DENY. Keep one source.
  • <meta http-equiv="X-Frame-Options"> has no effect: the header works only when the server sends it.
  • If another site legitimately shows your page (a booking window on a partner's page), SAMEORIGIN makes it disappear there. Use frame-ancestors with the partner's address in that case.
Terminal: an Apache response with two X-Frame-Options headers, SAMEORIGIN and DENY
A test Apache 2.4.59: the header is set in two places and the visitor receives both.

Possible values

ValueWhat it doesWhen to choose it
SAMEORIGINOnly your own site may frame the pageRight for almost everyone
DENYNobody may frame it, not even youWhen the site uses no frames at all
ALLOW-FROMObsolete valueBrowsers that meet it ignore the whole header. Use frame-ancestors https://partner.example instead

Sources

Next