Security
HTTPS, a strict Content Security Policy, isolation headers, integrity checks and the other headers, policies and DNS records that keep visitors safe.
- Required 6
- Recommended 9
- Optional 2
- Avoid 1
Required
Make browsers always use HTTPS
RequiredSend
Strict-Transport-Securityso browsers always use HTTPS. Give it a longmax-age(at least a year) andincludeSubDomains, on HTTPS responses only.Allow only the scripts you wrote
RequiredSend a strict Content Security Policy, a header that says which scripts may run. Allow scripts only by nonce or hash, with
'strict-dynamic',object-src 'none',base-uri 'none'and nounsafe-inline.Stop browsers guessing file types
RequiredSend
X-Content-Type-Options: nosniffon every response, so browsers don't guess file types. Give every response its correct Content-Type.Refuse to be framed
RequiredStop other sites from showing yours inside a frame. Use
frame-ancestors 'none'(or a list) in the CSP, plusX-Frame-Optionsfor older browsers.Set cookies safely or not at all
RequiredSet every cookie with
Secureand an explicitSameSite. AddHttpOnlyto every cookie that no script reads. UseSameSite=Noneonly for a cookie that must work inside another site.Limit how often anyone can call your APIs
RequiredPut a rate limit on every endpoint that does work for each request, such as APIs, agent endpoints, forms and report collectors.
Recommended
Load nothing over plain HTTP
RecommendedLoad every file over HTTPS. Add
upgrade-insecure-requestsas a safety net.Collect reports of blocked content
RecommendedName a place for browsers to send policy errors with
Reporting-Endpoints. Log those reports without any personal data.Tell people how to report a hole
RecommendedPublish
/.well-known/security.txtwith a contact and anExpiresdate in the future. It tells people where to report security problems.Refuse odd requests from other sites
RecommendedBrowsers send
Sec-Fetch-*headers that say where a request came from. Use them to refuse cross-site requests that are not normal page visits.Keep other sites' windows apart
RecommendedSend
Cross-Origin-Opener-Policy: same-originand aCross-Origin-Resource-Policy. These keep other sites' windows and pages away from yours. Add COEP only if you need full isolation.Share less in the Referer header
RecommendedSend
Referrer-Policy: strict-origin-when-cross-originor stricter. It limits what other sites learn about the page a visitor came from.Switch off browser features you don't use
RecommendedUse
Permissions-Policyto turn off every browser feature the site does not use. Allow the rest only for your own origin.Lock scripts to a known hash
RecommendedPut an
integrityhash, a fingerprint of the file, on every script and stylesheet. Let the browser refuse any script without one.Lock down risky DOM writes
RecommendedRequire Trusted Types in the CSP, so scripts can't write raw HTML into the page. Send every remaining case through one small named policy.
Optional
Send a hash of the body
OptionalSend a
Content-Digest, a hash of the response body, on files clients download to verify, such as Markdown copies and downloads. RFC 9530 defines it.Wipe browser data on sign-out
OptionalSend
Clear-Site-Datawhen a person signs out. Then their data does not stay behind in the browser.
Avoid
Drop the old XSS header
AvoidDo not turn on
X-XSS-Protection. The filter it controls is gone from current browsers, and in old ones it could open holes. Rely on the Content Security Policy instead.
For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers website playbook: https://agentwranglers.se/playbook/website/security.