<?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"><channel><title><![CDATA[LMS security notes]]></title><description><![CDATA[LMS security notes]]></description><link>https://luukverhoeven.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sun, 29 Nov 2026 22:38:43 GMT</lastBuildDate><atom:link href="https://luukverhoeven.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[$CFG->debugdisplay is how Moodle tells the internet your paths]]></title><description><![CDATA[Moodle debugdisplay prints PHP notices, SQL and absolute paths into the student HTML. Prove it from the public hostname and close it in config.php.]]></description><link>https://luukverhoeven.hashnode.dev/cfg-debugdisplay-is-how-moodle-tells-the-internet-your-paths</link><guid isPermaLink="true">https://luukverhoeven.hashnode.dev/cfg-debugdisplay-is-how-moodle-tells-the-internet-your-paths</guid><category><![CDATA[#moodle]]></category><category><![CDATA[PHP]]></category><category><![CDATA[Security]]></category><dc:creator><![CDATA[Luuk Verhoeven]]></dc:creator><pubDate>Wed, 18 Nov 2026 12:15:44 GMT</pubDate><content:encoded><![CDATA[<p>Moodle™ documents a development block in <code>config-dist.php</code> under “SETTINGS FOR DEVELOPMENT SERVERS - not intended for production use!!!”. Operators paste it onto a live vhost to chase one restore error, then leave it. The homepage still looks like Moodle. The HTML now contains PHP notices, SQL fragments, and absolute paths.</p>
<p><code>$CFG-&gt;debug</code> is how much Moodle logs. <code>$CFG-&gt;debugdisplay</code> is whether that text is printed into the page the student gets. The security report that only checks the admin tree misses a <code>config.php</code> override that wins over the GUI.</p>
<h2>What the two flags actually do</h2>
<p>From <code>config-dist.php</code> on Moodle 5.1:</p>
<pre><code class="language-php">// NOT FOR PRODUCTION SERVERS!
$CFG-&gt;debug = (E_ALL);   // === DEBUG_DEVELOPER
$CFG-&gt;debugdisplay = 1;
</code></pre>
<p>Site administration → Development → Debugging exposes the same pair as “Debug messages” and “Display debug messages”. Official guidance is: keep a record of errors, set debug to Normal if you must, and leave display <strong>off</strong>. Errors then go to the server log. Developer level on a public site is called out in the docs because the messages give away the setup.</p>
<p><code>$CFG-&gt;debugusers</code> is the narrower leftover: a comma-separated list of user ids that always see debug, even when the site flags are off. User id 2 is the primary admin on a default install. A list that still contains a teacher who left last year is a private debug channel on a shared account.</p>
<p>Whoops! pretty exceptions (<code>$CFG-&gt;debug_developer_use_pretty_exceptions</code>) only fire when Composer dev dependencies are present, debug+display are on, and the request is not CLI or AJAX. If you see the Whoops UI on production, you have a second problem: <code>vendor/</code> from a dev install is on the web host.</p>
<h2>Prove it from the public hostname</h2>
<p>You do not need a login for the first curl. A notice on <code>/login/index.php</code> or a missing slashargument is enough.</p>
<pre><code class="language-bash">HOST=https://lms.example.org

