CVE-2022-2564: Prototype Pollution in mongoose

mongoose Updated 02 Oct 2025

Summary

29/07/2022
Yes i
High
7.0

CVE-2022-2564: automattic/mongoose vulnerable to Prototype pollution via Schema.path. Affects mongoose across 2 version ranges.

< 5.13.15 >= 6.0.0, < 6.4.6

Fixed in 5.13.15 or 6.4.6, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2022-2564 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 Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

Mongoose is a MongoDB object modeling tool designed for asynchronous environments. It provides a schema-based solution for interacting with MongoDB databases. The vulnerability affects versions of the mongoose package prior to 6.4.6 and 5.13.15. Mongoose's Schema.path() function is susceptible to prototype pollution when setting the schema object. This vulnerability allows an attacker to modify the Object prototype, potentially leading to a Denial of Service (DoS) attack.

Vulnerability Detail

The vulnerability arises from the insecure handling of the Schema.path() function in mongoose. By manipulating the schema object, an attacker can pollute the prototype chain, leading to unexpected behavior and potential security issues. In this case, the vulnerability allows for a DoS attack by causing the application to crash or consume excessive resources. The severity of this vulnerability is rated as HIGH with a CVSS score of 7.0.

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.

  • < 5.13.15 5.13.15
    npm install mongoose@5.13.15
  • >= 6.0.0, < 6.4.6 6.4.6
    npm install mongoose@6.4.6

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

Workaround

As a workaround, developers can manually sanitize and validate the input before passing it to the Schema.path() function. This can help mitigate the risk of prototype pollution. Here's an example of how to sanitize the input:

const mongoose = require('mongoose');

function sanitizeInput(input) {
  // Perform input sanitization
  // ...
  return sanitizedInput;
}

const schema = new mongoose.Schema({
  path: sanitizeInput(userInput)
});

Conclusion

In conclusion, the mongoose package is vulnerable to prototype pollution via the Schema.path() function. This vulnerability can be mitigated by updating to the fixed versions or implementing input sanitization. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for mongoose →

Share this vulnerability

FAQ

Mongoose is a MongoDB object modeling tool that provides a schema-based solution for interacting with MongoDB databases in asynchronous environments.

Prototype pollution is a vulnerability that occurs when an attacker can modify the prototype of an object, leading to unexpected behavior and potential security issues.

The vulnerability in mongoose can be exploited to perform a Denial of Service (DoS) attack by manipulating the schema object and causing the application to crash or consume excessive resources.

To fix this vulnerability, update the mongoose package to version 6.4.6 or 5.13.15, depending on the version used.

As a workaround, developers can manually sanitize and validate the input before passing it to the Schema.path() function to mitigate the risk of prototype pollution.

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.

  • < 5.13.15 5.13.15
    npm install mongoose@5.13.15
  • >= 6.0.0, < 6.4.6 6.4.6
    npm install mongoose@6.4.6

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