CVE-2021-32040

Large aggregation pipelines with a specific stage can crash mongod under default configuration

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.

Remediation

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.

Categories

6.5
CVSS
Severity: Medium
CVSS 3.1 •
CVSS 2.0 •
EPSS 0.41%
Vendor Advisory mongodb.org Vendor Advisory mongodb.org Vendor Advisory mongodb.org
Affected: MongoDB Inc. MongoDB Server
Published at:
Updated at:

References

Link Tags
https://jira.mongodb.org/browse/SERVER-58203 issue tracking patch vendor advisory
https://jira.mongodb.org/browse/SERVER-59299 issue tracking patch vendor advisory
https://jira.mongodb.org/browse/SERVER-60218 issue tracking patch vendor advisory
https://security.netapp.com/advisory/ntap-20220609-0005/ third party advisory

Frequently Asked Questions

What is the severity of CVE-2021-32040?
CVE-2021-32040 has been scored as a medium severity vulnerability.
How to fix CVE-2021-32040?
As a workaround for remediating CVE-2021-32040: >= 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.
Is CVE-2021-32040 being actively exploited in the wild?
As for now, there are no information to confirm that CVE-2021-32040 is being actively exploited. According to its EPSS score, there is a ~0% probability that this vulnerability will be exploited by malicious actors in the next 30 days.
What software or system is affected by CVE-2021-32040?
CVE-2021-32040 affects MongoDB Inc. MongoDB Server.
This platform uses data from the NIST NVD, MITRE CVE, MITRE CWE, First.org and CISA KEV but is not endorsed or certified by these entities. CVE is a registred trademark of the MITRE Corporation and the authoritative source of CVE content is MITRE's CVE web site. CWE is a registred trademark of the MITRE Corporation and the authoritative source of CWE content is MITRE's CWE web site.
© 2025 Under My Watch. All Rights Reserved.