CVE-2021-46509

7.8 HIGH

📋 TL;DR

CVE-2021-46509 is a stack overflow vulnerability in Cesanta MJS v2.20.0's JSON parsing functionality that allows attackers to execute arbitrary code or cause denial of service. This affects any application using the vulnerable MJS library version. Attackers can exploit this by providing specially crafted JSON input to trigger the overflow.

💻 Affected Systems

Products:
  • Cesanta MJS
Versions: v2.20.0
Operating Systems: All platforms running MJS
Default Config Vulnerable: ⚠️ Yes
Notes: Any application using MJS v2.20.0 with JSON parsing enabled is vulnerable.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution leading to complete system compromise, data theft, or ransomware deployment.

🟠

Likely Case

Denial of service causing application crashes and service disruption.

🟢

If Mitigated

Limited impact with proper input validation and memory protection mechanisms in place.

🌐 Internet-Facing: HIGH - Applications accepting JSON input from untrusted sources are directly exploitable.
🏢 Internal Only: MEDIUM - Internal applications could be exploited through lateral movement or insider threats.

🎯 Exploit Status

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

The vulnerability is in a core JSON parsing function and requires minimal attacker skill to exploit.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: v2.20.1 or later

Vendor Advisory: https://github.com/cesanta/mjs/issues/200

Restart Required: Yes

Instructions:

1. Update MJS to version 2.20.1 or later. 2. Recompile applications using the updated library. 3. Restart affected services.

🔧 Temporary Workarounds

Disable JSON parsing

all

Remove or disable JSON parsing functionality if not required

Recompile MJS with JSON support disabled

Input validation

all

Implement strict input validation for JSON data

🧯 If You Can't Patch

  • Implement strict input validation and sanitization for all JSON inputs
  • Deploy memory protection mechanisms like ASLR and stack canaries

🔍 How to Verify

Check if Vulnerable:

Check if MJS version is 2.20.0 in application dependencies or library files

Check Version:

grep -r "MJS_VERSION" /path/to/mjs/headers/ || check package manager for mjs version

Verify Fix Applied:

Verify MJS version is 2.20.1 or later and test JSON parsing with various inputs

📡 Detection & Monitoring

Log Indicators:

  • Application crashes with segmentation faults
  • Unusual memory usage patterns
  • Multiple failed JSON parsing attempts

Network Indicators:

  • Large or malformed JSON payloads to application endpoints

SIEM Query:

source="application.logs" AND ("segmentation fault" OR "stack overflow" OR "mjs")

🔗 References

📤 Share & Export