CVE-2021-20187

7.2 HIGH

📋 TL;DR

This vulnerability allows Moodle site administrators to execute arbitrary PHP code via a PHP include during Shibboleth authentication. It affects Moodle installations with Shibboleth authentication enabled where administrators have access to configuration files. The risk is limited to authenticated administrators but could lead to full system compromise.

💻 Affected Systems

Products:
  • Moodle
Versions: Versions before 3.10.1, 3.9.4, 3.8.7, and 3.5.16
Operating Systems: All platforms running Moodle
Default Config Vulnerable: ✅ No
Notes: Requires Shibboleth authentication to be enabled and configured. Only affects installations where administrators can modify Shibboleth configuration files.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

An attacker with administrator access could execute arbitrary PHP code, leading to complete system takeover, data theft, or deployment of persistent backdoors.

🟠

Likely Case

Malicious or compromised administrator could execute arbitrary code within the Moodle context, potentially accessing sensitive user data or modifying system behavior.

🟢

If Mitigated

With proper access controls and monitoring, impact is limited to administrators who already have high privileges within the system.

🌐 Internet-Facing: MEDIUM
🏢 Internal Only: HIGH

🎯 Exploit Status

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

Exploitation requires administrator-level access to Moodle. The vulnerability is in the Shibboleth authentication component's PHP include functionality.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 3.10.1, 3.9.4, 3.8.7, or 3.5.16

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

Restart Required: No

Instructions:

1. Backup your Moodle installation and database. 2. Download the patched version from moodle.org. 3. Replace affected files with patched versions. 4. Clear Moodle caches. 5. Verify functionality.

🔧 Temporary Workarounds

Disable Shibboleth Authentication

all

Temporarily disable Shibboleth authentication if not required

Edit config.php and set $CFG->auth = 'manual' or another authentication method

Restrict Administrator Access

all

Limit administrator accounts to trusted personnel only

Review and reduce administrator privileges in Moodle user management

🧯 If You Can't Patch

  • Implement strict access controls for administrator accounts
  • Monitor administrator activities and file modifications in Shibboleth configuration directories

🔍 How to Verify

Check if Vulnerable:

Check Moodle version in Site Administration > Notifications or via CLI: php admin/cli/version.php

Check Version:

php admin/cli/version.php | grep 'Release'

Verify Fix Applied:

Verify version is 3.10.1, 3.9.4, 3.8.7, or 3.5.16 or later. Test Shibboleth authentication functionality.

📡 Detection & Monitoring

Log Indicators:

  • Unusual PHP file includes in Shibboleth authentication logs
  • Administrator account modifications to authentication configuration files

Network Indicators:

  • Unexpected outbound connections from Moodle server following administrator actions

SIEM Query:

source="moodle_logs" AND (event="config_modified" OR event="auth_shibboleth") AND user_role="admin"

🔗 References

📤 Share & Export