CVE-2021-42040
📋 TL;DR
This vulnerability in MediaWiki's Loops extension allows attackers to trigger infinite loops through parser functions, causing memory exhaustion and php-fpm hangs. It affects MediaWiki installations with the Loops extension enabled, potentially leading to denial of service.
💻 Affected Systems
- MediaWiki
📦 What is this software?
Mediawiki by Mediawiki
⚠️ Risk & Real-World Impact
Worst Case
Complete denial of service through memory exhaustion, crashing php-fpm processes and making the wiki unavailable
Likely Case
Temporary service degradation or unavailability due to resource exhaustion
If Mitigated
Minimal impact with proper resource limits and monitoring
🎯 Exploit Status
Simple parser function manipulation can trigger the infinite loop
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: MediaWiki 1.36.3 or later, Loops extension version with fix
Vendor Advisory: https://phabricator.wikimedia.org/T287347
Restart Required: Yes
Instructions:
1. Update MediaWiki to version 1.36.3 or later
2. Update Loops extension to patched version
3. Restart php-fpm/web server
4. Clear parser cache
🔧 Temporary Workarounds
Disable Loops Extension
allTemporarily disable the vulnerable Loops extension
Edit LocalSettings.php and comment out: wfLoadExtension('Loops');
Implement Resource Limits
linuxSet lower execution time and memory limits for php-fpm
Edit php-fpm.conf: pm.max_children = 50
Edit php.ini: max_execution_time = 30
Edit php.ini: memory_limit = 128M
🧯 If You Can't Patch
- Disable Loops extension immediately
- Implement aggressive resource monitoring and alerting for memory exhaustion
🔍 How to Verify
Check if Vulnerable:
Check if Loops extension is enabled and MediaWiki version is ≤1.36.2
Check Version:
php maintenance/showSiteStats.php | grep 'MediaWiki'
Verify Fix Applied:
Verify MediaWiki version is ≥1.36.3 and Loops extension is updated
📡 Detection & Monitoring
Log Indicators:
- php-fpm worker timeouts
- High memory usage alerts
- Parser function errors with loops
Network Indicators:
- Increased response times
- Service unavailability
SIEM Query:
source="php-fpm.log" AND ("max children" OR "memory exhausted" OR "execution timeout")