CVE-2022-2564

9.8 CRITICAL

📋 TL;DR

CVE-2022-2564 is a prototype pollution vulnerability in Mongoose, a MongoDB object modeling tool for Node.js. It allows attackers to inject arbitrary properties into object prototypes, potentially leading to denial of service, remote code execution, or privilege escalation. Any application using vulnerable versions of Mongoose is affected.

💻 Affected Systems

Products:
  • Mongoose
Versions: Versions prior to 6.4.6
Operating Systems: All operating systems running Node.js
Default Config Vulnerable: ⚠️ Yes
Notes: Vulnerability exists in the schema handling code when processing certain input patterns.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

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

🟠

Likely Case

Denial of service through application crashes or memory corruption, or privilege escalation within the application context.

🟢

If Mitigated

Limited impact if input validation and sanitization are properly implemented, though prototype pollution can bypass some controls.

🌐 Internet-Facing: HIGH - Web applications using Mongoose with user-controlled input are directly exploitable from the internet.
🏢 Internal Only: MEDIUM - Internal applications may still be vulnerable if they process untrusted data, though attack surface is reduced.

🎯 Exploit Status

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

Exploitation requires sending specially crafted input to endpoints that use Mongoose schemas with user-controlled data.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 6.4.6 and later

Vendor Advisory: https://github.com/Automattic/mongoose/security/advisories/GHSA-5r27-8q9v-5h39

Restart Required: Yes

Instructions:

1. Update Mongoose to version 6.4.6 or later using npm: npm update mongoose
2. Restart your Node.js application
3. Test application functionality after update

🔧 Temporary Workarounds

Input validation and sanitization

all

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

🧯 If You Can't Patch

  • Implement strict input validation to reject any objects containing __proto__ or constructor properties
  • Use object-freeze or similar techniques to prevent prototype modification in critical objects

🔍 How to Verify

Check if Vulnerable:

Check package.json or run: npm list mongoose | grep mongoose

Check Version:

npm list mongoose | grep mongoose

Verify Fix Applied:

Verify installed version is 6.4.6 or higher: npm list mongoose

📡 Detection & Monitoring

Log Indicators:

  • Unusual error messages related to schema validation
  • Application crashes or unexpected behavior in Mongoose operations
  • High frequency of requests to schema-related endpoints

Network Indicators:

  • HTTP requests containing __proto__ or constructor in payloads
  • Unusual patterns in API calls to Mongoose endpoints

SIEM Query:

source="application_logs" AND ("__proto__" OR "constructor.prototype" OR "mongoose error")

🔗 References

📤 Share & Export