<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Luuk Verhoeven on Medium]]></title>
        <description><![CDATA[Stories by Luuk Verhoeven on Medium]]></description>
        <link>https://medium.com/@luukverhoeven?source=rss-b2ce5ba121a2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*M-gtnMrXDqIJpe27wqBOow.jpeg</url>
            <title>Stories by Luuk Verhoeven on Medium</title>
            <link>https://medium.com/@luukverhoeven?source=rss-b2ce5ba121a2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 23:05:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@luukverhoeven/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Moodle’s login 302 is where your security headers go to die]]></title>
            <link>https://medium.com/@luukverhoeven/moodles-login-302-is-where-your-security-headers-go-to-die-a9f5b036308a?source=rss-b2ce5ba121a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9f5b036308a</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[moodle]]></category>
            <dc:creator><![CDATA[Luuk Verhoeven]]></dc:creator>
            <pubDate>Tue, 17 Nov 2026 12:42:54 GMT</pubDate>
            <atom:updated>2026-11-17T12:42:54.950Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*F06SYxuvuZshTBcI.png" /></figure><p>A scanner reports that https://lms.example.org has no Strict-Transport-Security header. You curl the homepage. The header is there. You argue with the finding. The scanner is still right.</p><p>Moodle™ sends almost every anonymous visitor to /login/index.php. That URL answers with a redirect more often than a 200. nginx&#39;s add_header does not copy onto that redirect unless you say always. The scanner follows the 302, records an empty header set, and files a finding you cannot close by pointing at the homepage.</p><p>This is the check I run before I believe any LMS header report.</p><pre>curl -sI https://lms.example.org/ curl -sI https://lms.example.org/login/index.php curl -sI https://lms.example.org/this-path-does-not-exist</pre><p>You want a 200, a 302/303, and a 404. Print only the security headers:</p><p>Typical Moodle-behind-nginx result:</p><ul><li>/ - 200, full header set.</li><li>/login/index.php - 303 to itself with a cookie, or 302 to /, <strong>no</strong> Strict-Transport-Security.</li><li>a missing course URL — 404 from Moodle’s theme, headers present or not depending on whether PHP or nginx wrote the response.</li></ul><p>A Qualys / Mozilla Observatory / commercial scanner that “follows redirects” scores the 303. That is the page a student actually hits on Monday morning.</p><p>add_header in nginx is inherited in a way people do not expect. From the <a href="https://nginx.org/en/docs/http/ngx_http_headers_module.html">nginx docs</a>: there can be several add_header directives. They are inherited from the previous configuration level <strong>if and only if</strong> there are no add_header directives defined on the current level. And without always, they are added only to responses whose status is 200, 201, 204, 206, 301, 302, 303, 304, 307 or 308 - wait, 302 and 303 are in that list.</p><p>So why do LMS redirects still drop them?</p><p>Because the 303 is often not nginx’s redirect. It is PHP. Moodle calls redirect() which sends Location from php-fpm. For nginx, that is a <strong>proxied 303</strong>. add_header without always is not added to proxied error and redirect responses in every version/build people still run, and more importantly: if the php location block has its own add_header (a CORS line, an X-Powered-By wipe), it <strong>replaces</strong> the server-level set instead of merging with it.</p><p>The reliable form is:</p><pre># in http, server, or the php location - same three lines, with always add_header Strict-Transport-Security &quot;max-age=31536000; includeSubDomains&quot; always; add_header X-Content-Type-Options &quot;nosniff&quot; always; add_header Referrer-Policy &quot;strict-origin-when-cross-origin&quot; always;</pre><p>Apache’s equivalent is Header always set, not Header set. The word always is doing the same job: attach the header to non-200 responses, including the ones PHP generated.</p><p>A few Moodle-specific traps:</p><ol><li><strong>$CFG-&gt;sslproxy = true;</strong> when TLS terminates on the load balancer. Moodle then emits http:// URLs internally unless wwwroot is https. HSTS on the edge and mixed-content in the page fight each other.</li><li><strong>Login HTTPS redirect</strong> in Site administration → Security → HTTP security. That setting issues the 303. It does not issue HSTS. Those are different layers.</li><li><strong>Additional HTML</strong> in the theme. A tag manager on the login page does not remove HSTS, but it is why people later delete a Content-Security-Policy. HSTS stays; CSP dies. Scanners report both as “headers”.</li><li><strong>A plugin that calls </strong><strong>header().</strong> Some local plugins send X-Frame-Options from PHP. PHP headers and nginx headers for the same name: the PHP one usually wins on that response. The plugin is uninstalled a year later. The nginx line is still there. The PHP line is gone. The portal that framed the quiz breaks, and someone comments out the nginx line &quot;to fix login&quot;.</li></ol><p>Terminate TLS once. Set HSTS, X-Content-Type-Options and Referrer-Policy on the reverse proxy with always. Do not also set them in PHP. Two writers for the same header is how they vanish after a plugin change.</p><p>Content-Security-Policy and frame-ancestors are different. They have to know about H5P, LTI and the HTML editor. Those belong in a config you can version, after you have inventoried the origins a real course page loads. Putting a strict CSP on the proxy the same afternoon you add HSTS will take the quiz down.</p><p>Permissions-Policy is the one exam vendors trip over. A policy that disables camera and microphone globally will fail a remote-proctoring launch. Name the proctor origin, or leave those features out of the policy until you have the vendor list.</p><p>Certificate renewal, a WAF in front of nginx, a move from Apache to nginx, a new location ~ \.php$ block: each one is a chance to lose always. Re-run the three-URL loop on staging, then on production, and keep the output. A pentest PDF from March does not prove the 303 in November still carries HSTS.</p><p>I built <a href="https://guardlms.com/">GuardLMS</a> to notice when those three responses stop matching. The curls above are still the first thing I run on a host I have not seen before.</p><p><em>Originally published at </em><a href="https://gist.github.com/luukverhoeven/01716047b08c33386701559b13f41952"><em>http://github.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9f5b036308a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>