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

- Severity: Medium 6.5 (CVSS:3.1, scored by mongodb) `CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 2.01%, higher than 81% of CVEs (2026-12-01)
- Published: 2022-04-12T14:15:16.692Z
- Modified: 2026-09-08T08:48:13.870Z
- Also known as: BIT-MONGODB-2021-32040
- Weaknesses: CWE-121, CWE-787
- SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial
- Assigned by: mongodb

## 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.

(As written by CVE List.)

## Affected

- MongoDB Inc. MongoDB Server: from 5.0 before 5.0.4; from 4.4 up to 4.4.28; from 4.2 before 4.2.16
- mongodb mongodb: from 5.0 before 5.0.4; from 4.4 up to 4.4.28; from 4.2 before 4.2.16; from 4.2.0 before 4.2.16; from 4.4.0 before 4.4.11; from 5.0.0 before 5.0.4
- mongodb (Bitnami): from 4.2.0 before 4.2.16; from 4.4.0 before 4.4.11; from 5.0.0 before 5.0.4

## Every score

- mongodb: CVSS:3.1 6.5 Medium `CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H`
- NVD: CVSS:3.1 7.5 High `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`
- NVD: CVSS:2.0 5.0 Medium `AV:N/AC:L/Au:N/C:N/I:N/A:P`
- Bitnami Vulnerability Database: rating High

## References

- <https://jira.mongodb.org/browse/SERVER-58203> (advisory, issue-tracking, patch, vendor-advisory)
- <https://jira.mongodb.org/browse/SERVER-59299> (advisory, issue-tracking, patch, vendor-advisory)
- <https://jira.mongodb.org/browse/SERVER-60218> (advisory, issue-tracking, patch, vendor-advisory)
- <https://security.netapp.com/advisory/ntap-20220609-0005/> (advisory, third-party-advisory)
- <https://nvd.nist.gov/vuln/detail/CVE-2021-32040> (web)

## Sources

- CVE List: [CVE-2021-32040](https://www.cve.org/CVERecord?id=CVE-2021-32040), CVE Terms of Use, modified 2024-09-16
- NVD: [CVE-2021-32040](https://nvd.nist.gov/vuln/detail/CVE-2021-32040), Public domain, modified 2026-06-17
- Bitnami Vulnerability Database: [BIT-MONGODB-2021-32040](https://osv.dev/vulnerability/BIT-MONGODB-2021-32040), Apache-2.0, modified 2026-09-08

---

Page: https://cve.day/CVE-2021-32040 · Whole record: https://cve.day/CVE-2021-32040.json · Rebuilt by cve.day 2026-11-25T22:58:07.366Z
