Skip to content
Pwnversity
WEB-HEADERSbasic · 6 min · upd. 2026-10

Security headers

OWASP A02:2025CWE-693

HTTP security headers are declarative defenses: the server tells the browser how to behave to mitigate XSS, clickjacking, HTTP downgrade, MIME sniffing, information leakage and origin isolation. Their absence isn’t a flaw by itself, but it enables or worsens other vulnerabilities, so they’re a mandatory part of any audit. The invariant they uphold is that the browser only does what the policy allows: with no policy, the browser assumes the most permissive behavior.

Without the right headers, a reflected XSS exploits frictionlessly, a page can be framed (clickjacking), traffic downgrades to HTTP (MITM/SSL stripping), tokens leak via Referer, and uploaded content is interpreted as executable (upload). Headers don’t create the vulnerability, but their absence is the difference between a theoretical flaw and an exploitable one.

Section titled “Catalog (what each one stops and recommended value)”

Controls where resources load from and which scripts run: defense in depth against XSS and exfiltration. Prefer nonce/hash + strict-dynamic (see XSS); avoid unsafe-inline/unsafe-eval, which nullify it.

Content-Security-Policy: default-src 'self'; script-src 'nonce-RAND' 'strict-dynamic'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'

Forces HTTPS in the browser, prevents downgrade and SSL stripping. The preload directive alone does not protect the first visit: that only happens once the domain is submitted to hstspreload.org, accepted and shipped in browsers’ preload lists; otherwise the policy is learned from the first HTTPS response.

Strict-Transport-Security: max-age=63072000; includeSubDomains; preload

CSP frame-ancestors (modern) and X-Frame-Options (compatibility). Detail in clickjacking.

Content-Security-Policy: frame-ancestors 'none'
X-Frame-Options: DENY

Prevents MIME sniffing (the browser guessing the type and running as script something uploaded as an image).

X-Content-Type-Options: nosniff

Limits URL (and in-URL token) leakage via the Referer header.

Referrer-Policy: strict-origin-when-cross-origin

Restricts powerful browser APIs (camera, mic, geolocation, USB…).

Permissions-Policy: geolocation=(), camera=(), microphone=(), payment=()

Protect against cross-origin and side-channel attacks (Spectre) and enable high-precision APIs like SharedArrayBuffer.

Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Resource-Policy: same-origin

The session transport is a “security header” too. SameSite mitigates CSRF; HttpOnly prevents theft via XSS; the browser enforces the prefixes.

Set-Cookie: sid=...; HttpOnly; Secure; SameSite=Lax
Set-Cookie: __Host-sid=...; Secure; Path=/
Set-Cookie: __Secure-sid=...; Secure

__Host- requires Secure, Path=/ and no Domain attribute, binding the cookie to that exact host, so only __Host- stops a subdomain (or a takeover) from setting cookies for the parent host. __Secure- only requires Secure and still permits Domain=, so a controlled subdomain can set a __Secure- cookie for the parent domain.

Cache-Control: no-store on pages with sensitive data; Clear-Site-Data: "*" on logout.

Assess what’s missing and leverage it: no CSP → trivial XSS; no frame-ancestors → clickjacking; no HSTS → downgrade/MITM; lax Referer → token leakage; no nosniff → XSS via uploaded content; cookie without HttpOnly → session theft from XSS. The flow is: map the present headers, cross them with candidate vulnerabilities, and use the absence as a multiplier in the report.

Ventana de terminal
# Dump a route's security headers
curl -sD - -o /dev/null https://victim.tld/ \
| grep -iE 'content-security-policy|strict-transport|x-frame|x-content-type|referrer-policy|permissions-policy'

Tools: securityheaders.com, Mozilla Observatory, CSP Evaluator (to spot weak CSPs with unsafe-inline), nuclei and Burp.

Apply all of the above site-wide (not just the home page); CSP first in Content-Security-Policy-Report-Only to measure before enforcing; __Host- for session cookies; no-store on sensitive data.

Periodic header scanning across all hosts; alert if missing in production or if a CSP includes unsafe-inline/unsafe-eval. Collect violations via report-to/report-uri.

Header scanners in CI/CD, CSP reports (report-to), WAF/edge config, and host inventory (including forgotten subdomains).

Centralize the headers in a middleware/edge to avoid uncovered routes; if a CSP caused false negatives, harden it (remove unsafe-*, move to nonce).

  • Usually not a CVE: they’re configuration. Their absence has turned theoretical XSS/clickjacking into exploitable in countless audits and bug-bounty programs, and is a common observation in compliance reports (PCI DSS, ENS).
  • A badly built CSP (with unsafe-inline or a wildcard domain hosting uploadable content) is as ineffective as having none: it shows up constantly as a CSP bypass.

Product advisories in NVD (https://nvd.nist.gov/vuln/search) and GitHub Advisories (https://github.com/advisories).

  • CSP present and robust (no unsafe-inline), evaluated with CSP Evaluator.
  • HSTS (ideally with preload), X-Content-Type-Options: nosniff.
  • frame-ancestors/X-Frame-Options.
  • Referrer-Policy and Permissions-Policy.
  • Cookie flags and prefixes (HttpOnly/Secure/SameSite/__Host-).
  • Cache-Control: no-store on pages with sensitive data.
  • Headers present on all hosts, not just the home page.