Skip to main content

The extra plugins are Moodle's real attack surface

Updated 6 min readMarkdown

Core Moodle™ gets a security announcement, a version bump, and a weekend patch window. The extra plugins do not. They sit in mod/, local/, auth/, enrol/, blocks/, theme/, filter/, repository/, qtype/ and a dozen other plugin types, installed from a zip, a git submodule, or a vendor tarball that nobody has opened since 2021.

When a Moodle security advisory (MSA) lands, operators grep the version of core. 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.

This is an inventory you can finish in an afternoon. It is also the inventory auditors ask for after the fact.

Core vs additional, in Moodle’s own words

Site administration → Plugins → Plugins overview splits the list into Standard and Additional. Standard plugins ship with the Moodle version you installed. Additional plugins did not. Additional is the attack surface you chose.

The same page shows a version number per plugin and a “source”. Treat “source” as a rumour until you see the files:

# 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->libdir . "/adminlib.php";
$pluginman = core_plugin_manager::instance();
foreach ($pluginman->get_plugins() as $type => $plugins) {
    foreach ($plugins as $name => $info) {
        if (empty($info->is_standard())) {
            printf("%s_%s\t%s\t%s\n", $type, $name, $info->versiondb, $info->rootdir);
        }
    }
}
'

That printout is the extra-plugin bill of materials. Keep it. Date it. Put it next to the last MSA you applied.

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.

Match the list to how the files actually arrived

Three common install paths, three different update stories:

How it got there How you update it How it drifts
Moodle Marketplace / plugins directory zip Admin UI “Install from ZIP” or a new zip Version in version.php vs what you think you installed
Git clone into local/yourplugin git fetch and a tag you remember Detached HEAD, vendor fork, uncommitted hotfixes
Hosting image / Partner appliance The image You cannot see the diff until you ask for the image notes

On disk:

# extra plugins are the directories git / the zip created
# standard plugins are in the Moodle tarball
cd /srv/moodle   # $CFG->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

Anything in local/ is extra by definition. Anything in mod/ that is not in a vanilla tarball of the same $CFG->version is extra. Diff against a clean tree:

# $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

You will find themes that overlay Boost, lib/ hacks that are not plugins, and a config.php that autoloads a fourth thing. Those hacks do not appear on Plugins overview. They still run.

Read MSAs as a plugin filter, not a core filter

Open moodle.org/security. For each MSA this year, ask:

  1. Is the affected component core, or a plugin type + frankenstyle name (mod_customcert, auth_saml2, local_xxx)?
  2. Is that frankenstyle name in the Additional list from the CLI dump?
  3. If yes, what version is on disk (version.php $plugin->version) versus the fixed version in the MSA?
# one extra plugin
sed -n '1,40p' local/yourplugin/version.php

A site that is “on 4.5.6” can still be running mod_attendance from 2022. Core being current is not a statement about attendance.

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.

What to do with the list on Monday

Sort extra plugins into three buckets. Write the bucket on the export.

Must stay. 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 before the next exam week.

Can go. 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.

Unknown. No owner, no git remote, version.php 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:

-- 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';

Do not delete first and restore from backup later during enrolment. The SQL is the argument for the change ticket.

Deploy so the inventory cannot silently grow

A zip dropped onto production by a well-meaning instructional designer is a new extra plugin with no owner. Stop that path:

  • config.php $CFG->disableupdateautodeploy = true; so the admin UI cannot install from the directory on production.
  • Filesystem: deploy from git or an artefact. local/ and extra mod/ are in the artefact, not on the live box as a writeable tree for www-data.
  • php-fpm user cannot write dirroot. Dataroot is writable; code is not.

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.

I work on this at Ldesign Media. The Moodle security hub we keep for operators is guardlms.com/en/moodle-security. Disclosure: I am the founder of GuardLMS. The CLI dump and the Additional table do not require the product.

No comments yet. Be the first to comment.