Security Headers Checker and Generator
Operator: Abdulla Al Fahad. How tools are built and checked
A response that sends 'unsafe-inline' in script-src, a 180-day HSTS, referrer-policy no-referrer-when-downgrade, no nosniff, a session cookie with no Secure flag and a Server header naming nginx 1.18.0 scores 40 out of 100 here, grade D, and each of those lost points has a sentence explaining why and a header line to replace it. The CSP alone loses 17 of its 25 points: 12 for 'unsafe-inline', 3 for no object-src and 2 for no base-uri.
Paste the raw response headers, from curl -sI or the browser's network panel, and the page parses them, evaluates each family of headers and grades the total. Nothing is requested from the site, so only what you paste is judged.
The same page also writes headers: pick a Content-Security-Policy preset, HSTS lifetime, framing and policies, and get the set as raw lines or as config for nginx, Apache, Netlify, Vercel or Next.js. With its default options the generated eight headers grade A+, 97%, when fed back through the checker.
Key features
- Twelve weighted sections: CSP 25, HSTS 15, framing 10, nosniff 8, referrer 7, permissions 5, COOP 4, COEP 3, CORP 3, cookies 12, disclosure 5, other 3
- CSP parsed by directive, with default-src fallback, nonce, hash and 'strict-dynamic' handling for 'unsafe-inline', and checks for wildcards, object-src, base-uri and form-action
- HSTS max-age bands and the header requirements for preload eligibility
- Every Set-Cookie checked for Secure, HttpOnly, SameSite, the __Host- and __Secure- prefix rules and the 400-day lifetime cap
- Redirect chains: several responses pasted together can be graded one at a time
- A generator with six output formats and validation of every source you type
How the grade is built and what each section looks for
Parsing accepts an HTTP status line, header lines with or without the < prefix curl -v adds, folded continuation lines and several responses in one paste. Names are case-insensitive, repeated headers are kept (Set-Cookie normally repeats), and a block that has an HTML tag at its start is refused with a pointer to curl -sI. Input is limited to 128 KB and 600 lines.
Scores are earned points over the points of the sections that apply. HSTS is skipped when you say the response was not served over HTTPS, since browsers ignore it there, and the cookie section is skipped when there are no cookies. Grades are A+ from 95%, A from 85, B from 70, C from 55, D from 40, E from 25 and F below. The scale is this tool's own and says nothing about another grader's letters.
CSP: 'unsafe-inline' in an effective script-src, taken from default-src when script-src is absent, costs 12 points unless a nonce, a hash or 'strict-dynamic' is present, in which case modern browsers ignore it and it is only a note. 'unsafe-eval' costs 6, a * or https: or data: source in script-src 8 (unless 'strict-dynamic' is used), no default-src 3, no script restriction at all 18, an object-src that is not 'none' 3 and no base-uri 2. If several CSP headers are sent, the best-scoring one is graded because the browser applies all of them together.
When to run it
- A site behind a CDN is tested with curl -sI against its public hostname, which shows the headers visitors really receive, including a Server banner the CDN adds and the origin's own configuration never mentions.
- A team ships a CSP in Report-Only first; the checker states it is not enforced and still counts as no CSP until the header name is changed.
- A login cookie named __Host-session is set without Path=/, and the cookie rule explains that browsers will reject it.
Running a check
- Run curl -sI https://your-site and paste the output, or copy the response headers from the network panel.
- Leave the HTTPS box ticked unless the response really came over plain HTTP, then press Grade headers.
- Work down the breakdown from the largest deductions; each note ends with a header line to use.
- To produce replacements, switch to Generate headers, choose the policies, copy the format your server uses and grade the result again.
Example
Five header lines
strict-transport-security: max-age=15552000
content-security-policy: default-src 'self'; script-src 'self' 'unsafe-inline'
x-frame-options: SAMEORIGIN
referrer-policy: no-referrer-when-downgrade
set-cookie: sid=1; Path=/; HttpOnlyPoints earned per section
Grade D, 43 of 100
CSP 8/25 (unsafe-inline -12, no object-src -3, no base-uri -2) HSTS 11/15 (180 days, no includeSubDomains)
nosniff 0/8 framing 8/10 referrer 1/7 permissions 1/5
COOP 0/4 COEP 0/3 CORP 0/3 cookies 6/12 (no Secure, no SameSite)
disclosure 5/5 other 3/3Tips for best results
- Remove the values from Set-Cookie lines before pasting headers into a ticket or chat: the grader shows only cookie names and attributes, but the text you paste still holds the session value.
- Grade the response of the page itself, not the redirect: when a chain is pasted the last response is selected, and an earlier one can have different headers.
- Use Report-Only in the generator for a first rollout, add a reporting endpoint, and switch it off only when no legitimate script is reported.
- Check each distinct response type: HTML pages, API responses and static files often get different headers from the same server.
Limits
A CSP is judged on its syntax and keywords, not simulated: an allowed host that serves user content or a JSONP endpoint can defeat a policy that scores well here.
The preload check covers the header only. The preload list also needs every subdomain to serve HTTPS and a redirect from http, which cannot be seen from one response.
Headers pasted from a browser panel may include ones the browser added; copy the Response Headers section, not the request.
Common errors and how to fix them
- script-src: "evil.com;" is not a valid source
- In the generator, each source must be a host, scheme or keyword such as 'self'. A semicolon, comma, quote or space would end the directive or the header, so it is refused.
Best practices
- Add headers in the order of their payoff: nosniff and a referrer policy cost nothing, framing is one line, HSTS needs HTTPS everywhere, and CSP needs testing.
- Remove X-Powered-By and version banners at the layer that adds them: the app, the reverse proxy and the CDN each add their own, and pasting the headers from each hop shows which one is responsible.
What the generator's CSP presets contain
Every preset starts from default-src 'self' and then sets script-src, style-src, img-src (which also allows data: images), font-src and connect-src to 'self' plus the hosts you add, followed by object-src 'none', base-uri 'self', form-action 'self', frame-ancestors from your framing choice and upgrade-insecure-requests. The inline-styles preset adds 'unsafe-inline' to style-src only. The nonce preset adds a nonce placeholder and 'strict-dynamic' to script-src.
The nonce placeholder is deliberate: the page cannot know a per-request value, so you must replace NONCE_PER_REQUEST in your server code. Extra sources are limited to hosts, schemes and 'self' or 'none', so nothing typed into a field can add another directive or a second header.
Frequently asked questions
Why is a missing COEP or COOP only a few points?
They are needed for cross-origin isolation, which only some sites use, and COEP breaks cross-origin embeds that do not opt in. With CORP they carry 10 of the 100 points in total, so leaving them out cannot sink an otherwise strong grade.
Why does the generated CSP break my inline scripts?
The presets do not allow 'unsafe-inline' for scripts, which is what makes them protective. Move the inline code to files, or choose the nonce preset and have your server add a fresh nonce to each response.
Does an A+ mean the site is secure?
No. It means the response carries the headers this tool looks for, configured the way it expects. It says nothing about injection flaws, access control or the software behind the headers, and a CSP that allows a hijackable host can still score well.