-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: 8.2.6
-
Component/s: None
-
None
-
Query Optimization
-
ALL
-
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Summary
A denial-of-service vulnerability exists in MongoDB server's query planner. A client that can issue find(...).sort(...) queries against a collection with a suitable compound index can supply large $in arrays that cause QueryPlannerAnalysis::explodeForSort() to overflow its size_t scan-count estimate. The wrapped value bypasses the maxScansToExplode safety check, after which makeCartesianProduct() materializes an enormous Cartesian product and can drive mongod into resource exhaustion and service unavailability.
Details
- Vulnerable area: src/mongo/db/query/planner_analysis.cpp
- explodeForSort() multiplies point-interval counts into numScans without overflow checks
- totalNumScans is compared to the safety limit only after unchecked arithmetic
- With eight $in predicates of 256 values each, 256^8 = 2^64 wraps to 0 on 64-bit size_t
- Planning then proceeds into explodeNode() / makeCartesianProduct(), causing practical resource exhaustion
Impact
An authenticated client with query capability against a collection that has a suitable compound index can trigger unbounded resource consumption through a single crafted query shape. Observed result: service unavailability of mongod. Depending on memory limits, the effect may be process termination, OOM kill, or prolonged unresponsiveness.
Evidence
- Control case using 200 values per $in array correctly set queryPlanner.maxScansToExplodeReached=True and kept the service alive
- Overflow-sized query caused connection drop, failed post-query TCP/ping checks, and container exit
Affected versions
<= 8.2.6
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/e2baaa02f631dafb4d5ad88bb03f1692
- is related to
-
SERVER-128255 Integer Overflow in explodeForSort() lets authenticated query trigger mongod OOM denial of service
-
- Needs Scheduling
-