A Leader in the 2026 Gartner® Magic Quadrant™ for Endpoint Protection. Six years running.Six years. Gartner® Magic Quadrant™ Leader.Find Out Why
Experiencing a Breach?Blog
Get StartedContact Us
SentinelOne
  • Platform
    Platform Overview
    • Singularity Platform
      Welcome to Integrated Enterprise Security
    • AI for Security
      Leading the Way in AI-Powered Security Solutions
    • Securing AI
      Accelerate AI Adoption with Secure AI Tools, Apps, and Agents.
    • How It Works
      The Singularity XDR Difference
    • Singularity Marketplace
      One-Click Integrations to Unlock the Power of XDR
    • Pricing & Packaging
      Comparisons and Guidance at a Glance
    Data & AI
    • Purple AI
      Accelerate SecOps with Generative AI
    • Singularity Hyperautomation
      Easily Automate Security Processes
    • AI-SIEM
      The AI SIEM for the Autonomous SOC
    • AI Data Pipelines
      Security Data Pipeline for AI SIEM and Data Optimization
    • Singularity Data Lake
      AI-Powered, Unified Data Lake
    • Singularity Data Lake for Log Analytics
      Seamlessly Ingest Data from On-Prem, Cloud or Hybrid Environments
    Endpoint Security
    • Singularity Endpoint
      Autonomous Prevention, Detection, and Response
    • Singularity XDR
      Native & Open Protection, Detection, and Response
    • Singularity RemoteOps Forensics
      Orchestrate Forensics at Scale
    • Singularity Threat Intelligence
      Comprehensive Adversary Intelligence
    • Singularity Vulnerability Management
      Application & OS Vulnerability Management
    • Singularity Identity
      Identity Threat Detection and Response
    Cloud Security
    • Singularity Cloud Security
      Block Attacks with an AI-Powered CNAPP
    • Singularity Cloud Native Security
      Secure Cloud and Development Resources
    • Singularity Cloud Workload Security
      Real-Time Cloud Workload Protection Platform
    • Singularity Cloud Data Security
      AI-Powered Threat Detection for Cloud Storage
    • Singularity Cloud Security Posture Management
      Detect and Remediate Cloud Misconfigurations
    Securing AI
    • Prompt Security
      Secure AI Tools Across Your Enterprise
  • Why SentinelOne?
    Why SentinelOne?
    • Why SentinelOne?
      Cybersecurity Built for What’s Next
    • Our Customers
      Trusted by the World’s Leading Enterprises
    • Industry Recognition
      Tested and Proven by the Experts
    • About Us
      The Industry Leader in Autonomous Cybersecurity
    Compare SentinelOne
    • Arctic Wolf
    • Broadcom
    • CrowdStrike
    • Cybereason
    • Microsoft
    • Palo Alto Networks
    • Sophos
    • Splunk
    • Trellix
    • Trend Micro
    • Wiz
    Verticals
    • Energy
    • Federal Government
    • Finance
    • Healthcare
    • Higher Education
    • K-12 Education
    • Manufacturing
    • Retail
    • State and Local Government
  • Services
    Managed Services
    • Managed Services Overview
      Wayfinder Threat Detection & Response
    • Threat Hunting
      World-Class Expertise and Threat Intelligence
    • Managed Detection & Response
      24/7/365 Expert MDR Across Your Entire Environment
    • Incident Readiness & Response
      DFIR, Breach Readiness, & Compromise Assessments
    Support, Deployment, & Health
    • Technical Account Management
      Customer Success with Personalized Service
    • SentinelOne GO
      Guided Onboarding & Deployment Advisory
    • SentinelOne University
      Live and On-Demand Training
    • Services Overview
      Comprehensive Solutions for Seamless Security Operations
    • SentinelOne Community
      Community Login
  • Partners
    Our Network
    • MSSP Partners
      Succeed Faster with SentinelOne
    • Singularity Marketplace
      Extend the Power of S1 Technology
    • Cyber Risk Partners
      Enlist Pro Response and Advisory Teams
    • Technology Alliances
      Integrated, Enterprise-Scale Solutions
    • SentinelOne for AWS
      Hosted in AWS Regions Around the World
    • Channel Partners
      Deliver the Right Solutions, Together
    • SentinelOne for Google Cloud
      Unified, Autonomous Security Giving Defenders the Advantage at Global Scale
    • Partner Locator
      Your Go-to Source for Our Top Partners in Your Region
    Partner Portal→
  • Resources
    Resource Center
    • Case Studies
    • Data Sheets
    • eBooks
    • Reports
    • Videos
    • Webinars
    • Whitepapers
    • Events
    View All Resources→
    Blog
    • Feature Spotlight
    • For CISO/CIO
    • From the Front Lines
    • Identity
    • Cloud
    • macOS
    • SentinelOne Blog
    Blog→
    Tech Resources
    • SentinelLABS
    • Ransomware Anthology
    • Cybersecurity 101
  • About
    About SentinelOne
    • About SentinelOne
      The Industry Leader in Cybersecurity
    • Investor Relations
      Financial Information & Events
    • SentinelLABS
      Threat Research for the Modern Threat Hunter
    • Careers
      The Latest Job Opportunities
    • Press & News
      Company Announcements
    • Cybersecurity Blog
      The Latest Cybersecurity Threats, News, & More
    • FAQ
      Get Answers to Our Most Frequently Asked Questions
    • DataSet
      The Live Data Platform
    • S Foundation
      Securing a Safer Future for All
    • S Ventures
      Investing in the Next Generation of Security, Data and AI
  • Pricing
