-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: 8.3.2
-
Component/s: None
-
None
-
Query Optimization
-
ALL
-
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Summary
A post-auth denial of service vulnerability exists in MongoDB Server's query planner. A user who can issue ordinary find(...).sort(...) queries can supply four large $in predicates against a matching compound index so that QueryPlannerAnalysis::explodeForSort() overflows its scan-count multiplication, bypasses the maxScansToExplode safeguard, and proceeds into Cartesian-product materialization. In practice this can drive mongod into out-of-memory termination.
Details
- Bug location: src/mongo/db/query/planner_analysis.cpp inside QueryPlannerAnalysis::explodeForSort()
- numScans starts at 1 and multiplies interval counts without overflow checking
- with four fields of 65,536 values each, 65536^4 = 2^64 wraps to 0 on 64-bit size_t
- wrapped value is accumulated into totalNumScans, so the later safeguard compares a false low value
- execution proceeds into explodeNode() and makeCartesianProduct(), amplifying memory use
Impact
An authenticated user with ordinary query capability can send a specially crafted find().sort() request that terminates the mongod process through memory exhaustion.
Affected versions
<= r8.3.2
Severity
High (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H)
Reference
Private report gist: https://gist.github.com/YLChen-007/88e66ebaf6ef0965937131da5749675c
- is related to
-
SERVER-128254 Integer overflow in explodeForSort() allows crafted find(...).sort(...) query to crash MongoDB
-
- Needs Scheduling
-
- related to
-
SERVER-128253 Integer overflow in query planner explodeForSort() can trigger mongod denial of service
-
- Needs Scheduling
-