What security headers are
Security headers are HTTP response headers that tell the browser how to treat a page: always use HTTPS, which scripts may run, who may show the page in a frame, how much of the URL to share with other sites, and whether to keep a copy in caches.
They cost nothing to send and close whole classes of attack, such as protocol downgrades, clickjacking and many cross-site scripting exploits. They matter most on pages that handle credentials, which makes a sign-in page the first place to get them right.
This analyzer reads a block of headers you paste and checks each one. It does not contact any site.
The headers that matter, at a glance
| Header | Protects against | A good value |
|---|---|---|
Strict-Transport-Security | Downgrade to HTTP, SSL stripping | max-age=31536000; includeSubDomains |
Content-Security-Policy | Cross-site scripting, data injection, framing | A policy that limits scripts and sets frame-ancestors |
X-Frame-Options | Clickjacking in older browsers | DENY or SAMEORIGIN |
X-Content-Type-Options | MIME type sniffing | nosniff |
Referrer-Policy | Leaking URLs to other sites | no-referrer or strict-origin-when-cross-origin |
Cache-Control | Sensitive pages kept in caches | no-store on pages with credentials or personal data |
Permissions-Policy | Unneeded browser features | Turn off features the page does not use |
Cross-Origin-Opener-Policy | Cross-window attacks | same-origin where pop-ups are not needed |
Each header in more detail
What each header does, and what the analyzer looks for in it.
Strict-Transport-Security (HSTS)
HSTS, defined in RFC 6797, tells the browser to use only HTTPS for this host for max-age seconds, and to refuse to continue past certificate errors. After the first visit, a network attacker can no longer downgrade the connection to HTTP. includeSubDomains extends it to every subdomain; max-age=0 cancels it.
The preload flag asks to be included in the HSTS preload list built into browsers, which protects even the first visit. Submission requires a max-age of at least one year, includeSubDomains and a redirect from HTTP to HTTPS. Removal from the list is slow, so preload only when every subdomain is ready for HTTPS.
Content-Security-Policy (CSP)
CSP lists where a page may load scripts, styles, images, frames and other content from. A strict policy means that even if an attacker injects markup, their script does not run. It is the most powerful header and the hardest to get right, which is why it has its own CSP builder.
The analyzer checks the policy for the usual weaknesses: no default-src, scripts allowed with 'unsafe-inline' and no nonce or hash, 'unsafe-eval', scripts from any host, a missing object-src 'none', a missing base-uri, and a missing frame-ancestors.
X-Frame-Options and frame-ancestors
Both stop other sites from showing your page in a frame, which is how clickjacking works. frame-ancestors in CSP is the current standard and can list allowed sites; browsers that support it ignore X-Frame-Options. Sending both covers old and new browsers. ALLOW-FROM is not supported by current browsers.
X-Content-Type-Options
nosniff stops browsers from guessing a different content type than the server declared. Without it, a file uploaded as text could be treated as a script or stylesheet.
Referrer-Policy
Controls how much of the current URL is sent in the Referer header when a user follows a link or the page loads a resource. URLs on sign-in and callback pages can hold codes, state values or session details, so no-referrer there is reasonable. Browsers default to strict-origin-when-cross-origin when the header is absent.
Cache-Control
no-store tells browsers and shared caches not to keep a copy. Sign-in pages, token responses and pages with personal data should send it, so a shared computer’s back button or a proxy cannot reveal them later.
Headers you can drop
X-XSS-Protection: controlled a cross-site scripting filter that current browsers have removed. It does nothing in them, and in some old browsers the filter itself caused problems. Send0or leave it out, and rely on CSP.ServerandX-Powered-Bywith versions: not a vulnerability on their own, but they tell an attacker which known bugs to try. Remove versions where your server allows it.Expect-CT: certificate transparency is now enforced by browsers without it, and the header is deprecated.
Security headers on a Keycloak sign-in page
Keycloak sends several security headers itself, configured per realm under Realm settings, Security defenses, Headers. The defaults are a sensible start:
X-Frame-Options: SAMEORIGIN
Content-Security-Policy: frame-src 'self'; frame-ancestors 'self'; object-src 'none';
X-Content-Type-Options: nosniff
X-Robots-Tag: none
X-XSS-Protection: 1; mode=block
Strict-Transport-Security: max-age=31536000; includeSubDomains
Referrer-Policy: no-referrerThis page loads with a sample response built from these defaults, so you can see what the analyzer makes of them: framing is limited, HSTS and nosniff are set, and the CSP is narrow but has no default-src or script-src, so it does not restrict scripts.
What to adjust
- If another of your sites must embed Keycloak pages in a frame, change
frame-ancestorsto list that site, and keepX-Frame-Optionsconsistent. Do not remove framing protection altogether. - Consider
X-XSS-Protection: 0, the current advice. - HSTS reaches the browser only over HTTPS. Behind a reverse proxy, make sure the proxy does not strip it, or set it at the proxy.
Headers added at the proxy
A reverse proxy in front of Keycloak can add headers Keycloak does not send, such as Permissions-Policy or Cross-Origin-Opener-Policy. Avoid sending a second, different Content-Security-Policy: browsers enforce every CSP header they receive, so two policies combine to the stricter of both and can break the login pages.
What this analyzer does and does not do
- It parses pasted headers, ignoring status lines and the
<and>prefixes ofcurl -voutput. If several responses are pasted, it checks the last one. - It checks HSTS, CSP, framing, nosniff, Referrer-Policy, Cache-Control, COOP and Permissions-Policy, and notes deprecated or revealing headers.
- It sorts findings into things to fix, things to improve and notes.
- It does not fetch your site. Browsers do not let one page read another site’s headers, and we do not want your URLs.
- It checks only the response you paste. Different pages, such as the sign-in page and an API endpoint, can send different headers.
How to check your headers
- Fetch the headers of the page you care about, ideally a real sign-in page.
- Paste them into the analyzer.
- Fix the red findings first: missing HSTS, a CSP that allows any script, unprotected framing.
- Then improve the amber ones and read the notes.
- Change the headers at the application or proxy, fetch again and paste the new response.
curl -sI https://auth.example.com/realms/acme/account
curl -sD - -o /dev/null https://auth.example.com/realms/acme/protocol/openid-connect/auth?client_id=accountCommon mistakes
- Setting HSTS on HTTP responses only. Browsers ignore it there; it must come over HTTPS.
- A CSP with
'unsafe-inline'for scripts and no nonce, which looks protective but stops little. - Removing
X-Frame-Optionsto allow one partner to frame a page, instead of listing the partner inframe-ancestors. - Headers set by the application but stripped or duplicated by a proxy or CDN.
- Checking only the home page while the sign-in and API pages send different headers.