vibe-audit.lab

guides · 2026-11-14

Which Security Headers Is Your Website Missing — and What Does Each One Actually Do?

Published 2026-11-14 · Reviewed 2026-11-14 · By the Ingenious AI team

The short answer

Five headers do most of the work: Content-Security-Policy blunts XSS, Strict-Transport-Security forces HTTPS, X-Frame-Options stops clickjacking framing, X-Content-Type-Options stops MIME sniffing, and Referrer-Policy controls what URLs leak to other sites. Add them in that order, one at a time, testing as you go — a wrong CSP is the only one that can visibly break your site.

Check your own app free: paste your code or enter your site URL on the Vibe-Code Audit homepage — the free scan checks for exposed secrets, injection flaws, XSS patterns, missing headers and exposed .env/.git paths, with a copy-paste fix for every finding. No credit card.

Content-Security-Policy: the XSS seatbelt

CSP tells the browser which origins may supply scripts, styles, images and connections for your page. When (not if) an XSS bug slips into an AI-generated template, a tight CSP can stop the injected script from loading or phoning home, turning a breach into a console error. The catch is precision: generated apps pull fonts, analytics, payment widgets and CDNs from many origins, and a policy copied from a blog will either break half of them or be so permissive it does nothing.

Start with Content-Security-Policy-Report-Only, watch the violation reports for a few days, then enforce the policy you actually observed. Vibe-Code Audit's live scan checks for CSP's presence on every URL scan; the report-only-first workflow is how you earn the real header without an outage.

Strict-Transport-Security: HTTPS, permanently

HSTS tells browsers 'only ever speak to this domain over HTTPS' for a period you choose, closing the first-visit downgrade window where an attacker on café Wi-Fi swaps your login page for a lookalike. It is one line — Strict-Transport-Security: max-age=31536000 — but it is a commitment: once cached, browsers refuse plain HTTP even if your certificate breaks, so confirm your HTTPS (including renewal) is solid before sending a long max-age, and add includeSubDomains only when every subdomain is HTTPS-ready.

X-Frame-Options and frame-ancestors: anti-clickjacking

Without framing protection, another site can embed your app in an invisible iframe, overlay fake buttons, and trick your logged-in users into clicking real controls — the classic clickjacking pattern. X-Frame-Options: DENY (or SAMEORIGIN if your own pages legitimately frame each other) is the simple legacy switch; CSP's frame-ancestors directive is the modern equivalent. AI-generated admin panels and 'preview' features are frequent victims because nobody thinks of the page as embeddable until someone embeds it.

X-Content-Type-Options and Referrer-Policy: the quiet two

X-Content-Type-Options: nosniff stops browsers from second-guessing a file's declared type — the attack where an uploaded 'image' that is actually HTML gets executed as a page on your domain. It costs nothing and breaks nothing; there is no excuse for its absence. Referrer-Policy decides how much of your URL travels to other sites when users click out or load third-party resources. URLs in AI apps routinely carry tokens — password-reset links, report shares, invite codes — and a default policy can paste those into a third party's logs. strict-origin-when-cross-origin is the sane default: full referrer inside your site, origin only outside it.

A safe rollout order

Add nosniff and Referrer-Policy first (zero breakage risk), then X-Frame-Options, then HSTS once HTTPS renewal is proven, then CSP in report-only mode before enforcing. Re-run a URL scan after each step: the scanner's header check names exactly which of the five are still missing, so the loop is add, scan, confirm — the same loop you will use after every future deploy, because headers set in one layer (app, proxy, CDN) have a habit of being dropped by the next.

Worked example: Casa Loma Kitchenware's storefront

Casa Loma Kitchenware (fictional), a 340-product store built on an AI website builder, ran a URL scan that reported all five headers missing and a score of 57/100. The owner added nosniff and Referrer-Policy the same afternoon, X-Frame-Options the next day, HSTS after confirming automatic certificate renewal, and CSP in report-only mode for six days — the reports revealed a forgotten reviews widget loading scripts from a CDN that a copied-from-a-blog policy would have broken. Enforcing the observed policy took the re-scan to 93/100, with zero customer-visible breakage.

Your five-action checklist

  1. Run a live URL scan and note exactly which of the five core headers are missing on your homepage and your login page.
  2. Add X-Content-Type-Options: nosniff and a strict-origin Referrer-Policy today — neither can break your site.
  3. Set X-Frame-Options: DENY (or CSP frame-ancestors) unless your own product frames its pages.
  4. Enable HSTS with a one-year max-age only after HTTPS and its renewal are proven on every subdomain you include.
  5. Roll CSP out in report-only mode, fix the violations it reports, enforce it, then re-scan to confirm all five headers stuck.

What is Security response headers?

instructions a server attaches to every HTTP response telling the browser how to handle the page: where scripts may load from, whether the page may be framed, whether HTTPS is mandatory. They are seatbelts, not armour — they shrink the damage of other bugs rather than replacing fixes.

Sources

Frequently asked questions

Do headers matter if my site has no login?

Yes, differently: framing and MIME-sniffing attacks target visitors, CSP limits what injected ad or widget code can do, and HSTS protects anyone reaching you over hostile networks. The set is cheap insurance for any public page.

Will a strict CSP break my site?

It can — that is what report-only mode is for. Observe real traffic first, list the origins your pages actually use, then enforce. Never paste a maximal policy from the internet onto a live app.

My framework adds some headers already. Why does the scan still flag them?

Because something downstream — a proxy, CDN or static host — may strip or never receive them, or they are set on the homepage but not on app routes. The scan reports what a browser actually receives; trust the wire, not the config file.

Is HSTS dangerous to enable?

Only if your HTTPS breaks afterwards: browsers will refuse the HTTP fallback until max-age expires. Prove certificate renewal works, start with a shorter max-age if you are unsure, then raise it.

How often should I re-check headers?

After every deploy and every infrastructure change. Headers live in config that gets copied, migrated and 'simplified' — a quarterly scan catches silent regressions.

Related guides

Browse the full library on the guides index, run the checks in the launch audit, or compare plans on pricing.


Informational explainer, not a security guarantee. Scan your code free before every deploy.

← all guides

← Back