CVE-2024-53900: Mongoose Mongoose Search Injection Vulnerability Vulnerability

HIGH
Advisory Identifier: GHSA-m7xq-9374-9rvx
CVSS 9.8
CWE-89
Published
Advisory Summary

CVE-2024-53900 is a HIGH (CVSS 9.8) mongoose search injection vulnerability vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL 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.8.3, 7.8.3, 6.13.5, 5.13.23.

CVE-2024-53900 at a Glance

CVE Identifier CVE-2024-53900
GHSA Identifier GHSA-m7xq-9374-9rvx
Severity HIGH
CVSS v3.1 Base Score 9.8
CWE Classification CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
Affected Product Mongoose
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 9.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2024-53900

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.

mongoose fixed: 8.8.3
npm install mongoose@8.8.3
mongoose fixed: 7.8.3
npm install mongoose@7.8.3
mongoose fixed: 6.13.5
npm install mongoose@6.13.5
mongoose fixed: 5.13.23
npm install mongoose@5.13.23
Verify Direct and Transitive Dependencies

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-2024-53900, 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.8.3), 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-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. 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

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.

CVE-2024-53900 Affected Mongoose Versions

4 component(s)
Fixed Versions:
8.8.37.8.36.13.55.13.23
Product / Package Ecosystem Affected Versions Fixed Version
mongoose
npm
≥ 8.0.0-rc0
< 8.8.3
8.8.3
mongoose
npm
≥ 7.0.0-rc0
< 7.8.3
7.8.3
mongoose
npm
≥ 6.0.0-rc0
< 6.13.5
6.13.5
mongoose
npm
≥ 3.6.0-rc0
< 5.13.23
5.13.23

References

Frequently Asked Questions

What is CVE-2024-53900?
CVE-2024-53900 is a security vulnerability in Mongoose involving Mongoose search injection vulnerability under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Which Mongoose versions are affected?
Affected versions include releases prior to 8.8.3, 7.8.3, 6.13.5, 5.13.23 across affected packages: mongoose.
What version fixes CVE-2024-53900?
Upgrading to 8.8.3, 7.8.3, 6.13.5, 5.13.23 (or the latest patched release for your respective branch) resolves the vulnerability.
Is mongoose affected?
Yes, mongoose is affected in releases prior to 8.8.3, 7.8.3, 6.13.5, 5.13.23. Upgrade your dependency to 8.8.3, 7.8.3, 6.13.5, 5.13.23 or later.
What is the CVSS score of CVE-2024-53900?
CVE-2024-53900 has a CVSS v3.1 base score of 9.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2024-53900?
CVE-2024-53900 is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.).
How can I check npm dependencies for CVE-2024-53900?
Run the dependency tree command: 'npm ls mongoose'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-m7xq-9374-9rvx",
  "modified" : "2026-02-04T22:47:45Z",
  "published" : "2024-12-02T21:31:20Z",
  "aliases" : [ "CVE-2024-53900" ],
  "summary" : "Mongoose search injection vulnerability",
  "details" : "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.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "mongoose"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "8.0.0-rc0"
      }, {
        "fixed" : "8.8.3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "mongoose"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "7.0.0-rc0"
      }, {
        "fixed" : "7.8.3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "mongoose"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "6.0.0-rc0"
      }, {
        "fixed" : "6.13.5"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "mongoose"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.6.0-rc0"
      }, {
        "fixed" : "5.13.23"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-53900"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/github/advisory-database/pull/6769"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/github/advisory-database/pull/6776"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Automattic/mongoose/commit/33679bcf8ca43d74e3e8ecd4cc224826772d805b"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Automattic/mongoose/commit/bbb6fa7ecb44bbaf5bea955d886378a1247bce0b"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Automattic/mongoose/commit/c9e86bff7eef477da75a29af62a06d41a835a156"
  }, {
    "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.4...6.13.5"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Automattic/mongoose/compare/7.8.2...7.8.3"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Automattic/mongoose/compare/8.8.2...8.8.3"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Automattic/mongoose/releases"
  }, {
    "type" : "WEB",
    "url" : "https://www.npmjs.com/package/mongoose?activeTab=versions"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-89" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-12-02T22:19:11Z",
    "nvd_published_at" : "2024-12-02T20:15:08Z"
  }
}