# Security headers checklist

A free checklist from Lazy Devs Agency (https://lazydevsagency.com/blog/security-headers-checklist).
Each line is a header or cookie setting, a safe starting value, and what to check before you ship it.
Starting values are our defaults, not universal answers. Test on a staging environment first.

## Before you start

- [ ] List every response type: HTML pages, API responses, static assets, redirects and error pages
- [ ] Find where headers are set: framework config, CDN or edge rules, server, static-asset rules
- [ ] Confirm static assets get the same headers as pages (some hosts serve them outside your app)

## Transport

- [ ] HTTPS only; HTTP redirects to HTTPS on the same host
- [ ] `Strict-Transport-Security: max-age=63072000` sent over HTTPS (browsers ignore it over HTTP)
- [ ] Add `includeSubDomains` only once every subdomain, including internal ones, serves HTTPS
- [ ] HSTS preload only if you meet every hstspreload.org requirement:
      valid certificate, HTTP to HTTPS redirect, all subdomains on HTTPS,
      `max-age` of at least 31536000, `includeSubDomains`, `preload`,
      and the HSTS header on any HTTPS redirect from the base domain

## Content Security Policy

- [ ] Start with `Content-Security-Policy-Report-Only` and collect violation reports
- [ ] Baseline: `default-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'`
- [ ] Scripts: nonces or hashes with `'strict-dynamic'`; avoid `'unsafe-inline'`
- [ ] Reporting: `report-to` with a `Reporting-Endpoints` header (keep `report-uri` too while browser support differs)
- [ ] Next.js: nonce-based CSP requires dynamic rendering; for static pages, consider the experimental SRI hash option
- [ ] Every third-party domain in the policy has an owner and a reason
- [ ] Switch to the enforcing `Content-Security-Policy` header once reports are clean

## Framing and content type

- [ ] `frame-ancestors 'none'` (or `'self'`) in CSP, sent as a header, not a meta tag
- [ ] `X-Frame-Options: DENY` (or `SAMEORIGIN`) for older browsers; never `ALLOW-FROM` (obsolete, ignored)
- [ ] `X-Content-Type-Options: nosniff`
- [ ] Every response has a correct `Content-Type` (nosniff blocks scripts and styles with the wrong MIME type)

## Privacy and features

- [ ] `Referrer-Policy: strict-origin-when-cross-origin` (or stricter, such as `same-origin`)
- [ ] `Permissions-Policy` disabling features you don't use, for example `camera=(), microphone=(), geolocation=()`

## Cross-origin isolation (only if you need it)

- [ ] `Cross-Origin-Opener-Policy: same-origin` (`same-origin-allow-popups` if you rely on popups such as OAuth)
- [ ] `Cross-Origin-Embedder-Policy: require-corp` or `credentialless`, after checking every embedded resource
- [ ] `Cross-Origin-Resource-Policy: same-origin` or `same-site` on resources that should not be embedded elsewhere

## Cookies

- [ ] `Secure` on every cookie
- [ ] `HttpOnly` on session and auth cookies
- [ ] `SameSite=Lax` or `Strict`; `SameSite=None` only with `Secure` and a reason
- [ ] `__Host-` prefix for session cookies (requires `Secure`, `Path=/`, and no `Domain`)

## Verify

- [ ] Check headers on a page, an API response, a static asset, a redirect and a 404
- [ ] Re-check after every CDN, hosting or framework change
- [ ] Review the CSP report stream after each release that adds a script

Sources: MDN HTTP headers reference, hstspreload.org, OWASP Secure Headers Project, Next.js CSP guide.
