Skip to main content
Press slash or control plus K to focus the search. Use the arrow keys to navigate results and press enter to open a threat.
Reconnecting to live updates…

CVE-2025-23061: CWE-94 Improper Control of Generation of Code ('Code Injection') in mongoosejs Mongoose

0
Critical
VulnerabilityCVE-2025-23061cvecve-2025-23061cwe-94
Published: Wed Jan 15 2025 (01/15/2025, 00:00:00 UTC)
Source: CVE Database V5
Vendor/Project: mongoosejs
Product: Mongoose

Description

Mongoose before 8.9.5 can improperly use a nested $where filter with a populate() match, leading to search injection. NOTE: this issue exists because of an incomplete fix for CVE-2024-53900.

AI-Powered Analysis

Machine-generated threat intelligence

AILast updated: 02/27/2026, 12:34:35 UTC

Technical Analysis

CVE-2025-23061 is a critical vulnerability classified under CWE-94 (Improper Control of Generation of Code), affecting Mongoose, a widely used MongoDB object modeling tool for Node.js. The flaw exists in Mongoose versions 6.0.0, 7.0.0, and 8.0.0, prior to version 8.9.5. It arises from improper handling of nested $where filters when used in conjunction with populate() match queries. The $where operator in MongoDB allows execution of JavaScript expressions for filtering documents, which if improperly sanitized, can lead to code injection. This vulnerability is a result of an incomplete fix for a previous vulnerability (CVE-2024-53900), indicating residual unsafe code paths remain. An attacker can craft malicious queries that exploit this injection point to execute arbitrary code or commands on the database server or the application environment. The vulnerability has a CVSS v3.1 score of 9.0, reflecting its critical nature with network attack vector, no privileges required, no user interaction, and complete impact on confidentiality, integrity, and availability. No public exploits are known yet, but the ease of exploitation and severity make it a significant threat. The vulnerability affects applications that rely on vulnerable Mongoose versions for database interactions, especially those exposing query interfaces to untrusted users.

Potential Impact

The impact of CVE-2025-23061 is severe for organizations worldwide using vulnerable Mongoose versions. Successful exploitation can lead to remote code execution, allowing attackers to compromise sensitive data, manipulate or delete database contents, and disrupt application availability. This can result in data breaches, loss of customer trust, regulatory penalties, and operational downtime. Since Mongoose is widely used in Node.js applications across various industries including finance, healthcare, e-commerce, and technology, the scope of affected systems is broad. The vulnerability’s ability to bypass authentication and user interaction requirements increases the risk of automated or remote exploitation. Organizations with internet-facing applications or APIs that accept user-supplied query parameters are particularly at risk. The incomplete fix from a previous CVE suggests that patch management and vulnerability assessment processes need strengthening to prevent similar issues.

Mitigation Recommendations

To mitigate CVE-2025-23061, organizations should immediately upgrade Mongoose to version 8.9.5 or later, where the vulnerability is fixed. If upgrading is not immediately feasible, implement strict input validation and sanitization on all user-supplied query parameters, especially those involving $where and populate() match filters. Disable or restrict the use of the $where operator in MongoDB queries if possible, as it inherently allows JavaScript execution. Employ application-layer firewalls or query filtering mechanisms to detect and block suspicious query patterns indicative of injection attempts. Conduct thorough code reviews and static analysis focusing on database query construction to identify unsafe patterns. Monitor application logs and database activity for anomalous queries or errors related to $where usage. Additionally, isolate database servers from direct internet exposure and enforce the principle of least privilege on database access credentials. Finally, maintain an up-to-date inventory of Mongoose versions in use and integrate vulnerability scanning into the CI/CD pipeline to catch vulnerable dependencies early.

Pro Console: star threats, build custom feeds, automate alerts via Slack, email & webhooks.Upgrade to Pro

Technical Details

Data Version
5.1
Assigner Short Name
mitre
Date Reserved
2025-01-10T00:00:00.000Z
Cvss Version
3.1
State
PUBLISHED

Threat ID: 699f6b1bb7ef31ef0b54e35e

Added to database: 2/25/2026, 9:35:23 PM

Last enriched: 2/27/2026, 12:34:35 PM

Last updated: 4/12/2026, 12:55:47 AM

Views: 34

Community Reviews

0 reviews

Crowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.

Sort by
Loading community insights…

Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.

Actions

PRO

Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.

Please log in to the Console to use AI analysis features.

Need more coverage?

Upgrade to Pro Console for AI refresh and higher limits.

For incident response and remediation, OffSeq services can help resolve threats faster.

Latest Threats

Breach by OffSeqOFFSEQFRIENDS — 25% OFF

Check if your credentials are on the dark web

Instant breach scanning across billions of leaked records. Free tier available.

Scan now
OffSeq TrainingCredly Certified

Lead Pen Test Professional

Technical5-day eLearningPECB Accredited
View courses