Large aggregation pipelines with a specific stage can crash mongod under default configuration
Key facts
- Attack vector
- Network
- Privileges required
- None
- User interaction
- None
- Attack complexity
- Low
- Impact type
- Denial of service
- Confidentiality · integrity · availability
- None · None · High
- Fix status
- Partial Red Hat: 2 without a fix
Attack profile from CVSS 3.1 · NVD. Fix status from CNA and Red Hat. Impact type from CWE-121 and the CVSS impact.
Summary
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.
Why it matters now
SSVC decision points
CISA ADP · SSVC 2.0.3
- Exploitation
- None
- Automatable
- No
- Technical impact
- Partial
The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| MongoDB | MongoDB Server | 5.0 to before 5.0.4; 4.4 – 4.4.28; 4.2 to before 4.2.16 | 5.0.4, 4.2.16 | Patch available | CNA |
- MongoDB Server VendorMongoDB Affected 5.0 to before 5.0.4; 4.4 – 4.4.28; 4.2 to before 4.2.16 Fixed in 5.0.4, 4.2.16 Patch available CNA
CPE configurations NVD · 1
| CPE | Versions | Role | Vendor |
|---|---|---|---|
| cpe:2.3:a:mongodb:mongodb:*:*:*:*:*:*:*:* | 4.2.0 to before 4.2.16; 4.4.0 to before 4.4.11; 5.0.0 to before 5.0.4 | Vulnerable | MongoDB |
- cpe:2.3:a:mongodb:mongodb:*:*:*:*:*:*:*:* Versions 4.2.0 to before 4.2.16; 4.4.0 to before 4.4.11; 5.0.0 to before 5.0.4 Vulnerable ·MongoDB
Remediation
- Fix · CNA MongoDB Server (MongoDB Inc.) Fixed in 5.0.4, 4.2.16
Vendor assessments
Red Hat
Red Hat rating: Moderate. Red Hat's page for this CVE →
| Product | Status | Plan or fix |
|---|---|---|
| Red Hat Openshift Data Foundation 4 | Affected | No fix planned: Out of support scope |
| Red Hat Update Infrastructure 3 for Cloud Providers | Affected | No fix planned: Will not fix |
Not affected: 1 product
- Red Hat Satellite 6
Timeline
- 2026-10-02 Threatist record created from CVE-2021-32040
- 2026-10-03 Alias added: GHSA-hmq6-2xj3-79w5
References
More Mongodb vulnerabilities
- TI-2025-13542 Zlib compressed protocol header length confusion may allow memory read KEVCVSS 4.0HIGH 8.7
- TI-2013-01669 MongoDB before 2.0.9 and 2.2.x before 2.2.4 does not properly validate requests to the… CVSS 2.0MEDIUM 6.0
- TI-2026-56639 Uncontrolled Resource Consumption in MongoDB Sharded Cluster Router Allows Unauthenticated Denial of Service CVSS 4.0HIGH 8.7
- TI-2026-56628 Reachable assertion in MongoDB Server CVSS 4.0HIGH 8.7
- TI-2026-15322 Improper Input Validation in MongoDB Aggregation Framework Allows Unauthenticated Denial of Service on mongos CVSS 4.0HIGH 8.7
- TI-2026-08537 Unbounded recursion in BSONColumn interleaved-reference causes pre-auth stack overflow CVSS 4.0HIGH 8.7
Sources
- CVE-2021-32040 · CVE Program
- CVE-2021-32040 · NVD
- FIRST EPSS
- GHSA-hmq6-2xj3-79w5 · GitHub Advisory Database · CC BY 4.0
- CVE-2021-32040 · Red Hat security data · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences