CVE-2022-0335

8.8 HIGH

📋 TL;DR

This Cross-Site Request Forgery (CSRF) vulnerability in Moodle allows attackers to trick authenticated users into unknowingly deleting badge alignments. Attackers can craft malicious requests that execute when users visit compromised pages while logged into Moodle. All Moodle instances running affected versions are vulnerable if users with badge management permissions access malicious content.

💻 Affected Systems

Products:
  • Moodle
Versions: 3.11 to 3.11.4, 3.10 to 3.10.8, 3.9 to 3.9.11, and earlier unsupported versions
Operating Systems: All
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects users with permissions to manage badge alignments (typically teachers, managers, or administrators).

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Attackers could delete all badge alignments across the platform, disrupting credential verification and badge systems, potentially requiring manual restoration from backups.

🟠

Likely Case

Targeted deletion of specific badge alignments to undermine credential verification or disrupt specific courses/programs.

🟢

If Mitigated

With proper CSRF protections and user awareness, exploitation requires sophisticated social engineering and would be limited in scope.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ✅ No
Complexity: LOW

Exploitation requires the victim to be authenticated with badge management permissions and to visit a malicious page while logged into Moodle.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Moodle 3.11.5, 3.10.9, 3.9.12, and later versions

Vendor Advisory: https://moodle.org/mod/forum/discuss.php?d=431103

Restart Required: No

Instructions:

1. Backup your Moodle instance and database. 2. Upgrade to Moodle 3.11.5, 3.10.9, or 3.9.12 depending on your current version. 3. Apply the patch via Moodle's update mechanism or manual installation. 4. Clear Moodle caches after upgrade.

🔧 Temporary Workarounds

Implement CSRF Protection Headers

all

Add Content Security Policy headers to restrict cross-origin requests

Add to web server config: add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval';"
Add to Moodle config.php: $CFG->cspheader = true;

Restrict Badge Alignment Permissions

all

Temporarily limit which roles can manage badge alignments

Navigate to Site administration > Users > Permissions > Define roles
Edit relevant roles to remove 'moodle/badges:managealignments' capability

🧯 If You Can't Patch

  • Implement web application firewall rules to block suspicious badge alignment deletion requests
  • Educate users about CSRF risks and safe browsing practices, especially for administrative staff

🔍 How to Verify

Check if Vulnerable:

Check Moodle version in Site administration > Notifications page or run: php admin/cli/check_database_schema.php

Check Version:

grep \$release /path/to/moodle/version.php | head -1

Verify Fix Applied:

Verify version is 3.11.5+, 3.10.9+, or 3.9.12+ and test badge alignment deletion functionality with CSRF testing tools

📡 Detection & Monitoring

Log Indicators:

  • Multiple badge alignment deletion requests from same user in short timeframe
  • DELETE requests to /badges/alignments.php without referrer headers

Network Indicators:

  • HTTP POST requests to badge alignment endpoints with suspicious referrers
  • Cross-origin requests to Moodle badge management endpoints

SIEM Query:

source="moodle_logs" action="deleted" object="badge_alignment" | stats count by user, src_ip

🔗 References

📤 Share & Export