CVE-2023-26121

7.5 HIGH

📋 TL;DR

CVE-2023-26121 is a prototype pollution vulnerability in the safe-eval npm package that allows attackers to modify JavaScript object prototypes, potentially leading to remote code execution or denial of service. Any application using safe-eval for evaluating untrusted code is affected. The vulnerability exists because the safeEval function doesn't properly sanitize input parameters.

💻 Affected Systems

Products:
  • safe-eval npm package
Versions: All versions
Operating Systems: All
Default Config Vulnerable: ⚠️ Yes
Notes: Any application using safe-eval to evaluate untrusted user input is vulnerable. The package is commonly used for sandboxed JavaScript evaluation.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution leading to complete system compromise, data theft, or lateral movement within the network.

🟠

Likely Case

Denial of service, application crashes, or limited data manipulation through prototype pollution.

🟢

If Mitigated

Limited impact with proper input validation and sandboxing, potentially only causing application instability.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

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

Proof-of-concept code is publicly available. Exploitation requires the application to process untrusted input through safeEval.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: N/A

Vendor Advisory: https://github.com/hacksparrow/safe-eval/issues/28

Restart Required: No

Instructions:

1. Remove safe-eval from your project dependencies. 2. Use alternative sandboxing solutions like vm2, isolated-vm, or Node.js worker threads. 3. Update package.json to remove safe-eval reference. 4. Run npm uninstall safe-eval.

🔧 Temporary Workarounds

Input Validation and Sanitization

all

Implement strict input validation to reject any input containing prototype pollution patterns like __proto__ or constructor.prototype

Use Alternative Sandbox

all

Replace safe-eval with vm2 module which provides better isolation

npm uninstall safe-eval
npm install vm2

🧯 If You Can't Patch

  • Implement strict input validation to reject any user input containing prototype pollution patterns
  • Isolate the vulnerable component in a container or sandboxed environment with minimal privileges

🔍 How to Verify

Check if Vulnerable:

Check package.json or package-lock.json for safe-eval dependency. Run: npm list safe-eval

Check Version:

npm list safe-eval

Verify Fix Applied:

Verify safe-eval is removed from dependencies and not in node_modules. Run: npm list safe-eval and check it returns 'empty'

📡 Detection & Monitoring

Log Indicators:

  • Unusual JavaScript evaluation errors
  • Application crashes during code evaluation
  • Suspicious input patterns containing __proto__ or constructor

Network Indicators:

  • Unusually large or complex payloads sent to evaluation endpoints
  • Repeated requests to code evaluation endpoints

SIEM Query:

source=application_logs AND ("safeEval" OR "safe-eval") AND (error OR crash OR exception)

🔗 References

📤 Share & Export