curl -sI "$HOST/login/index.php" | head
curl -s "$HOST/login/index.php" | grep -E -i 'warning|notice|deprecated|stack trace|www/moodle|/var/www|debugdisplay|whoops' | head
curl -s "$HOST/?whatever=1" | grep -E -i 'warning|notice|undefined|on line' | head
</code></pre>
<p>Empty grep is the pass. A path like <code>/var/www/moodle/lib/setup.php</code> or a table name from a plugin is the fail. Developer debug also dumps SQL on some pages. Do not paste that output into a ticket that leaves the organisation.</p>
<p>Then ask the process what it thinks, because the GUI can disagree with <code>config.php</code>:</p>
<pre><code class="language-bash">php -r 'define("CLI_SCRIPT", true); require "config.php";
echo "debug="; var_export($CFG-&gt;debug ?? null); echo "\n";
echo "debugdisplay="; var_export($CFG-&gt;debugdisplay ?? null); echo "\n";
echo "debugusers="; var_export($CFG-&gt;debugusers ?? null); echo "\n";
echo "themedesignermode="; var_export(!empty($CFG-&gt;themedesignermode)); echo "\n";
echo "cachejs="; var_export($CFG-&gt;cachejs ?? null); echo "\n";
'
</code></pre>
<p><code>debugdisplay</code> truthy plus <code>debug</code> at <code>E_ALL</code> is DEBUG_DEVELOPER. <code>themedesignermode</code> and <code>cachejs = false</code> are the same class of leftover: they belong on a theme box, not on the exam-week frontends.</p>
<p>If the CLI printout is clean and the HTML still has notices, you are not hitting that <code>config.php</code>. Extra vhost, extra PHP-FPM pool, opcache on an old file. Curl the public hostname <em>and</em> the origin.</p>
<h2>Close it in config.php, not only in the GUI</h2>
<p>Forced settings in <code>config.php</code> beat the admin tree. Comment the development block. Set the production pair explicitly so the next restore cannot “helpfully” turn display back on:</p>
<pre><code class="language-php">$CFG-&gt;debug = 0;          // DEBUG_NONE
$CFG-&gt;debugdisplay = 0;
</code></pre>
<p>Leave <code>display_errors</code> off in php.ini for the FPM pool that serves Moodle. Moodle’s own <code>@ini_set('display_errors', '1')</code> in the development block is the other switch. Server logs still get the notices if you set debug to Normal and display to 0. That is the combination the docs describe.</p>
<pre><code class="language-ini">; php-fpm pool for Moodle
display_errors = Off
log_errors = On
error_log = /var/log/php/moodle-error.log
</code></pre>
<p>Re-curl <code>/login/index.php</code> after you write the file. Purge opcache if the HTML does not change (<code>php -r 'opcache_reset();'</code> in a web-context script, or bounce php-fpm). A 5.1 <code>public/</code> document root does not change this. <code>config.php</code> still lives next to <code>$CFG-&gt;root</code>.</p>
<h2>The week after go-live</h2>
<p>A plugin zip that “needs developer debug to install” is a plugin bug. Do not leave DEBUG_DEVELOPER on overnight so the vendor can read a trace. Copy the message, turn the flags off, send the copy.</p>
<p>Re-run the greps after every <code>config.php</code> edit, after a theme designer session, after cloning production onto a test host that then got a public DNS name.</p>
<p>I built <a href="https://guardlms.com/en/moodle-security">GuardLMS</a> to notice when debug display comes back on a public Moodle. Disclosure: I am the founder. The curls above do not require it. Moodle already printed NOT FOR PRODUCTION SERVERS next to the lines.</p>
]]></content:encoded></item><item><title><![CDATA[The extra plugins are Moodle's real attack surface]]></title><description><![CDATA[Core Moodle patches are not the extra plugins. Inventory additional plugins from CLI, match them to MSAs, and stop silent zip installs.]]></description><link>https://luukverhoeven.hashnode.dev/the-extra-plugins-are-moodle-s-real-attack-surface</link><guid isPermaLink="true">https://luukverhoeven.hashnode.dev/the-extra-plugins-are-moodle-s-real-attack-surface</guid><category><![CDATA[#moodle]]></category><dc:creator><![CDATA[Luuk Verhoeven]]></dc:creator><pubDate>Wed, 18 Nov 2026 11:54:07 GMT</pubDate><content:encoded><![CDATA[<p>Core Moodle™ gets a security announcement, a version bump, and a weekend patch window. The extra plugins do not. They sit in <code>mod/</code>, <code>local/</code>, <code>auth/</code>, <code>enrol/</code>, <code>blocks/</code>, <code>theme/</code>, <code>filter/</code>, <code>repository/</code>, <code>qtype/</code> and a dozen other plugin types, installed from a zip, a git submodule, or a vendor tarball that nobody has opened since 2021.</p>
<p>When a Moodle security advisory (MSA) lands, operators grep the version of <em>core</em>. That is the wrong first grep. Most of the code that runs on a Monday morning course page is not core. It is the attendance plugin, the custom cert, the SAML auth, the theme that forks Boost, the LTI source, the plagiarism tool, the exam proctoring brick.</p>
<p>This is an inventory you can finish in an afternoon. It is also the inventory auditors ask for after the fact.</p>
<h2>Core vs additional, in Moodle’s own words</h2>
<p>Site administration → Plugins → Plugins overview splits the list into <strong>Standard</strong> and <strong>Additional</strong>. Standard plugins ship with the Moodle version you installed. Additional plugins did not. Additional is the attack surface you chose.</p>
<p>The same page shows a version number per plugin and a “source”. Treat “source” as a rumour until you see the files:</p>
<pre><code class="language-bash"># from the Moodle dirroot (public/ on 5.1)
php admin/cli/check_database_schema.php  # not the inventory; just prove CLI works

php -r '
define("CLI_SCRIPT", true);
require "config.php";
require_once $CFG-&gt;libdir . "/adminlib.php";
$pluginman = core_plugin_manager::instance();
foreach ($pluginman-&gt;get_plugins() as $type =&gt; $plugins) {
    foreach ($plugins as $name =&gt; $info) {
        if (empty($info-&gt;is_standard())) {
            printf("%s_%s\t%s\t%s\n", $type, $name, $info-&gt;versiondb, $info-&gt;rootdir);
        }
    }
}
'
</code></pre>
<p>That printout is the extra-plugin bill of materials. Keep it. Date it. Put it next to the last MSA you applied.</p>
<p>If CLI is locked down, the overview page is enough to start. Export is: copy the Additional table. Do not screenshot only the red “update available” badges. A plugin with no badge can still be a 2019 zip with a known issue that Moodle HQ never packaged as an MSA because HQ does not ship it.</p>
<h2>Match the list to how the files actually arrived</h2>
<p>Three common install paths, three different update stories:</p>
<table>
<thead>
<tr>
<th>How it got there</th>
<th>How you update it</th>
<th>How it drifts</th>
</tr>
</thead>
<tbody><tr>
<td>Moodle Marketplace / plugins directory zip</td>
<td>Admin UI “Install from ZIP” or a new zip</td>
<td>Version in <code>version.php</code> vs what you think you installed</td>
</tr>
<tr>
<td>Git clone into <code>local/yourplugin</code></td>
<td><code>git fetch</code> and a tag you remember</td>
<td>Detached HEAD, vendor fork, uncommitted hotfixes</td>
</tr>
<tr>
<td>Hosting image / Partner appliance</td>
<td>The image</td>
<td>You cannot see the diff until you ask for the image notes</td>
</tr>
</tbody></table>
<p>On disk:</p>
<pre><code class="language-bash"># extra plugins are the directories git / the zip created
# standard plugins are in the Moodle tarball
cd /srv/moodle   # $CFG-&gt;root on 5.1; dirroot on 4.x

# if the site is a git checkout of core:
git status --short --ignored | head
git ls-files --others --exclude-standard | grep -E '^(public/)?(local|mod|auth|enrol|blocks|theme|filter|repository|qtype|report|admin/tool)/' | head -50
</code></pre>
<p>Anything in <code>local/</code> is extra by definition. Anything in <code>mod/</code> that is not in a vanilla tarball of the same <code>$CFG-&gt;version</code> is extra. Diff against a clean tree:</p>
<pre><code class="language-bash"># $VANILLA is an unmodified Moodle 4.5 / 5.1 unpack, same branch
diff -rq --exclude=config.php --exclude=moodledata "$VANILLA" "$LIVE" | grep -v '/lang/.*\.php$' | head
</code></pre>
<p>You will find themes that overlay Boost, <code>lib/</code> hacks that are not plugins, and a <code>config.php</code> that autoloads a fourth thing. Those hacks do not appear on Plugins overview. They still run.</p>
<h2>Read MSAs as a plugin filter, not a core filter</h2>
<p>Open <a href="https://moodle.org/security">moodle.org/security</a>. For each MSA this year, ask:</p>
<ol>
<li>Is the affected component <code>core</code>, or a plugin type + frankenstyle name (<code>mod_customcert</code>, <code>auth_saml2</code>, <code>local_xxx</code>)?</li>
<li>Is that frankenstyle name in the Additional list from the CLI dump?</li>
<li>If yes, what version is on disk (<code>version.php</code> <code>$plugin-&gt;version</code>) versus the fixed version in the MSA?</li>
</ol>
<pre><code class="language-bash"># one extra plugin
sed -n '1,40p' local/yourplugin/version.php
</code></pre>
<p>A site that is “on 4.5.6” can still be running <code>mod_attendance</code> from 2022. Core being current is not a statement about attendance.</p>
<p>Some additional plugins publish their own advisories (GitHub Security tab, a Partner mailing list, a closed ticket). Those never hit moodle.org/security. The inventory is how you know who to subscribe to. No inventory, no subscription list.</p>
<h2>What to do with the list on Monday</h2>
<p>Sort extra plugins into three buckets. Write the bucket on the export.</p>
<p><strong>Must stay.</strong> SSO, enrolment, the theme production uses, the exam tool the faculty will not drop. These get an owner, a source URL, a watch on releases, and a staging install of the next version <em>before</em> the next exam week.</p>
<p><strong>Can go.</strong> A block nobody added to a course this year. A filter that is disabled. A repository that points at a retired Google project. Uninstall through the UI so Moodle drops the DB tables, then remove the directory. Leaving the directory after uninstall is how it comes back on the next deploy.</p>
<p><strong>Unknown.</strong> No owner, no git remote, <code>version.php</code> older than the Moodle branch. Treat as must-stay until you prove otherwise, or as can-go if a course search for the frankenstyle name is empty:</p>
<pre><code class="language-sql">-- example: is this extra module used?
SELECT COUNT(*) FROM mdl_course_modules cm
JOIN mdl_modules m ON m.id = cm.module
WHERE m.name = 'attendance';
</code></pre>
<p>Do not delete first and restore from backup later during enrolment. The SQL is the argument for the change ticket.</p>
<h2>Deploy so the inventory cannot silently grow</h2>
<p>A zip dropped onto production by a well-meaning instructional designer is a new extra plugin with no owner. Stop that path:</p>
<ul>
<li><code>config.php</code> <code>$CFG-&gt;disableupdateautodeploy = true;</code> so the admin UI cannot install from the directory on production.</li>
<li>Filesystem: deploy from git or an artefact. <code>local/</code> and extra <code>mod/</code> are in the artefact, not on the live box as a writeable tree for <code>www-data</code>.</li>
<li>php-fpm user cannot write <code>dirroot</code>. Dataroot is writable; code is not.</li>
</ul>
<p>Re-run the CLI dump after every deploy. Diff it with last month. A new frankenstyle name is a change like a core upgrade: changelog, staging, then production.</p>
<p>I work on this at Ldesign Media. The Moodle security hub we keep for operators is <a href="https://guardlms.com/en/moodle-security">guardlms.com/en/moodle-security</a>. Disclosure: I am the founder of GuardLMS. The CLI dump and the Additional table do not require the product.</p>
]]></content:encoded></item><item><title><![CDATA[Permissions-Policy on a Moodle quiz that needs the camera]]></title><description><![CDATA[Permissions-Policy (formerly Feature-Policy) is the security header people copy from a hardening gist and then spend a support ticket on during exam week…]]></description><link>https://luukverhoeven.hashnode.dev/permissions-policy-on-a-moodle-quiz-that-needs-the-camera</link><guid isPermaLink="true">https://luukverhoeven.hashnode.dev/permissions-policy-on-a-moodle-quiz-that-needs-the-camera</guid><dc:creator><![CDATA[Luuk Verhoeven]]></dc:creator><pubDate>Tue, 17 Nov 2026 12:54:43 GMT</pubDate><content:encoded><![CDATA[<p><code>Permissions-Policy</code> (formerly <code>Feature-Policy</code>) is the security header people copy from a hardening gist and then spend a support ticket on during exam week. A remote-proctoring tool, an in-browser recorder, or even Moodle’s own Atto/TinyMCE media plugin asks the browser for <code>camera</code> or <code>microphone</code>. The header you pasted last quarter already answered <code>()</code>. The permission prompt never appears. The vendor says “your LMS is blocking us”. They are describing a browser header, not a Moodle capability.</p>
<p>This is a working map for a Moodle™ site that has to sit behind a real policy without taking the quiz down.</p>
<h2>What the header actually does</h2>
<p>The browser reads <code>Permissions-Policy</code> and decides which origins may use powerful APIs. It is not an allow-list for scripts. A script from <code>https://proctor.example</code> can still load under CSP and still be denied <code>camera</code> if the policy says so.</p>
<p>A strict starter, useful on a brochure site and hostile on an LMS:</p>
<pre><code>Permissions-Policy: camera=(), microphone=(), geolocation=(), payment=(), usb=(), interest-cohort=()
</code></pre>
<p>On a course page that launches a proctoring LTI tool inside an iframe, <code>camera=()</code> means: no origin, including your own, may use the camera. The iframe cannot override a disabled feature. The student sees a black preview or a generic “could not start video” string.</p>
<h2>See what you send today</h2>
<pre><code class="language-bash">curl -sI https://lms.example.org/mod/quiz/view.php?id=1 | grep -i permissions-policy
</code></pre>
<p>Empty is common. Moodle core does not ship this header. If you see a value, it came from nginx, Apache, a WAF, or a local plugin.</p>
<p>In the browser, on a quiz attempt page:</p>
<pre><code class="language-js">document.featurePolicy
  ? [...document.featurePolicy.features()].sort()
  : 'featurePolicy API not exposed';