Get StartedContact Us
CVE Vulnerability Database
Vulnerability Database/CVE-2025-23061

CVE-2025-23061: Mongoosejs Mongoose SQLi Vulnerability

CVE-2025-23061 is a SQL injection flaw in Mongoosejs Mongoose before 8.9.5 caused by improper handling of nested $where filters with populate() match. This article covers technical details, affected versions, and mitigation.

Updated: May 15, 2026

CVE-2025-23061 Overview

CVE-2025-23061 is a search injection vulnerability in Mongoose, the popular MongoDB object modeling library for Node.js. Versions before 8.9.5 improperly handle a nested $where filter inside a populate() match. Attackers can bypass the existing $where block by nesting the operator one level deeper, achieving code injection [CWE-94] through MongoDB server-side JavaScript evaluation. The flaw exists because the original remediation for CVE-2024-53900 only validated top-level and array-level $where keys, missing nested structures. Applications that pass user-controlled input into populate() match conditions are exposed to remote, unauthenticated exploitation.

Critical Impact

Unauthenticated attackers can inject arbitrary JavaScript expressions evaluated by MongoDB through populate() match, leading to data exfiltration, manipulation, and potential service disruption.

Affected Products

  • Mongoose for Node.js, all versions prior to 8.9.5
  • Applications using populate() with user-controlled match filters
  • Node.js services backed by MongoDB through the mongoosejs/mongoose ODM

Discovery Timeline

  • 2025-01-15 - CVE-2025-23061 published to NVD
  • 2025-10-31 - Last updated in NVD database

Technical Details for CVE-2025-23061

Vulnerability Analysis

Mongoose's populate() method resolves references between MongoDB documents and accepts a match option to filter populated results. The $where operator in MongoDB executes a JavaScript expression on the server during query evaluation. When user input reaches a match object containing $where, an attacker can supply arbitrary JavaScript that runs inside the database engine.

The earlier fix for CVE-2024-53900 rejected match.$where and iterated arrays for item.$where. It did not recurse into nested objects or logical operators such as $and, $or, or sub-document filters. Crafted payloads place $where inside a deeper key, evading the guard and reaching MongoDB unfiltered. This is an incomplete fix issue, which is why CVE-2025-23061 was assigned as a distinct vulnerability.

Root Cause

The root cause is incomplete input validation in lib/helpers/populate/getModelsMapForPopulate.js. The previous logic only inspected the immediate match object and array entries. Attackers can hide $where inside nested filter clauses, bypassing the shallow check and injecting JavaScript that MongoDB executes server-side.

Attack Vector

Exploitation requires the application to pass attacker-influenced data into populate({ match: ... }). A request that nests $where under another operator triggers code evaluation when Mongoose builds the populate query. No authentication or user interaction is required when the vulnerable endpoint is reachable over the network.

javascript
// Security patch in lib/helpers/populate/getModelsMapForPopulate.js
// Replaces shallow checks with a recursive helper that rejects $where anywhere in the match tree.
     if (hasMatchFunction) {
       match = match.call(doc, doc);
     }
-    if (Array.isArray(match)) {
-      for (const item of match) {
-        if (item != null && item.$where) {
-          throw new MongooseError('Cannot use $where filter with populate() match');
-        }
-      }
-    } else if (match != null && match.$where != null) {
-      throw new MongooseError('Cannot use $where filter with populate() match');
-    }
+    throwOn$where(match);
     data.match = match;
     data.hasMatchFunction = hasMatchFunction;
     data.isRefPath = isRefPath;
