CVE-2026-133062
Patch Available.
This Vulnerability has been fixed in the Never-Ending Support (NES) version offered by HeroDevs.
Overview
Moodle is an open source learning management system written in PHP. Schools, universities, and companies use it to run online courses. IOMAD is a multi-tenant distribution of Moodle that lets one installation serve several companies or organizations; it is built on Moodle core and shares the affected code. The external database enrolment plugin (enrol_database) synchronizes course enrolments from a table in a separate database. It is not enabled by default. During synchronization, Moodle queries the external table using values taken from Moodle courses and users.
A SQL Injection vulnerability (CVE-2026-133062) has been identified in the external database enrolment plugin (enrol_database) of Moodle and IOMAD, which allows an authenticated user with course editing permissions to inject SQL into queries that Moodle runs against the connected external database. Moodle tracks this issue as MSA-26-0049 (MDL-90353).
Per MITRE CWE-89: The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
This issue affects all versions of Moodle before 4.5.16, versions 5.0.0 through 5.1.8, versions 5.2.0 through 5.2.4, and version 5.3.0, including End-of-Life release lines such as Moodle 4.3 and 5.0. IOMAD releases built on these Moodle versions contain the same code and are affected as well.
Details
Module Info
- Product: Moodle, IOMAD
- Affected packages: moodle/moodle (enrol_database)
- Affected versions: <4.5.16, >=5.0.0 <5.1.9, >=5.2.0 <5.2.5, >=5.3.0 <5.3.1
- GitHub repository: https://github.com/moodle/moodle (Moodle), https://github.com/iomad/iomad (IOMAD)
- Published packages: https://packagist.org/packages/moodle/moodle
- Package manager: Composer
- Fixed in:
- OSS Moodle 4.5.16, 5.1.9, 5.2.5, 5.3.1
- NES for Moodle v4.3.16
- NES for IOMAD v4.3.7
Vulnerability Info
This High-severity vulnerability is found in the moodle/moodle package in all versions of Moodle before 4.5.16, versions 5.0.0 through 5.1.8, versions 5.2.0 through 5.2.4, and version 5.3.0, including End-of-Life release lines such as Moodle 4.3 and 5.0. IOMAD releases built on these Moodle versions contain the same code and are affected as well. The CVE record's CNA assigns it a CVSS 3.1 base score of 7.5 (CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H).
The plugin connects to the external database through ADOdb and builds its SELECT statements in db_get_sql(). Values such as the course's mapping field or the user's mapping field are escaped by a function in the plugin and placed directly into the SQL text:
protected function db_get_sql($table, array $conditions, array $fields, $distinct = false, $sort = "") {
$fields = $fields ? implode(',', $fields) : "*";
$where = array();
if ($conditions) {
foreach ($conditions as $key=>$value) {
$value = $this->db_encode($this->db_addslashes($value));
$where[] = "$key = '$value'";
}
}
$where = $where ? "WHERE ".implode(" AND ", $where) : "";The escaping function, db_addslashes(), is a hand-written routine that either doubles single quotes or adds backslashes, depending on a plugin setting. It does not use the quoting rules of the external database's driver. When the routine does not match what the external database expects, a crafted value can end the string literal and add SQL of its own. Some of these values, for example the course field used for mapping, can be set by a user who can edit course settings.
The queries run against the external enrolment database, not Moodle's own database. Per the advisory, only sites with the enrol_database plugin enabled are affected, and editing teacher access is required. The CVE record states that an attacker could view, modify or delete records in the connected external database.
The fix replaces the string building with parameterized queries. Each value is bound through a placeholder generated by the ADOdb connection, and the setting that selected the old quoting style is removed:
$extdb->Param(false);
foreach ($conditions as $key => $value) {
$name = 'p' . count($params);
$where[] = "$key = " . $extdb->Param($name);
$params[$name] = $this->db_encode($value);
}Mitigation
Moodle publishes security fixes only for its supported release lines. Moodle 5.0 and the release lines before 4.5, including Moodle 4.3 and the IOMAD releases built on it, are End-of-Life and will not receive any public updates to address this issue.
If the external database enrolment plugin is not needed, disabling it under Site administration, Plugins, Enrolments, Manage enrol plugins removes the exposure.
Users of the affected components should apply one of the following mitigations:
- Upgrade to Moodle 4.5.16, 5.1.9, 5.2.5, 5.3.1, or later, or to an IOMAD release built on one of those versions.
- Leverage a commercial support partner like HeroDevs (NES for Moodle, NES for IOMAD) for post-EOL security support.
Credits
- Anupama Sarjoshi (remediation)
- Huong Nguyen (remediation)