CVE-2021-32040
Large aggregation pipelines with a specific stage can crash mongod under default configuration
- Published
- Updated
- Reserved
- 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.
Scores
| Scored by | CVSS | Score | Vector |
|---|---|---|---|
| mongodbCNA (assigner) | 3.1 | Medium6.5 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H |
| NVDNVD · Modified | 3.1 | High7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
- EPSS (exploitation in 30 days)
- 2.0% · top 19% of all CVEs (7 Nov 2026)
- CISA SSVC
- Exploitation: none · Automatable: no · Technical impact: partial
The list uses the assigner's score when there is one, then CISA's, then NVD's: Medium 6.5.
Weakness
Affected products
- affected 5.0 – < 5.0.4
- affected 4.4 – ≤ 4.4.28
- affected 4.2 – < 4.2.16
What to do
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.
References (4)
- https://jira.mongodb.org/browse/SERVER-58203 (opens in a new tab)x_refsource_MISCx_transferred
- https://jira.mongodb.org/browse/SERVER-59299 (opens in a new tab)x_refsource_MISCx_transferred
- https://jira.mongodb.org/browse/SERVER-60218 (opens in a new tab)x_refsource_MISCx_transferred
- https://security.netapp.com/advisory/ntap-20220609-0005/ (opens in a new tab)x_refsource_CONFIRMx_transferred
Sources
The same CVE in the primary databases and aggregators, to check against.
- CVE.org record (opens in a new tab)
- CVE List JSON (GitHub) (opens in a new tab)
- NVD (opens in a new tab)
- FIRST EPSS (opens in a new tab)
- OSV.dev (opens in a new tab)
- GitHub Advisories (opens in a new tab)
- CIRCL Vulnerability-Lookup (opens in a new tab)
Badge for a README or a ticket
[](https://trackcve.app/cve/CVE-2021-32040)Record last updated .