</code></pre>
<p>And for a specific feature:</p>
<pre><code class="language-js">document.featurePolicy &amp;&amp; document.featurePolicy.allowsFeature('camera');
</code></pre>
<p><code>false</code> on the quiz page, with a vendor iframe present, is the incident.</p>
<h2>Decide per feature, not from a gist</h2>
<p>Features that are safe to disable on almost every Moodle:</p>
<ul>
<li><code>geolocation</code></li>
<li><code>payment</code></li>
<li><code>usb</code></li>
<li><code>midi</code></li>
<li><code>magnetometer</code>, <code>accelerometer</code>, <code>gyroscope</code> (unless you have a very strange lab plugin)</li>
<li><code>interest-cohort</code> (already irrelevant in current Chrome, harmless to keep)</li>
</ul>
<p>Features you must inventory before you touch them:</p>
<ul>
<li><code>camera</code></li>
<li><code>microphone</code></li>
<li><code>display-capture</code> (some proctors record the desktop)</li>
<li><code>autoplay</code> (H5P, video in lessons)</li>
<li><code>fullscreen</code> (quiz secure window, some players)</li>
<li><code>clipboard-read</code> / <code>clipboard-write</code> (the HTML editor, some question types)</li>
</ul>
<p>For each of those, list the origin that needs it. Your own LMS origin (<code>'self'</code>) needs <code>fullscreen</code> for the quiz “secure” layout. The proctor origin needs <code>camera</code> and <code>microphone</code>. H5P hosted on the same host needs <code>autoplay</code>. A third-party video CDN does not need <code>camera</code>.</p>
<p>Example that has survived an exam week:</p>
<pre><code class="language-nginx">add_header Permissions-Policy "geolocation=(), payment=(), usb=(), camera=(self \"https://proctor.example\"), microphone=(self \"https://proctor.example\"), fullscreen=(self), autoplay=(self)" always;
</code></pre>
<p>Quote the foreign origin. A missing quote is a parser error; some browsers then ignore the whole header, which looks like “the policy is off” until you test in the other browser.</p>
<h2>Iframes and the allow attribute</h2>
<p>An LTI tool in an iframe also needs the iframe’s <code>allow</code> attribute:</p>
<pre><code class="language-html">&lt;iframe src="https://proctor.example/launch" allow="camera; microphone; display-capture"&gt;&lt;/iframe&gt;
</code></pre>
<p>Moodle does not always emit that attribute for you. If the header allows the origin and the iframe does not, the feature is still blocked. If the iframe allows it and the header says <code>camera=()</code>, the header wins. Fix both, then retest in the student browser, not in an admin session.</p>
<p><code>X-Frame-Options: DENY</code> on the LMS itself is a different problem: the portal cannot frame Moodle. <code>frame-ancestors</code> is the modern form. Do not confuse it with <code>Permissions-Policy</code>. Framing and camera access are two headers.</p>
<h2>Roll out like CSP: observe, then enforce</h2>
<p>There is no <code>Permissions-Policy-Report-Only</code> in all browsers. Treat it as a breaking change.</p>
<ol>
<li>Staging course with the real proctor, H5P, a recorded lesson, TinyMCE image insert.</li>
<li>Policy with only the obviously-useless features disabled.</li>
<li>Add <code>camera</code> / <code>microphone</code> restrictions after the vendor origin is in the list.</li>
<li>Repeat on the quiz attempt, the LTI launch, and a mobile Safari session. Safari is where <code>allow</code> attribute mistakes show up first.</li>
</ol>
<p>Keep a changelog line with an expiry: “proctor.example on camera/microphone until 2027-03-01”. Vendors get replaced. The header does not get read again unless you write down why the origin is there.</p>
<p>I built <a href="https://guardlms.com">GuardLMS</a> to flag when this header disappears after a proxy change. The origin list for camera and microphone is still a spreadsheet you maintain, because only you know which exam vendor is live this term.</p>
]]></content:encoded></item></channel></rss>