<?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>Homelab &#8211; Armand IT</title>
	<atom:link href="https://www.armandit.com/tag/homelab/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 22:36:34 +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>Homelab &#8211; Armand IT</title>
	<link>https://www.armandit.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How I Use Pi-hole to Keep My Kids Safe Online (and Kill Ads in Their Games)</title>
		<link>https://www.armandit.com/2026/11/29/pi-hole-kids-safe-network/</link>
		
		<dc:creator><![CDATA[Armand Hatting]]></dc:creator>
		<pubDate>Sun, 29 Nov 2026 22:36:34 +0000</pubDate>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Ad Blocking]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[Homelab]]></category>
		<category><![CDATA[Parental Controls]]></category>
		<category><![CDATA[Pi-hole]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<guid isPermaLink="false">https://www.armandit.com/?p=789</guid>

					<description><![CDATA[A Raspberry Pi with Pi-hole blocks ads in mobile games, adult content, gambling and DNS bypass for every device in the house. My strict-by-default setup, the blocklists I use, test results, and what DNS filtering can't do.]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Anyone with kids and a tablet knows the drill: a free game, and every thirty seconds an ad. Sometimes for another game, sometimes for something you really don&#8217;t want your kids to see. Add websites that are one tap away from an innocent search, and apps that quietly phone home to a dozen tracking companies.</p>



<p class="wp-block-paragraph">At home I solve most of this with one small device: a <strong>Pi-hole</strong> on a Raspberry Pi. In this post I&#8217;ll show exactly how it&#8217;s set up, what it blocks (I tested it), and just as important, what it <em>can&#8217;t</em> do.</p>



<h2 class="wp-block-heading">What Pi-hole does</h2>



<p class="wp-block-paragraph">Every device on your network constantly looks up names: before a game can show an ad from <code>ads.example-network.com</code>, it has to ask a DNS server for that name&#8217;s IP address. Pi-hole <em>is</em> that DNS server. It answers normally for everything, except for names on its blocklists. For those it answers <code>0.0.0.0</code>: nowhere. The ad never loads, the tracker never reports, the website never opens.</p>



<p class="wp-block-paragraph">Because it works at the network level, it protects every device at once: tablets, phones, consoles, smart TVs, without installing anything on them. And it works inside apps and games, where browser ad blockers can&#8217;t reach.</p>



<h2 class="wp-block-heading">My setup</h2>



<ul class="wp-block-list">
<li><strong>Hardware:</strong> a Raspberry Pi 3 B+ (yes, from 2018). With over 600,000 blocked domains it uses about 16% of its memory and is bored most of the day.</li>

<li><strong>Software:</strong> Pi-hole v6, forwarding allowed lookups to Cloudflare (<code>1.1.1.1</code>).</li>

<li><strong>Network:</strong> the router hands out the Pi-hole as the only DNS server, so every device uses it automatically.</li>

<li><strong>Privacy:</strong> query logging is switched off. I want to filter, not to read along with what my family does online.</li>
</ul>



<h2 class="wp-block-heading">The key idea: strict by default</h2>



<p class="wp-block-paragraph">Pi-hole can apply different blocklists to different groups of devices. Most guides set up a special group for the kids&#8217; devices. I did it the other way around:</p>



<ul class="wp-block-list">
<li><strong>Every device Pi-hole doesn&#8217;t know</strong> lands in the <em>Default</em> group, which gets the strictest filtering.</li>

<li><strong>The adults&#8217; own devices</strong> are added by name to a lighter group that only blocks ads and trackers.</li>
</ul>



<p class="wp-block-paragraph">Why this way? Because the risky devices are exactly the ones you forget: a new tablet from a birthday, a friend&#8217;s phone, a console, a smart TV. And modern phones and tablets use a <em>private Wi-Fi address</em> that differs from the hardware address, so you can&#8217;t reliably recognize a device anyway. With strict-by-default, anything new is protected from the first minute, and only devices I consciously add get more freedom.</p>



<figure class="wp-block-table"><table><thead><tr><th>Group</th><th>Who</th><th>Blocklists</th></tr></thead><tbody><tr><td>Default (strict)</td><td>Every unknown device: kids&#8217; tablets and consoles, guests, new devices</td><td>StevenBlack hosts, HaGeZi Ultimate, HaGeZi NSFW, HaGeZi Gambling, HaGeZi DNS bypass, and YouTube</td></tr><tr><td>Normal</td><td>The adults&#8217; named devices</td><td>HaGeZi Multi (ads, trackers, malware)</td></tr></tbody></table></figure>



<h2 class="wp-block-heading">The blocklists</h2>



<p class="wp-block-paragraph">All lists except one come from <a href="https://github.com/hagezi/dns-blocklists" target="_blank" rel="noopener">HaGeZi&#8217;s DNS blocklists</a>: well maintained, updated several times a day, and with very few false positives.</p>



<ul class="wp-block-list">
<li><strong>StevenBlack hosts</strong> and <strong>HaGeZi Ultimate</strong>: ads, trackers, malware and phishing. Ultimate is HaGeZi&#8217;s most aggressive level, and it&#8217;s what catches the ad networks inside games.</li>

<li><strong>HaGeZi NSFW</strong>: adult content.</li>

<li><strong>HaGeZi Gambling (medium)</strong>: casinos and betting, including the Dutch ones. The full list is seven times bigger; medium covers everything I tested and keeps the Pi fast.</li>

<li><strong>HaGeZi DoH/VPN/Proxy bypass</strong>: encrypted DNS services, VPNs and proxies. More on why below.</li>
</ul>



<p class="wp-block-paragraph">Adding them is a matter of pasting the URL under <em>Lists</em> in the Pi-hole interface, assigning the right groups and running <em>Update Gravity</em>:</p>



<pre class="wp-block-code language-none"><code>https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/adblock/ultimate.txt
https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/adblock/nsfw.txt
https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/adblock/gambling.medium.txt
https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/adblock/doh-vpn-proxy-bypass.txt</code></pre>



<p class="wp-block-paragraph">YouTube is blocked for the strict group with two regex rules under <em>Domains</em>, so it doesn&#8217;t become an endless video feed on the kids&#8217; devices:</p>



<pre class="wp-block-code language-none"><code>(\.|^)youtube\.com$
(\.|^)googlevideo\.com$</code></pre>



<h2 class="wp-block-heading">Ads in mobile games</h2>



<p class="wp-block-paragraph">Free games earn money through advertising SDKs: libraries from ad networks that fetch ads from the network&#8217;s own servers. Those servers have recognizable names, and that is exactly what DNS blocking is good at. I tested the big ones from a device in the strict group:</p>



<figure class="wp-block-table"><table><thead><tr><th>Ad network</th><th>Used in</th><th>Result</th></tr></thead><tbody><tr><td>Google AdMob</td><td>A huge share of Android and iOS games</td><td>&#10003; Blocked</td></tr><tr><td>Unity Ads</td><td>Games built with Unity</td><td>&#10003; Blocked</td></tr><tr><td>AppLovin</td><td>Many casual and puzzle games</td><td>&#10003; Blocked</td></tr><tr><td>ironSource</td><td>Mobile games, ad mediation</td><td>&#10003; Blocked</td></tr><tr><td>Vungle (Liftoff)</td><td>Video ads in games</td><td>&#10003; Blocked</td></tr><tr><td>Chartboost</td><td>Ads for other games</td><td>&#10003; Blocked</td></tr><tr><td>InMobi</td><td>Mobile ads</td><td>&#10003; Blocked</td></tr><tr><td>Meta Audience Network</td><td>Ads in apps</td><td>&#10003; Blocked</td></tr><tr><td>Adjust, Branch, Firebase Analytics</td><td>Tracking and attribution</td><td>&#10003; Blocked</td></tr></tbody></table></figure>



<p class="wp-block-paragraph">Before I added the stricter lists, the lighter ads-only list let Vungle, Chartboost, InMobi and Adjust through. The difference between blocklists is real, so test with the networks that matter to you.</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>What your kids will notice</strong> Games with <em>rewarded ads</em> (&#8220;watch a video for 50 extra coins&#8221;) will say no ad is available. Most games simply carry on; the occasional game refuses to work without its ad server. For those you can allow a single domain, which you find in Pi-hole&#8217;s query log (temporarily switch logging on while testing).</p>
</div>



<h2 class="wp-block-heading">Results: what is blocked and what still works</h2>



<figure class="wp-block-table"><table><thead><tr><th>Category</th><th>Tested with</th><th>Strict group</th></tr></thead><tbody><tr><td>Game ads</td><td>AdMob, Unity Ads, AppLovin, ironSource, Vungle, Chartboost, InMobi</td><td>&#10003; Blocked</td></tr><tr><td>Adult content</td><td>Large adult websites</td><td>&#10003; Blocked</td></tr><tr><td>Gambling</td><td>International and Dutch casino and betting sites</td><td>&#10003; Blocked</td></tr><tr><td>DNS bypass</td><td>Google, Cloudflare, Quad9 and OpenDNS encrypted DNS</td><td>&#10003; Blocked</td></tr><tr><td>YouTube</td><td>youtube.com</td><td>&#10003; Blocked</td></tr><tr><td>Games and stores</td><td>Roblox, Minecraft, Nintendo, PlayStation, App Store, Play Store</td><td>Works</td></tr><tr><td>School and info</td><td>Wikipedia</td><td>Works</td></tr></tbody></table></figure>



<p class="wp-block-paragraph">You can test this yourself from any computer: ask your Pi-hole directly and look at the answer. <code>0.0.0.0</code> means blocked.</p>



<pre class="wp-block-code language-bash"><code>nslookup googleads.g.doubleclick.net 192.168.0.37
nslookup www.roblox.com 192.168.0.37</code></pre>



<h2 class="wp-block-heading">Why block encrypted DNS?</h2>



<p class="wp-block-paragraph">Pi-hole only works if devices actually ask <em>it</em>. Browsers and apps increasingly use <strong>DNS over HTTPS</strong>: they send their lookups encrypted to Google or Cloudflare instead, straight past your Pi-hole. Sometimes that&#8217;s a setting a curious kid finds, sometimes the app does it on its own.</p>



<p class="wp-block-paragraph">The bypass list blocks the names of those encrypted DNS services, plus well-known VPN and proxy services. Pi-hole also answers the special domains that Firefox and Apple&#8217;s iCloud Private Relay check first, so those fall back to normal DNS by themselves.</p>



<h2 class="wp-block-heading">What Pi-hole can&#8217;t do</h2>



<p class="wp-block-paragraph">DNS filtering is a strong first layer, not complete parental control. Be honest with yourself about the gaps:</p>



<ul class="wp-block-list">
<li><strong>Mobile data:</strong> on 4G or 5G a phone doesn&#8217;t use your home network at all. Use the parental controls built into the device (Screen Time on iOS, Google Family Link on Android) for phones that leave the house.</li>

<li><strong>Hard-coded DNS servers:</strong> a device can ask <code>8.8.8.8</code> directly by IP address, and no blocklist stops that. Close that gap in your router: only allow DNS traffic (port 53, and port 853 for DNS over TLS) to the Pi-hole.</li>

<li><strong>Content inside allowed apps:</strong> chat in an online game, or a video inside an app that is allowed, can&#8217;t be filtered by name. Age settings in the game or platform matter there.</li>

<li><strong>Ads from the same domain as the content:</strong> some platforms serve ads from their own servers. DNS can&#8217;t separate those from the content without blocking both.</li>
</ul>



<p class="wp-block-paragraph">And the most important layer isn&#8217;t technical at all: talking with your kids about what they see online. The Pi-hole just makes sure those conversations are about the exceptions instead of every thirty seconds.</p>



<h2 class="wp-block-heading">Getting started</h2>



<ol class="wp-block-list">
<li>Install Pi-hole on a Raspberry Pi (any model from the 3 onwards is enough) or in a container, following the <a href="https://docs.pi-hole.net/" target="_blank" rel="noopener">official documentation</a>.</li>

<li>Set the Pi-hole as the only DNS server in your router&#8217;s DHCP settings.</li>

<li>Add the strict blocklists to the <em>Default</em> group.</li>

<li>Create a lighter group for the adults&#8217; devices and add those devices by name under <em>Clients</em>.</li>

<li>Run <em>Update Gravity</em> and test with <code>nslookup</code>, from a device in each group.</li>

<li>In the router, block outgoing DNS that doesn&#8217;t come from the Pi-hole.</li>
</ol>
]]></content:encoded>
					
		
		
			</item>
		<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>
