CVE-2022-30599
📋 TL;DR
CVE-2022-30599 is a critical SQL injection vulnerability in Moodle's badges functionality that allows attackers to execute arbitrary SQL commands. This affects all Moodle instances with badges enabled, potentially compromising the entire database. Administrators of Moodle-based learning management systems are primarily affected.
💻 Affected Systems
- Moodle
📦 What is this software?
Fedora by Fedoraproject
Fedora by Fedoraproject
Fedora by Fedoraproject
Moodle by Moodle
Moodle by Moodle
Moodle by Moodle
Moodle by Moodle
⚠️ Risk & Real-World Impact
Worst Case
Complete database compromise leading to data theft, data manipulation, privilege escalation, and potential remote code execution via database functions.
Likely Case
Unauthorized access to sensitive user data (grades, personal information), manipulation of course data, and potential administrative account takeover.
If Mitigated
Limited impact with proper input validation and parameterized queries in place, potentially only error messages or minor data exposure.
🎯 Exploit Status
SQL injection vulnerabilities in popular platforms like Moodle are frequently weaponized. Requires some level of user access to badges functionality.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: Moodle 3.9.17, 3.10.10, 3.11.7, or 4.0.2
Vendor Advisory: https://moodle.org/mod/forum/discuss.php?d=438013
Restart Required: No
Instructions:
1. Backup your Moodle installation and database. 2. Download the patched version from moodle.org. 3. Replace affected files or perform a full upgrade. 4. Clear Moodle caches. 5. Verify the fix by checking version and testing badges functionality.
🔧 Temporary Workarounds
Disable Badges Functionality
allTemporarily disable the badges feature to eliminate the attack vector while patching.
Navigate to Site administration > Advanced features > Enable badges (uncheck)
Web Application Firewall Rules
allImplement WAF rules to block SQL injection patterns targeting badges endpoints.
Add WAF rule: block requests containing SQL keywords to /badges/* endpoints
🧯 If You Can't Patch
- Implement strict network segmentation to isolate Moodle instances from sensitive databases
- Enable detailed SQL query logging and monitor for suspicious badge-related database activity
🔍 How to Verify
Check if Vulnerable:
Check Moodle version via Site administration > Notifications page or by examining version.php file. If version is below 3.9.17, 3.10.10, 3.11.7, or 4.0.2, you are vulnerable.
Check Version:
Check version.php file: grep "\$release" version.php
Verify Fix Applied:
Verify Moodle version is 3.9.17, 3.10.10, 3.11.7, or 4.0.2 or higher. Test badges functionality to ensure it works without errors.
📡 Detection & Monitoring
Log Indicators:
- Unusual SQL queries in database logs containing badges-related tables
- Multiple failed login attempts followed by badges API calls
- SQL syntax errors in web server logs for badges endpoints
Network Indicators:
- Unusual traffic patterns to /badges/* endpoints
- SQL injection payloads in HTTP requests
SIEM Query:
source="moodle_logs" AND ("badges" AND ("SQL" OR "UNION" OR "SELECT" OR "INSERT"))
🔗 References
- http://git.moodle.org/gw?p=moodle.git&a=search&h=HEAD&st=commit&s=MDL-74333
- https://bugzilla.redhat.com/show_bug.cgi?id=2083610
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/OGF35EN5K2R6X3NTY3XPZSJ3UDASMXI6/
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/PIMSIRKCFLIC646K4GMUSZU7THOUVPAJ/
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/QCTWSE3JDMSYL7DPCMXMMJEXZSS6VIA5/
- https://moodle.org/mod/forum/discuss.php?d=434581
- http://git.moodle.org/gw?p=moodle.git&a=search&h=HEAD&st=commit&s=MDL-74333
- https://bugzilla.redhat.com/show_bug.cgi?id=2083610
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/OGF35EN5K2R6X3NTY3XPZSJ3UDASMXI6/
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/PIMSIRKCFLIC646K4GMUSZU7THOUVPAJ/
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/QCTWSE3JDMSYL7DPCMXMMJEXZSS6VIA5/
- https://moodle.org/mod/forum/discuss.php?d=434581