CVE-2021-32040: mongodb inc mongodb server Stack-based Buffer Overflow
Vulnerability summary
CVE-2021-32040 is a high (CVSS 7.5) Stack-based Buffer Overflow vulnerability in mongodb inc mongodb server. EPSS estimates a 2.01% chance of exploitation in the next 30 days, higher than 80.5% of scored vulnerabilities.
Timeline
- 12-04-2022PublishedVulnerability first disclosed.
- 16-09-2024Last modifiedVulnerability information updated.
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.
CVSS metrics
4 scores · 3 sources · 2 versions- CVE.orgCNA6.5MediumCVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:HDiffers
- OSV · UbuntuEcosystem advisory · calculated7.5HighCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
EPSS trend
Probability
2.01%
Chance of exploitation in the next 30 days
Percentile
81%
Versus all other CVEs
30-day change
+0.02 pp
From 1.99% on 18-09-2026
Known exploited
Compare KEV catalogsNot in any of the 3 tracked catalogs.
Public exploits
0 foundNo public exploits indexed.
Weaknesses
CWE · root cause- CWE-121Stack-based Buffer OverflowA stack-based buffer overflow condition is a condition where the buffer being overwritten is allocated on the stack (i.e., is a local variable or, rarely, a parameter to a function).
- CWE-787Out-of-bounds WriteThe product writes data past the end, or before the beginning, of the intended buffer.
Affected systems
Mongodb1 product
- mongodb≥ 4.2.0, < 4.2.16 | ≥ 4.4.0, < 4.4.11 | ≥ 5.0.0, < 5.0.4
Mongodb inc1 product
- mongodb server≥ 5.0, < 5.0.4 | ≥ 4.4, ≤ 4.4.28 | ≥ 4.2, < 4.2.16
Ubuntu1 product
- mongodbAll versions (No fix recorded)
3 vendors · 3 products