CVE-2025-23061: Mongoose Mongoose Search Injection Vulnerability Vulnerability
CRITICALCVE-2025-23061 is a CRITICAL (CVSS 9.0) mongoose search injection vulnerability vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Mongoose libraries in the npm ecosystem. The issue involves mongoose search injection vulnerability. Remediation is available by upgrading affected packages to version 8.9.5, 7.8.4, 6.13.6.
CVE-2025-23061 at a Glance
Security Impact
CVSS: 9.0
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H).
How to Fix CVE-2025-23061
To remediate this vulnerability, upgrade all affected Mongoose dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install mongoose@8.9.5
npm install mongoose@7.8.4
npm install mongoose@6.13.6
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls mongoose
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2025-23061, inspect your project dependencies using npm:
npm ls mongoose
Analyze the terminal output to locate any version of Mongoose in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 8.9.5), your application is affected.
Note: The npm ls mongoose command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Mongoose, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2025-23061 Affected Mongoose Versions
3 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
mongoose
|
npm |
≥ 8.0.0-rc0
< 8.9.5
|
8.9.5
|
|
mongoose
|
npm |
≥ 7.0.0-rc0
< 7.8.4
|
7.8.4
|
|
mongoose
|
npm |
< 6.13.6
|
6.13.6
|
References
Frequently Asked Questions
What is CVE-2025-23061?
Which Mongoose versions are affected?
What version fixes CVE-2025-23061?
Is mongoose affected?
What is the CVSS score of CVE-2025-23061?
What CWE is associated with CVE-2025-23061?
How can I check npm dependencies for CVE-2025-23061?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-vg7j-7cwx-8wgw",
"modified" : "2025-10-03T15:40:22Z",
"published" : "2025-01-15T06:30:49Z",
"aliases" : [ "CVE-2025-23061" ],
"summary" : "Mongoose search injection vulnerability",
"details" : "Mongoose versions prior to 8.9.5, 7.8.4, and 6.13.6 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.\n\nNOTE: this issue exists because of an incomplete fix for CVE-2024-53900.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "mongoose"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "8.0.0-rc0"
}, {
"fixed" : "8.9.5"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "mongoose"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "7.0.0-rc0"
}, {
"fixed" : "7.8.4"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "mongoose"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "6.13.6"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-23061"
}, {
"type" : "WEB",
"url" : "https://github.com/Automattic/mongoose/commit/64a9f9706f2428c49e0cfb8e223065acc645f7bc"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/Automattic/mongoose"
}, {
"type" : "WEB",
"url" : "https://github.com/Automattic/mongoose/blob/master/CHANGELOG.md"
}, {
"type" : "WEB",
"url" : "https://github.com/Automattic/mongoose/compare/6.13.5...6.13.6"
}, {
"type" : "WEB",
"url" : "https://github.com/Automattic/mongoose/compare/7.8.3...7.8.4"
}, {
"type" : "WEB",
"url" : "https://github.com/Automattic/mongoose/compare/8.9.4...8.9.5"
}, {
"type" : "WEB",
"url" : "https://github.com/Automattic/mongoose/releases/tag/6.13.6"
}, {
"type" : "WEB",
"url" : "https://github.com/Automattic/mongoose/releases/tag/7.8.4"
}, {
"type" : "WEB",
"url" : "https://github.com/Automattic/mongoose/releases/tag/8.9.5"
}, {
"type" : "ADVISORY",
"url" : "https://github.com/advisories/GHSA-m7xq-9374-9rvx"
}, {
"type" : "WEB",
"url" : "https://www.npmjs.com/package/mongoose?activeTab=versions"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-94" ],
"severity" : "CRITICAL",
"github_reviewed" : true,
"github_reviewed_at" : "2025-01-16T14:02:22Z",
"nvd_published_at" : "2025-01-15T05:15:10Z"
}
}