GUIDE 10 OF 11 · WEBSITE HEALTH CHECK
Security headers and cookie flags
Six checks look at the headers a server sends with a page and the flags on its cookies: X-Content-Type-Options, protection against being framed, Referrer-Policy, Permissions-Policy, a server version that gives itself away, and Secure, SameSite and HttpOnly on cookies. All six are warnings, never fails, and each is fixed by one header line in your server or framework settings.
AT A GLANCE
- nosniff:
X-Content-Type-Options: nosniffmust be there, or it is a warning. - Framing: a CSP
frame-ancestorsdirective, orX-Frame-Optionsof DENY or SAMEORIGIN, passes. ALLOW-FROM does not. - Referrer-Policy: missing,
unsafe-urlorno-referrer-when-downgradeis a warning. Anything else passes. - Permissions-Policy, server leak, cookies: a missing header, a version number in
Server, or a cookie without its flags is a warning.
| Check | Group | Points |
|---|---|---|
X-Content-Type-Options sec-nosniff | Security | 3 |
Clickjacking protection sec-framing | Security | 3 |
Referrer-Policy sec-referrer | Security | 2 |
Permissions-Policy sec-permissions | Security | 1 |
Cookie flags sec-cookies | Security | 4 |
Server version not disclosed sec-server-leak | Security | 1 |
What each check looks at
| Check | Pass | Warning |
|---|---|---|
X-Content-Type-Options (sec-nosniff) | The header contains nosniff | Missing, or another value |
Clickjacking protection (sec-framing) | frame-ancestors in the CSP, or X-Frame-Options: DENY or SAMEORIGIN | Neither present (ALLOW-FROM is obsolete and does not count) |
Referrer-Policy (sec-referrer) | Any value except the two below | Missing, unsafe-url, or no-referrer-when-downgrade |
Permissions-Policy (sec-permissions) | A Permissions-Policy (or the older Feature-Policy) header | Neither present |
Server version not disclosed (sec-server-leak) | No X-Powered-By, and no version number in Server | X-Powered-By present, or Server: nginx/1.18.0 |
Cookie flags (sec-cookies) | Every cookie has the flags it needs. No cookies: skipped. | Any cookie missing a flag |
The four headers, and one block that sets them
- `X-Content-Type-Options: nosniff` stops a browser from guessing a file's type. Without it, an uploaded file can be run as a script.
- Framing:
Content-Security-Policy: frame-ancestors 'self'(orX-Frame-Options: SAMEORIGIN) stops other sites from putting your page in a frame, which is how clickjacking works. - `Referrer-Policy: strict-origin-when-cross-origin` sends only your site's name, not the full address, to other sites when someone clicks a link.
- `Permissions-Policy` switches off browser features your site does not use, such as the camera, the microphone and location.
const nextConfig = {
async headers() {
return [{
source: "/:path*",
headers: [
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "X-Frame-Options", value: "SAMEORIGIN" },
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
{ key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=()" },
],
}];
},
};
export default nextConfig;This site sends these four on every page, plus a Content-Security-Policy. Its Permissions-Policy allows the camera, microphone and motion sensors for the site's own pages only (for example camera=(self)), because some features of the site use them, and switches off geolocation, payment, USB, serial and Bluetooth. A Permissions-Policy is not copy and paste: list what your pages really use.
A server that tells everyone its version
A header such as Server: nginx/1.18.0 or X-Powered-By: PHP/7.4 tells an attacker which known flaws to try. The check warns on any X-Powered-By and on a Server value that contains a version number such as 1.18.0. A bare Server: Vercel or Server: nginx passes. Turn the version off in the server (server_tokens off; in nginx) and remove X-Powered-By (in Express, app.disable('x-powered-by'); in Next.js, poweredByHeader: false).
Cookie flags
The check reads the Set-Cookie headers of the page itself and warns about any cookie that lacks a flag it needs:
- Secure (on an HTTPS site): the cookie is only sent over HTTPS.
- SameSite (any value, including
None): limits when the cookie is sent along with requests from other sites. - HttpOnly, but only for cookies that look like session or token cookies: the cookie cannot be read by JavaScript, so a script injected into the page cannot steal it.
Set-Cookie: session=abc123; Path=/; Secure; HttpOnly; SameSite=Lax
Set-Cookie: theme=dark; Path=/; Secure; SameSite=LaxA cookie counts as "session-like" when its name contains any of sess, auth, token, sid, jwt, login, csrf or xsrf, in any case. That is a name match, not a judgement: a cookie called inside_promo contains sid and is asked for HttpOnly. If the checker flags a harmless cookie for that reason, renaming it is the quickest fix.
The check reads only the cookies set by the page's own response. A cookie that JavaScript sets later is not seen. A page that sets no cookies skips the check.
What these checks cannot see
They check that a header exists and has an acceptable value, not that it is right for your site: a Permissions-Policy that allows everything passes. Headers set only on some pages, or on files other than the page, are not seen, because the scan reads the response for the one address you gave. Strong values of Content-Security-Policy have their own guide, linked below.
Questions people ask
Do I need X-Frame-Options if I have a Content-Security-Policy?
No. The check passes if either one is there: a frame-ancestors directive in the CSP, or X-Frame-Options of DENY or SAMEORIGIN. Sending both is harmless and covers older browsers.
Which Referrer-Policy value should I use?
strict-origin-when-cross-origin is the value the checker suggests and the one this site uses. same-origin and no-referrer pass too. unsafe-url and no-referrer-when-downgrade send full addresses to other sites, so they warn.
Why is my theme cookie flagged?
Most likely it is missing Secure or SameSite. A theme cookie does not need HttpOnly, and the checker only asks for that on cookies whose names look like sessions or tokens.
Where the facts come from
See also on this site
FREE · ABOUT TEN SECONDS · NOTHING STORED
Check your own site
Paste a web address into the free website health check. It runs the 36 checks these guides explain, gives a score out of 100, and says what to fix first.
Open the free website health check