<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WordPress &#8211; Armand IT</title>
	<atom:link href="https://www.armandit.com/tag/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.armandit.com</link>
	<description>Azure at work, Kubernetes at home</description>
	<lastBuildDate>Sun, 29 Nov 2026 21:53:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.5</generator>

<image>
	<url>https://www.armandit.com/wp-content/uploads/2026/11/armandit-icon-512-32x32.png</url>
	<title>WordPress &#8211; Armand IT</title>
	<link>https://www.armandit.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>From C to A+: Why Security Headers Matter (and How I Fixed Mine)</title>
		<link>https://www.armandit.com/2026/11/29/security-headers-mdn-observatory/</link>
		
		<dc:creator><![CDATA[Armand Hatting]]></dc:creator>
		<pubDate>Sun, 29 Nov 2026 21:52:02 +0000</pubDate>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Content Security Policy]]></category>
		<category><![CDATA[Homelab]]></category>
		<category><![CDATA[MDN Observatory]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[Security Headers]]></category>
		<category><![CDATA[WordPress]]></category>
		<guid isPermaLink="false">https://www.armandit.com/?p=777</guid>

					<description><![CDATA[MDN Observatory gave this blog a C. What the scan measures, why security headers matter, and how I got three sites to A+ and B, including a CSP with nonces for WordPress and two gotchas.]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">After rebuilding this blog I ran it through <a href="https://developer.mozilla.org/en-US/observatory" target="_blank" rel="noopener">MDN Observatory</a>, Mozilla&#8217;s free website security scanner. The result: a <strong>C</strong>, 50 out of 100. For a blog that writes about security, that stung a bit. An evening later it scored <strong>A+</strong>, 135 out of 100, and I hardened the two other sites on my homelab cluster along the way.</p>



<p class="wp-block-paragraph">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.</p>



<h2 class="wp-block-heading">Live results</h2>



<p class="wp-block-paragraph">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.</p>


<figure class="wp-block-table obs-table"><table><thead><tr><th>Site</th><th>Grade</th><th>Score</th><th>Tests passed</th><th>Last scan</th></tr></thead><tbody><tr><td><a href="https://developer.mozilla.org/en-US/observatory/analyze?host=www.armandit.com" target="_blank" rel="noopener">www.armandit.com</a></td><td><span class="obs-grade obs-grade-a">A+</span></td><td>135/100</td><td>12 / 12</td><td>29 Nov 2026</td></tr><tr><td><a href="https://developer.mozilla.org/en-US/observatory/analyze?host=fps.armandit.com" target="_blank" rel="noopener">fps.armandit.com</a></td><td><span class="obs-grade obs-grade-a">A+</span></td><td>145/100</td><td>12 / 12</td><td>29 Nov 2026</td></tr><tr><td><a href="https://developer.mozilla.org/en-US/observatory/analyze?host=crm.armandit.com" target="_blank" rel="noopener">crm.armandit.com</a></td><td><span class="obs-grade obs-grade-b">B</span></td><td>70/100</td><td>10 / 12</td><td>29 Nov 2026</td></tr></tbody></table><figcaption>Live results from the MDN Observatory API, refreshed every 12 hours.</figcaption></figure>



<h2 class="wp-block-heading">What MDN Observatory checks</h2>



<p class="wp-block-paragraph">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.</p>



<p class="wp-block-paragraph">It does not scan for vulnerabilities in your application, outdated plugins or weak passwords. It measures one thing: how much the <em>browser</em> is instructed to protect your visitors. That makes it narrow, but also cheap to fix and easy to verify.</p>



<h2 class="wp-block-heading">Why security headers matter</h2>



<p class="wp-block-paragraph">Security headers are instructions from your server to the visitor&#8217;s browser. They don&#8217;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.</p>



<figure class="wp-block-table"><table><thead><tr><th>Header</th><th>Protects against</th><th>What I use</th></tr></thead><tbody><tr><td><code>Content-Security-Policy</code></td><td>Cross-site scripting and data injection: only scripts you approve may run</td><td>Per-request nonce for scripts, <code>object-src 'none'</code>, <code>frame-ancestors 'self'</code></td></tr><tr><td><code>Strict-Transport-Security</code></td><td>Downgrade to HTTP and SSL stripping</td><td>6 months, set at Cloudflare</td></tr><tr><td><code>X-Frame-Options</code></td><td>Clickjacking: your site loaded invisibly inside someone else&#8217;s page</td><td><code>SAMEORIGIN</code></td></tr><tr><td><code>X-Content-Type-Options</code></td><td>MIME sniffing: a file served as text being executed as script</td><td><code>nosniff</code></td></tr><tr><td><code>Referrer-Policy</code></td><td>Leaking full URLs (with paths and query strings) to other sites</td><td><code>strict-origin-when-cross-origin</code></td></tr><tr><td><code>Cross-Origin-Opener-Policy</code></td><td>Other windows keeping a handle on your page; cross-origin leaks</td><td><code>same-origin</code></td></tr><tr><td><code>Cross-Origin-Resource-Policy</code></td><td>Other sites loading your resources to probe them</td><td><code>same-origin</code> for HTML pages</td></tr><tr><td><code>Permissions-Policy</code></td><td>Pages or embeds quietly using camera, microphone or location</td><td>All denied</td></tr></tbody></table></figure>



<p class="wp-block-paragraph">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.</p>



<h2 class="wp-block-heading">Before and after</h2>



<figure class="wp-block-table"><table><thead><tr><th>Site</th><th>What it is</th><th>Before</th><th>After</th></tr></thead><tbody><tr><td>www.armandit.com</td><td>This blog (WordPress)</td><td>C (50)</td><td><strong>A+ (135)</strong></td></tr><tr><td>fps.armandit.com</td><td>Firewall Policy Studio, a static web app</td><td>A+ (125)</td><td><strong>A+ (145)</strong></td></tr><tr><td>crm.armandit.com</td><td>SuiteCRM behind Microsoft Entra ID sign-in</td><td>B&minus; (65)</td><td><strong>B (70)</strong></td></tr></tbody></table></figure>



<h2 class="wp-block-heading">Gotcha 1: the headers were there, until the cache answered</h2>



<p class="wp-block-paragraph">The strange part: my WordPress hardening plugin <em>did</em> send <code>X-Frame-Options</code> and friends. Testing a fresh page showed them. Observatory didn&#8217;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.</p>



<p class="wp-block-paragraph">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 <code>mod_headers</code> enabled):</p>



