CVE-2025-23061: Mongoose Search Injection Vulnerability

mongoose Updated 02 Oct 2025

Summary

15/01/2025
Yes i
Critical
9.0

CVE-2025-23061: Mongoose search injection vulnerability. Affects mongoose across 3 version ranges.

< 6.13.6 >= 7.0.0-rc0, < 7.8.4 >= 8.0.0-rc0, < 8.9.5

Fixed in 6.13.6, 7.8.4 or 8.9.5, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2025-23061 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Mongoose is a popular Object Data Modeling (ODM) library for MongoDB and Node.js, providing a straightforward way to interact with MongoDB databases. It offers features such as schema validation, query building, and middleware support. However, Mongoose versions prior to 8.9.5 are vulnerable to a search injection issue due to improper handling of nested $where filters in conjunction with populate() matches, which can lead to unintended data exposure or manipulation.

Vulnerability Detail

The vulnerability arises from an incomplete fix for a previous issue (CVE-2024-53900), allowing attackers to exploit the $where filter in Mongoose queries. This can lead to search injection attacks, where malicious users can manipulate queries to retrieve or modify data in ways not intended by the application. The severity of this vulnerability is rated as critical, with a CVSS score of 9.0, indicating a high potential for impact on affected systems.

How To Fix

Latest published version: 9.11.3 as of 23 Oct 2026

npm install mongoose@9.11.3

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 6.13.6 6.13.6
    npm install mongoose@6.13.6
  • >= 7.0.0-rc0, < 7.8.4 7.8.4
    npm install mongoose@7.8.4
  • >= 8.0.0-rc0, < 8.9.5 8.9.5
    npm install mongoose@8.9.5

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

If you are unable to upgrade to the patched version immediately, consider avoiding the use of nested $where filters in your queries or implementing additional validation and sanitization on user inputs to mitigate the risk of injection attacks.

Conclusion

The Mongoose search injection vulnerability (CVE-2025-23061) poses a significant risk to applications using affected versions of the library. It is crucial to update to version 8.9.5 or later to mitigate this risk. Additionally, utilizing tools like Vulert can help maintain awareness of vulnerabilities in your dependencies.

See every vulnerability recorded for mongoose →

Share this vulnerability

FAQ

The vulnerability allows for search injection through improper handling of nested $where filters in Mongoose queries.

If you are using Mongoose versions prior to 8.9.5, your application may be vulnerable. You can check your package-lock.json file or use the Vulert playground to assess your application's exposure.

Exploitation of this vulnerability can lead to unauthorized data access, data manipulation, or even complete compromise of the application.

Yes, you can use Vulert, which monitors your package-lock.json for open-source vulnerabilities in real-time without requiring code access or installation.

Implement workarounds such as avoiding nested $where filters and enhancing input validation to reduce the risk of injection attacks.

Related vulnerabilities

Recent vulnerabilities recorded for mongoose.

How To Fix

Latest published version: 9.11.3 as of 23 Oct 2026

npm install mongoose@9.11.3

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 6.13.6 6.13.6
    npm install mongoose@6.13.6
  • >= 7.0.0-rc0, < 7.8.4 7.8.4
    npm install mongoose@7.8.4
  • >= 8.0.0-rc0, < 8.9.5 8.9.5
    npm install mongoose@8.9.5

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback