CVE-2021-32040: Large aggregation pipelines with a specific stage can crash mongod under default configuration

Published Apr 12, 2022
·
Updated

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.

Other sources

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 versions prior to 5.0.4, 4.4.11, 4.2.16.

Affected Software

3 affected components
MongoDB MongoDB>=4.2.0<4.2.16
MongoDB MongoDB>=4.4.0<4.4.11
MongoDB MongoDB>=5.0.0<5.0.4

Event History

Apr 12, 2022
CVE Published
via MITRE·02:15 PM
Data Sourced
via MITRE·02:15 PM
DescriptionSeverityWeakness
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is CVE-2021-32040?

CVE-2021-32040 is a vulnerability in MongoDB that allows an attacker to cause a stack overflow and crash the database server in a denial-of-service (DoS) attack.

2

What is the severity of CVE-2021-32040?

CVE-2021-32040 has a severity score of 7.5, which is considered high.

3

Which versions of MongoDB are affected by CVE-2021-32040?

Versions 4.2.0 to 4.2.16, 4.4.0 to 4.4.11, and 5.0.0 to 5.0.4 of MongoDB are affected by CVE-2021-32040.

4

How can an attacker exploit CVE-2021-32040?

An attacker can exploit CVE-2021-32040 by constructing an extremely long aggregation pipeline in MongoDB with a specific stage/operator, causing a stack overflow and crashing the database server.

5

Is there a fix available for CVE-2021-32040?

Yes, MongoDB has released patches to fix CVE-2021-32040. Users are advised to upgrade to the latest patched version of MongoDB to mitigate the vulnerability.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203