CVE-2024-53900: Mongoose search injection vulnerability
Mongoose versions prior to 8.8.3, 7.8.3, 6.13.5, and 5.13.23 are vulnerable to improper use of the $where operator. This vulnerability arises from the ability of the $where clause to execute arbitrary JavaScript code in MongoDB queries, potentially leading to code injection attacks and unauthorized access or manipulation of database data.
Published Dec 2, 2024 · Updated Feb 4, 2026
Affected packages
mongoose
- Ecosystem
- npm
- Affected
- >= 8.0.0-rc0, < 8.8.3
- Fixed in
- 8.8.3
- Check
npm ls mongoose
mongoose
- Ecosystem
- npm
- Affected
- >= 7.0.0-rc0, < 7.8.3
- Fixed in
- 7.8.3
- Check
npm ls mongoose
mongoose
- Ecosystem
- npm
- Affected
- >= 6.0.0-rc0, < 6.13.5
- Fixed in
- 6.13.5
- Check
npm ls mongoose
mongoose
- Ecosystem
- npm
- Affected
- >= 3.6.0-rc0, < 5.13.23
- Fixed in
- 5.13.23
- Check
npm ls mongoose
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Mongoose versions prior to 8.8.3, 7.8.3, 6.13.5, and 5.13.23 are vulnerable to improper use of the $where operator. This vulnerability arises from the ability of the $where clause to execute arbitrary JavaScript code in MongoDB queries, potentially leading to code injection attacks and unauthorized access or manipulation of database data.
Credited to balles, skrtheboss, ljharb.
References
- https://nvd.nist.gov/vuln/detail/CVE-2024-53900
- https://github.com/Automattic/mongoose/commit/c9e86bff7eef477da75a29af62a06d41a835a156
- https://github.com/Automattic/mongoose/blob/master/CHANGELOG.md
- https://github.com/Automattic/mongoose/releases
- https://www.npmjs.com/package/mongoose?activeTab=versions
- https://github.com/Automattic/mongoose/commit/33679bcf8ca43d74e3e8ecd4cc224826772d805b
- https://github.com/Automattic/mongoose/compare/6.13.4...6.13.5
- https://github.com/Automattic/mongoose/compare/7.8.2...7.8.3
- https://github.com/Automattic/mongoose/compare/8.8.2...8.8.3
- https://github.com/github/advisory-database/pull/6769
- https://github.com/github/advisory-database/pull/6776
- https://github.com/Automattic/mongoose/commit/bbb6fa7ecb44bbaf5bea955d886378a1247bce0b
- https://github.com/advisories/GHSA-m7xq-9374-9rvx
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More npm vulnerabilities
All npm entriesCVE-2026-125116
Mongoose: Discriminator key values matching inherited properties (e.g. __t: 'constructor') bypass schema casting and can poison collections
medium4.8Nov 10, 2026CVE-2026-125117
Mongoose walks into inherited properties when hydrating, setting, and merging, allowing overwrites of built-in functions (denial of service) and shared schema state
high8.2Nov 10, 2026CVE-2026-125118
Mongoose: Prototype pollution via Schema.prototype.virtual()
medium6.5Nov 10, 2026CVE-2026-125119
Mongoose: Connection-level sanitizeFilter not applied
high7.5Nov 10, 2026CVE-2026-125120
Mongoose: sanitizeFilter not applied on countDocuments
critical9.8Nov 10, 2026CVE-2026-73562
Mongoose: Prototype pollution in mongoose update casting via __proto__-prefixed dotted path (Schema._getSchema/path getter)
medium6.5Jul 24, 2026
