High severity · published Apr 12, 2022
CVE-2021-32040
It may be possible to have an extremely long aggregation pipeline in conjunction with a specific stage/operator and cause a stack overflow due to the size of the stack frames used…
7.5
CVSS
2%
EPSS
No
On KEV
Description
It may be possible to have an extremely long aggregation pipeline in conjunction with a specific stage/operator and cause a stack overflow due to the size of the stack frames used by that stage. If an attacker could cause such an aggregation to occur, they could maliciously crash MongoDB in a DoS attack. This vulnerability affects MongoDB Server v4.4 versions prior to and including 4.4.28, MongoDB Server v5.0 versions prior to 5.0.4 and MongoDB Server v4.2 versions prior to 4.2.16.
Workaround: >= v4.2.16 users and all v4.4 users can add the --setParameter internalPipelineLengthLimit=50 instead of the default 1000 to mongod at startup to prevent a crash.
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Attack vector
Network
Complexity
Low
Privileges
None
User interaction
None
Confidentiality
None
Integrity
None
Availability
High
Scope
Unchanged
Exploitation
Is it being used?
Exploit prediction (EPSS)2.0% · higher than 81% of CVEs
Exploited in the wildNo evidence yet
CISA KEVNot listed
Ransomware campaign useNot known
Affected products
Which versions
MO
MongoDB · MongoDB
4.2.0 before 4.2.16; 4.4.0 before 4.4.11; 5.0.0 before 5.0.4 · source: NVD
References
NVD
https://nvd.nist.gov/vuln/detail/CVE-2021-32040
CVE.org
https://www.cve.org/CVERecord?id=CVE-2021-32040
Issue Tracking
https://jira.mongodb.org/browse/SERVER-58203
Issue Tracking
https://jira.mongodb.org/browse/SERVER-59299
Issue Tracking
https://jira.mongodb.org/browse/SERVER-60218
Third Party Advisory
https://security.netapp.com/advisory/ntap-20220609-0005/
More from MongoDB
9.9
CVE-2019-10758
MongoDB mongo-express Remote Code Execution Vulnerability
7.5
CVE-2025-14847
Zlib compressed protocol header length confusion may allow memory read
9.8
CVE-2026-19001
MongoDB BI Connector ODBC driver may write outside an allocated buffer when handling oversized catalog object names
9.8
CVE-2025-3085
A MongoDB server under specific conditions running on Linux with TLS and CRL revocation status checking enabled, fails to check the revocation status of the intermediate…
9.8
CVE-2024-8654
MongoDB Server may access non-initialized region of memory leading to unexpected behaviour
