CVE-2021-42717

7.5 HIGH

📋 TL;DR

CVE-2021-42717 is a denial-of-service vulnerability in ModSecurity's JSON parser where excessively nested JSON objects cause excessive CPU consumption and process blocking. This affects ModSecurity 2.8.0-2.9.4 and 3.x-3.0.5 when processing JSON payloads. Any web server using vulnerable ModSecurity versions with JSON parsing enabled is affected.

💻 Affected Systems

Products:
  • ModSecurity
  • NGINX with ModSecurity module
  • Apache with ModSecurity module
  • Other web servers using ModSecurity
Versions: ModSecurity 2.8.0 through 2.9.4 and ModSecurity 3.x through 3.0.5
Operating Systems: Linux, Windows, All platforms running affected ModSecurity versions
Default Config Vulnerable: ⚠️ Yes
Notes: Vulnerable when ModSecurity is configured to process JSON content (default in many configurations). NGINX deployments are particularly affected due to limited worker processes.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete denial of service where all worker processes become occupied processing malicious JSON, making the web server unavailable to legitimate users for extended periods.

🟠

Likely Case

Partial service degradation where some worker processes are tied up, causing increased latency and reduced capacity for legitimate requests.

🟢

If Mitigated

Minimal impact with proper request size limits, rate limiting, and updated ModSecurity rules in place.

🌐 Internet-Facing: HIGH - Web servers are directly exposed to crafted HTTP requests containing malicious JSON payloads.
🏢 Internal Only: MEDIUM - Internal applications could still be targeted by authenticated users or compromised internal systems.

🎯 Exploit Status

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

Exploitation requires sending HTTP requests with deeply nested JSON payloads. Public proof-of-concept code exists demonstrating the attack.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: ModSecurity 2.9.5 and ModSecurity 3.0.6

Vendor Advisory: https://www.trustwave.com/en-us/resources/blogs/spiderlabs-blog/modsecurity-dos-vulnerability-in-json-parsing-cve-2021-42717/

Restart Required: Yes

Instructions:

1. Update ModSecurity to version 2.9.5 or 3.0.6 or later. 2. For NGINX: update the ModSecurity module. 3. For Apache: update the ModSecurity module. 4. Restart the web server to apply changes.

🔧 Temporary Workarounds

Limit JSON nesting depth

all

Configure ModSecurity to reject JSON with excessive nesting depth

SecRule ARGS "@validateJsonDepth 100" "id:1001,phase:2,deny,status:400,msg:'JSON nesting depth exceeded'"
SecRule REQUEST_BODY "@validateJsonDepth 100" "id:1002,phase:2,deny,status:400,msg:'JSON nesting depth exceeded'"

Disable JSON parsing

all

Temporarily disable JSON parsing in ModSecurity if not required

SecRuleRemoveById 200000
SecRuleRemoveById 200001

🧯 If You Can't Patch

  • Implement WAF rules to block requests with deeply nested JSON patterns
  • Configure request size limits at the web server level to reject large JSON payloads

🔍 How to Verify

Check if Vulnerable:

Check ModSecurity version: modsecurity -v or examine web server configuration for ModSecurity version

Check Version:

modsecurity -v 2>/dev/null || grep -i modsecurity /path/to/nginx.conf /path/to/apache.conf

Verify Fix Applied:

Verify ModSecurity version is 2.9.5+ or 3.0.6+ and test with a nested JSON payload (use caution)

📡 Detection & Monitoring

Log Indicators:

  • High CPU usage by web server processes
  • Requests with large JSON payloads taking excessive time
  • ModSecurity rule 949110 or 980130 triggers

Network Indicators:

  • HTTP POST/PUT requests with Content-Type: application/json and unusually large size
  • Multiple requests with similar JSON structure in short time

SIEM Query:

source="web_server_logs" AND (msg="JSON parsing" OR msg="ModSecurity") AND (duration>10s OR size>200KB)

🔗 References

📤 Share & Export