After rebuilding this blog I ran it through MDN Observatory, Mozilla’s free website security scanner. The result: a C, 50 out of 100. For a blog that writes about security, that stung a bit. An evening later it scored A+, 135 out of 100, and I hardened the two other sites on my homelab cluster along the way.
In this post: what the scan actually measures, why those things matter, how I fixed them (including two gotchas that cost me most of the time), and where a score stops telling you anything useful.
Live results
These grades are fetched live from the Observatory API, so they stay up to date. The same badge sits in the footer of every page on this site.
| Site | Grade | Score | Tests passed | Last scan |
|---|---|---|---|---|
| www.armandit.com | A+ | 135/100 | 12 / 12 | 29 Nov 2026 |
| fps.armandit.com | A+ | 145/100 | 12 / 12 | 29 Nov 2026 |
| crm.armandit.com | B | 70/100 | 10 / 12 | 29 Nov 2026 |
What MDN Observatory checks
Observatory requests your homepage and looks at the HTTP response: the security headers, cookies, redirects and how scripts are loaded. Every site starts at 100 points; missing protections cost points and strong configurations earn bonus points, which is why a score above 100 is possible. The grade follows from the score.
It does not scan for vulnerabilities in your application, outdated plugins or weak passwords. It measures one thing: how much the browser is instructed to protect your visitors. That makes it narrow, but also cheap to fix and easy to verify.
Why security headers matter
Security headers are instructions from your server to the visitor’s browser. They don’t fix bugs in your code, but they shrink what an attacker can do when something does go wrong. That is defence in depth: if a plugin has a cross-site scripting hole, a good Content-Security-Policy can still stop the injected script from running.
| Header | Protects against | What I use |
|---|---|---|
Content-Security-Policy | Cross-site scripting and data injection: only scripts you approve may run | Per-request nonce for scripts, object-src 'none', frame-ancestors 'self' |
Strict-Transport-Security | Downgrade to HTTP and SSL stripping | 6 months, set at Cloudflare |
X-Frame-Options | Clickjacking: your site loaded invisibly inside someone else’s page | SAMEORIGIN |
X-Content-Type-Options | MIME sniffing: a file served as text being executed as script | nosniff |
Referrer-Policy | Leaking full URLs (with paths and query strings) to other sites | strict-origin-when-cross-origin |
Cross-Origin-Opener-Policy | Other windows keeping a handle on your page; cross-origin leaks | same-origin |
Cross-Origin-Resource-Policy | Other sites loading your resources to probe them | same-origin for HTML pages |
Permissions-Policy | Pages or embeds quietly using camera, microphone or location | All denied |
None of this costs performance, and for a static-ish site most of it is a one-time change. That is the real argument: few security measures have a better effort-to-value ratio.
Before and after
| Site | What it is | Before | After |
|---|---|---|---|
| www.armandit.com | This blog (WordPress) | C (50) | A+ (135) |
| fps.armandit.com | Firewall Policy Studio, a static web app | A+ (125) | A+ (145) |
| crm.armandit.com | SuiteCRM behind Microsoft Entra ID sign-in | B− (65) | B (70) |
Gotcha 1: the headers were there, until the cache answered
The strange part: my WordPress hardening plugin did send X-Frame-Options and friends. Testing a fresh page showed them. Observatory didn’t see them, because it got a page from the page cache, and the cache plugin serves stored pages before WordPress runs the hook that adds the headers.
The fix is to set static headers at the web server, not in the application. Then every response gets them: cached pages, images, CSS, error pages. In Apache (with mod_headers enabled):
<IfModule mod_headers.c>
Header always set X-Content-Type-Options "nosniff"
Header always set X-Frame-Options "SAMEORIGIN"
Header always set Referrer-Policy "strict-origin-when-cross-origin"
Header always set Permissions-Policy "camera=(), microphone=(), geolocation=(), payment=(), usb=()"
Header always set Cross-Origin-Opener-Policy "same-origin"
Header always set Cross-Origin-Resource-Policy "same-origin" "expr=%{CONTENT_TYPE} =~ m#^text/html#"
Header always unset X-Powered-By
</IfModule>
The same in nginx, inside the server block. Remember that a location with its own add_header stops inheriting these:
server_tokens off;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header Cross-Origin-Resource-Policy "same-origin" always;
Gotcha 2: a real Content-Security-Policy for WordPress
The CSP was worth the most points (25) and is the hardest to get right. Allowing 'unsafe-inline' scripts would be easy, but it defeats the purpose: injected scripts are inline too. The proper way is a nonce: a random value, new for every request, that the header announces and every legitimate script tag carries.
WordPress has filters for exactly this: wp_script_attributes and wp_inline_script_attributes run for every script WordPress prints itself. The cache is the complication again: a cached page contains the nonce of the request that created it. My solution puts a placeholder in the script tags and swaps it for the fresh nonce on the way out, so cached pages stay valid:
$nonce = base64_encode( random_bytes( 18 ) );
header( "Content-Security-Policy: default-src 'self'; script-src 'self' 'nonce-$nonce'; "
. "style-src 'self' 'unsafe-inline'; object-src 'none'; base-uri 'self'; "
. "frame-ancestors 'self'; form-action 'self'" );
$add_nonce = function ( $attributes ) {
$attributes['nonce'] = '__CSP_NONCE__';
return $attributes;
};
add_filter( 'wp_script_attributes', $add_nonce );
add_filter( 'wp_inline_script_attributes', $add_nonce );
ob_start( fn( $html ) => str_replace( '__CSP_NONCE__', $nonce, $html ) );
This runs in a must-use plugin, early enough to also cover pages served from the cache. Inline styles are still allowed, because block themes rely on them; Observatory accepts that without a penalty. Admin pages and logged-in users are skipped, so the editor keeps working.
Test in a real browser, not just with a scanner A scanner only reads headers. Whether the CSP breaks something only shows in the browser: open DevTools, reload, and look for Refused to load or violates the following Content Security Policy directive in the console. I checked every page type (home, posts, search, archives) that way before calling it done.
Cookies: the Secure flag
On the CRM, Observatory flagged a cookie without the Secure flag, which means a browser could send it over plain HTTP. The application sets it somewhere deep in its framework, so rather than patching vendor code I added a small hook that runs right before PHP sends its headers and adds Secure to every cookie on HTTPS:
header_register_callback( static function () {
if ( ( $_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '' ) !== 'https' ) {
return;
}
$cookies = array_filter( headers_list(), fn( $h ) => stripos( $h, 'Set-Cookie:' ) === 0 );
if ( ! $cookies ) {
return;
}
header_remove( 'Set-Cookie' );
foreach ( $cookies as $cookie ) {
header( preg_match( '/;\s*secure\b/i', $cookie ) ? $cookie : "$cookie; Secure", false );
}
} );
Loaded with auto_prepend_file, it works regardless of which part of the application sets the cookie, and it survives upgrades.
Where a score stops being useful
The CRM ends at a B, and that’s fine. It uses single sign-on, so visiting it redirects straight to Microsoft’s sign-in page, and Observatory grades the last page in the redirect chain. The remaining findings belong to login.microsoftonline.com. My own responses now carry every header and secure cookies; the rest isn’t mine to fix.
The lesson: read the individual findings, not just the grade. And don’t add headers only for points. Cross-Origin-Embedder-Policy, for example, would break embedded videos and earns nothing.
Check your own site in five minutes
- Scan it at developer.mozilla.org/observatory.
- Look at the raw headers yourself (example below).
- Set the static headers at the web server or reverse proxy, so cached pages and files get them too.
- Add a CSP, start strict, and test every page type in the browser console.
- Rescan, and repeat after major changes: new plugins, embeds or analytics will need CSP adjustments.
curl -sI https://www.example.com | grep -iE 'content-security|strict-transport|x-frame|x-content-type|referrer|permissions|cross-origin|set-cookie'
