CVE-2024-8654

5.0 MEDIUM

📋 TL;DR

MongoDB Server v6.0.3 contains a memory access vulnerability in internal aggregation stage processing when zero arguments are called. This could lead to crashes, data corruption, or potential information disclosure. Only MongoDB Server v6.0.3 installations are affected.

💻 Affected Systems

Products:
  • MongoDB Server
Versions: v6.0.3 only
Operating Systems: All platforms running MongoDB
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects MongoDB Server v6.0.3; other versions including earlier 6.0.x releases are not vulnerable.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Server crash leading to denial of service, memory corruption potentially enabling arbitrary code execution, or sensitive data leakage from uninitialized memory.

🟠

Likely Case

Server instability, crashes, or unexpected behavior when processing specific aggregation queries with zero arguments.

🟢

If Mitigated

Minimal impact if proper network segmentation and access controls prevent unauthorized users from sending malicious aggregation queries.

🌐 Internet-Facing: MEDIUM - Attackers could potentially trigger the vulnerability remotely if MongoDB is exposed to untrusted networks.
🏢 Internal Only: LOW - Risk is reduced if MongoDB is only accessible to trusted internal applications and users.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ⚠️ Yes
Complexity: MEDIUM

Exploitation requires sending specific aggregation queries with zero arguments to trigger the memory access issue.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Upgrade to MongoDB Server v6.0.4 or later

Vendor Advisory: https://jira.mongodb.org/browse/SERVER-71477

Restart Required: Yes

Instructions:

1. Backup all MongoDB data and configuration. 2. Stop MongoDB service. 3. Upgrade to MongoDB v6.0.4 or later using your package manager or MongoDB distribution. 4. Restart MongoDB service. 5. Verify successful upgrade and normal operation.

🔧 Temporary Workarounds

Restrict Aggregation Query Access

all

Limit which users/applications can execute aggregation queries through MongoDB role-based access control.

db.createRole({ role: "restrictedRole", privileges: [{ resource: { db: "", collection: "" }, actions: ["find", "insert", "update", "remove"] }], roles: [] })
db.grantRolesToUser("username", ["restrictedRole"])

🧯 If You Can't Patch

  • Implement strict network access controls to limit MongoDB exposure to only trusted applications
  • Monitor for abnormal server behavior or crashes and implement aggressive logging of aggregation queries

🔍 How to Verify

Check if Vulnerable:

Connect to MongoDB and run: db.version(). If output is "6.0.3", the system is vulnerable.

Check Version:

db.version()

Verify Fix Applied:

After patching, run db.version() and confirm version is 6.0.4 or higher. Test aggregation functionality with your applications.

📡 Detection & Monitoring

Log Indicators:

  • Unexpected server crashes or restarts
  • Error messages related to aggregation stages or memory access
  • Abnormal query patterns with zero-argument aggregation calls

Network Indicators:

  • Unusual aggregation query traffic patterns
  • Requests to MongoDB aggregation endpoints from unexpected sources

SIEM Query:

source="mongodb.log" AND ("aggregation" OR "stage") AND ("error" OR "crash" OR "unexpected")

🔗 References

📤 Share & Export