CVE-2023-26158

8.2 HIGH

📋 TL;DR

CVE-2023-26158 is a prototype pollution vulnerability in the mockjs package that allows attackers to modify JavaScript object prototypes through user-controlled inputs. This can lead to denial of service, data corruption, or potentially remote code execution by polluting built-in object methods. All applications using mockjs are affected.

💻 Affected Systems

Products:
  • mockjs
Versions: All versions
Operating Systems: All
Default Config Vulnerable: ⚠️ Yes
Notes: Vulnerable when using extend() method with user-controlled inputs in Mock.Handler, Mock.Random, Mock.RE.Handler, or Mock.Util

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution through prototype pollution leading to complete system compromise

🟠

Likely Case

Denial of service, application crashes, or data corruption through polluted object methods

🟢

If Mitigated

Limited impact with proper input validation and prototype pollution protections

🌐 Internet-Facing: HIGH - Web applications using mockjs with user inputs are directly exploitable
🏢 Internal Only: MEDIUM - Internal applications still vulnerable but attack surface reduced

🎯 Exploit Status

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

Simple prototype pollution exploitation with publicly available proof-of-concept

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: None

Vendor Advisory: https://security.snyk.io/vuln/SNYK-JS-MOCKJS-6051365

Restart Required: No

Instructions:

No official patch available. Apply workaround or migrate to alternative library.

🔧 Temporary Workarounds

Add prototype pollution protection to Util.extend

all

Modify the Util.extend function to block dangerous prototype properties

Add this line inside the for (name in options) loop: if (["__proto__", "constructor", "prototype"].includes(name)) continue

🧯 If You Can't Patch

  • Implement strict input validation and sanitization for all user inputs passed to mockjs functions
  • Use Object.freeze() on critical object prototypes or implement runtime monitoring for prototype modifications

🔍 How to Verify

Check if Vulnerable:

Check package.json for mockjs dependency and verify if Util.extend function lacks prototype pollution protection

Check Version:

npm list mockjs

Verify Fix Applied:

Verify the Util.extend function includes the prototype property denylist check

📡 Detection & Monitoring

Log Indicators:

  • Unusual application crashes, unexpected prototype modifications, or errors in object property access

Network Indicators:

  • Unusual payloads containing __proto__, constructor, or prototype properties in requests

SIEM Query:

Search for requests containing __proto__, constructor, or prototype in payloads to mockjs endpoints

🔗 References

📤 Share & Export