// Source: https://github.com/Automattic/mongoose/commit/64a9f9706f2428c49e0cfb8e223065acc645f7bc

Detection Methods for CVE-2025-23061

Indicators of Compromise

  • HTTP request bodies or query parameters containing $where keys nested inside other filter operators.
  • MongoDB server logs showing unexpected JavaScript evaluation or queries with $where expressions originating from application traffic.
  • Anomalous database response times or CPU spikes on MongoDB nodes coinciding with populate() queries.

Detection Strategies

  • Inventory Node.js projects and audit package-lock.json or yarn.lock for mongoose versions below 8.9.5.
  • Perform static analysis on application code to locate calls to populate() where the match argument is derived from request input.
  • Inspect web application firewall logs for JSON payloads containing the substring $where in nested positions.

Monitoring Recommendations

  • Enable MongoDB profiler or audit logging to capture queries that include $where and alert on their frequency.
  • Forward Node.js application logs and database query telemetry to a centralized analytics platform for correlation.
  • Track outbound connections and file access from MongoDB hosts to detect post-exploitation activity.

How to Mitigate CVE-2025-23061

Immediate Actions Required

  • Upgrade Mongoose to version 8.9.5 or later across all Node.js services.
  • Reject any user-supplied filter objects containing $where at the application layer before invoking populate().
  • Disable server-side JavaScript in MongoDB where business logic does not require it by setting security.javascriptEnabled: false.

Patch Information

The fix is delivered in Mongoose 8.9.5. The repaired code introduces a recursive throwOn$where helper, as shown in the GitHub commit details. Refer to the GitHub Mongoose Changelog and NPM Mongoose Package Versions for release details.

Workarounds

  • Sanitize incoming JSON by recursively stripping keys that begin with $ before passing data to Mongoose query builders.
  • Wrap populate() calls in a helper that accepts only an allow-list of filter fields and operators.
  • Restrict MongoDB user privileges so that the application account cannot execute commands requiring server-side JavaScript.
bash
# Update Mongoose to a patched version
npm install mongoose@^8.9.5

# Verify the installed version
npm ls mongoose

# Disable server-side JavaScript in mongod.conf as a defense-in-depth measure
# security:
#   javascriptEnabled: false

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

  • Vulnerability Details
  • TypeSQLI

  • Vendor/TechMongoosejs

  • SeverityCRITICAL

  • CVSS Score9.8

  • EPSS Probability55.32%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityNone
  • AvailabilityHigh
  • CWE References
  • CWE-94
  • Technical References
  • GitHub Mongoose Changelog

  • GitHub Mongoose Release 8.9.5

  • NPM Mongoose Package Versions
  • Vendor Resources
  • GitHub Commit Details
  • Related CVEs
  • CVE-2024-53900: Mongoosejs Mongoose SQLi Vulnerability

  • CVE-2023-3696: Mongoosejs Mongoose Prototype Pollution
Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.

Try SentinelOne
  • Get Started
  • Get a Demo
  • Product Tour
  • Why SentinelOne
  • Pricing & Packaging
  • FAQ
  • Contact
  • Contact Us
  • Customer Support
  • SentinelOne Status
  • Language
  • Platform
  • Singularity Platform
  • Singularity Endpoint
  • Singularity Cloud
  • Singularity AI-SIEM
  • Singularity Identity
  • Singularity Marketplace
  • Purple AI
  • Services
  • Wayfinder TDR
  • SentinelOne GO
  • Technical Account Management
  • Support Services
  • Verticals
  • Energy
  • Federal Government
  • Finance
  • Healthcare
  • Higher Education
  • K-12 Education
  • Manufacturing
  • Retail
  • State and Local Government
  • Cybersecurity for SMB
  • Resources
  • Blog
  • Labs
  • Case Studies
  • Videos
  • Product Tours
  • Events
  • Cybersecurity 101
  • eBooks
  • Webinars
  • Whitepapers
  • Press
  • News
  • Ransomware Anthology
  • Company
  • About Us
  • Our Customers
  • Careers
  • Partners
  • Legal & Compliance
  • Security & Compliance
  • Investor Relations
  • S Foundation
  • S Ventures

©2026 SentinelOne, All Rights Reserved.

Privacy Notice Terms of Use

English