<pre class="wp-block-code language-none"><code>&lt;IfModule mod_headers.c&gt;
  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
&lt;/IfModule&gt;</code></pre>



<p class="wp-block-paragraph">The same in nginx, inside the <code>server</code> block. Remember that a <code>location</code> with its own <code>add_header</code> stops inheriting these:</p>



<pre class="wp-block-code language-none"><code>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;</code></pre>



<h2 class="wp-block-heading">Gotcha 2: a real Content-Security-Policy for WordPress</h2>



<p class="wp-block-paragraph">The CSP was worth the most points (25) and is the hardest to get right. Allowing <code>'unsafe-inline'</code> scripts would be easy, but it defeats the purpose: injected scripts are inline too. The proper way is a <strong>nonce</strong>: a random value, new for every request, that the header announces and every legitimate script tag carries.</p>



<p class="wp-block-paragraph">WordPress has filters for exactly this: <code>wp_script_attributes</code> and <code>wp_inline_script_attributes</code> 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:</p>



<pre class="wp-block-code language-none"><code>$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 ) =&gt; str_replace( '__CSP_NONCE__', $nonce, $html ) );</code></pre>



<p class="wp-block-paragraph">This runs in a must-use plugin, early enough to also cover pages served from the cache. Inline <em>styles</em> 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.</p>



<div class="wp-block-group is-style-callout-warning has-global-padding is-layout-constrained wp-block-group-is-layout-constrained">
<p class="wp-block-paragraph"><strong>Test in a real browser, not just with a scanner</strong> A scanner only reads headers. Whether the CSP breaks something only shows in the browser: open DevTools, reload, and look for <em>Refused to load</em> or <em>violates the following Content Security Policy directive</em> in the console. I checked every page type (home, posts, search, archives) that way before calling it done.</p>
</div>



<h2 class="wp-block-heading">Cookies: the Secure flag</h2>



<p class="wp-block-paragraph">On the CRM, Observatory flagged a cookie without the <code>Secure</code> 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 <code>Secure</code> to every cookie on HTTPS:</p>



<pre class="wp-block-code language-none"><code>header_register_callback( static function () {
    if ( ( $_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '' ) !== 'https' ) {
        return;
    }
    $cookies = array_filter( headers_list(), fn( $h ) =&gt; 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 );
    }
} );</code></pre>



<p class="wp-block-paragraph">Loaded with <code>auto_prepend_file</code>, it works regardless of which part of the application sets the cookie, and it survives upgrades.</p>



<h2 class="wp-block-heading">Where a score stops being useful</h2>



<p class="wp-block-paragraph">The CRM ends at a B, and that&#8217;s fine. It uses single sign-on, so visiting it redirects straight to Microsoft&#8217;s sign-in page, and Observatory grades the last page in the redirect chain. The remaining findings belong to <code>login.microsoftonline.com</code>. My own responses now carry every header and secure cookies; the rest isn&#8217;t mine to fix.</p>



<p class="wp-block-paragraph">The lesson: read the individual findings, not just the grade. And don&#8217;t add headers only for points. <code>Cross-Origin-Embedder-Policy</code>, for example, would break embedded videos and earns nothing.</p>



<h2 class="wp-block-heading">Check your own site in five minutes</h2>



<ol class="wp-block-list">
<li>Scan it at <a href="https://developer.mozilla.org/en-US/observatory" target="_blank" rel="noopener">developer.mozilla.org/observatory</a>.</li>

<li>Look at the raw headers yourself (example below).</li>

<li>Set the static headers at the web server or reverse proxy, so cached pages and files get them too.</li>

<li>Add a CSP, start strict, and test every page type in the browser console.</li>

<li>Rescan, and repeat after major changes: new plugins, embeds or analytics will need CSP adjustments.</li>
</ol>



<pre class="wp-block-code language-bash"><code>curl -sI https://www.example.com | grep -iE 'content-security|strict-transport|x-frame|x-content-type|referrer|permissions|cross-origin|set-cookie'</code></pre>



<h2 class="wp-block-heading">Sources and further reading</h2>

<ul class="wp-block-list">
<li><a href="https://developer.mozilla.org/en-US/observatory" target="_blank" rel="noopener">MDN Observatory</a></li>

<li><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP" target="_blank" rel="noopener">MDN: Content Security Policy (CSP)</a></li>

<li><a href="https://developer.mozilla.org/en-US/docs/Web/Security/Practical_implementation_guides" target="_blank" rel="noopener">MDN: Practical security implementation guides</a></li>

<li><a href="https://owasp.org/www-project-secure-headers/" target="_blank" rel="noopener">OWASP Secure Headers Project</a></li>
</ul>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
