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

- Priority: **Routine**
- Reason: Not severe (CVSS 6.5, network access); no exploitation reported by the 5 checked sources
- Next step: Fix in the normal cadence
- Status: published
- Published: 2022-04-12 · Modified: 2024-09-16
- Aliases: UBUNTU-CVE-2021-32040
- Record: https://cvemate.com/vulnerability/CVE-2021-32040 · JSON: https://cvemate.com/vulnerability/CVE-2021-32040/json

## Description

```text
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.
```

## Signals

- CVSS: 7.5 high (v3.1, NVD) CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
- EPSS: 2.011%, percentile 81.542%, as of 2026-12-04
- Known exploited (KEV): CISA not listed, ENISA not listed, CIRCL not listed
- Ransomware use: none recorded
- Public exploits: 0

## Affected

- ubuntu mongodb (Ubuntu): All versions (No fix recorded)
- mongodb inc mongodb server: ≥ 5.0, \< 5.0.4 \| ≥ 4.4, ≤ 4.4.28 \| ≥ 4.2, \< 4.2.16
- mongodb mongodb: ≥ 4.2.0, \< 4.2.16 \| ≥ 4.4.0, \< 4.4.11 \| ≥ 5.0.0, \< 5.0.4

## References

- <https://jira.mongodb.org/browse/SERVER-58203>
- <https://jira.mongodb.org/browse/SERVER-59299>
- <https://jira.mongodb.org/browse/SERVER-60218>
- <https://security.netapp.com/advisory/ntap-20220609-0005/>
- <https://ubuntu.com/security/CVE-2021-32040>
- <https://www.cve.org/CVERecord?id=CVE-2021-32040>

---

Data as of 2026-12-05T13:42:19.393Z. The priority label is CveMate's own model from public evidence, not an official rating, and it knows nothing about your assets. How labels are decided: https://cvemate.com/faq#priority
