CVE-2021-42040

7.5 HIGH

📋 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

Products:
  • MediaWiki
Versions: MediaWiki through 1.36.2 with Loops extension
Operating Systems: All
Default Config Vulnerable: ✅ No
Notes: Only vulnerable when Loops extension is installed and enabled

📦 What is this software?

⚠️ 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

🌐 Internet-Facing: HIGH - Public wikis are directly exposed to unauthenticated exploitation
🏢 Internal Only: MEDIUM - Internal wikis still vulnerable but attack surface is reduced

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

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

all

Temporarily disable the vulnerable Loops extension

Edit LocalSettings.php and comment out: wfLoadExtension('Loops');

Implement Resource Limits

linux

Set 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")

🔗 References

📤 Share & Export