All articles
Configuration9/3/20265 min

The security headers your site (almost) always forgets

The browser knows perfectly well how to defend itself — you just have to ask it to. A handful of HTTP headers, free to enable, that block entire families of attacks.

The principle

With every response, a web server can attach invisible instructions for the browser: “never render this site inside an iframe”, “only load my own scripts”, “always force HTTPS”. These instructions are called security headers.

They cost nothing technically to enable, yet the majority of sites simply never configure them. Without them, the browser stays on its “default” configuration — the least protective one possible, for lack of instructions saying otherwise.

The headers that matter most

Content-Security-Policy precisely limits where scripts and styles loaded by the page can come from, and blocks a large share of XSS attacks even if a flaw exists elsewhere in the code. X-Frame-Options (and its CSP successor, frame-ancestors) stops your site from being trapped inside an invisible iframe — the basis of clickjacking.

Strict-Transport-Security forces the browser to always use HTTPS for your domain, even if a link mistakenly points to HTTP. X-Content-Type-Options: nosniff stops the browser from guessing a file’s type on its own and accidentally running it as a script.

What their absence really costs

Without CSP, a single XSS flaw overlooked somewhere in the code becomes immediately exploitable to its full potential, with no additional safety net. Without X-Frame-Options, your payment page can be invisibly overlaid under a fake game or ad — the visitor thinks they’re clicking the game, but they’re actually confirming a transfer (clickjacking).

Without HSTS, an attacker in a network position (a fake public wifi hotspot, for instance) can force an unencrypted connection and read the exchange in the clear, credentials included.

How to protect yourself

Most of these headers can be added in just a few lines: at the web server level (Nginx, Apache) or via a dedicated application middleware (Helmet.js for Node.js, django-security for Django, a handful of lines in Symfony or Laravel).

Start with a CSP in “report-only” mode to observe its effect without breaking anything in production, then tighten it progressively once every legitimate source is identified. Verify the final result with a dedicated public tool (securityheaders.com, for instance).

How SauronSec detects it

A passive, read-only analysis of every HTTP response: each expected header is checked for presence, with a value that is genuinely protective — a misconfigured X-Frame-Options doesn’t count as valid protection.

A deliberate anti-false-positive rule: a cookie’s Secure attribute is only required on an HTTPS site (it would be meaningless elsewhere), and HttpOnly is never demanded on an XSRF-TOKEN cookie designed by nature to be read in JavaScript — flagging it would be a false alarm, not a real flaw to fix.

Are these flaws on your site?

SauronSec detects them, proves them, and delivers the fix — with no false positives.

Ready to scan without a shadow of doubt? Request an audit