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 Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Mongoose is an object modeling tool for MongoDB designed to work in an asynchronous environment. It provides a schema-based solution for modeling application data. The vulnerability affects versions 0 to 5.13.15 and 6.0.0 to 6.4.6 of the mongoose package. Mongoose's Schema.path() function is vulnerable 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 in mongoose arises from the insecure handling of the Schema.path() function. By manipulating the schema object, an attacker can pollute the prototype of the Object, enabling them to modify the behavior of all objects in the application. This can have severe consequences, including the ability to execute arbitrary code, bypass security measures, or cause a DoS attack. The vulnerability has a CVSS score of 7.0, indicating a high severity level.

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 temporary workaround, developers can sanitize user input and validate the schema object before passing it to the Schema.path() function. This can help prevent the injection of malicious code and reduce the risk of prototype pollution. Here's an example of how to sanitize the schema object:

const schema = sanitizeSchema(userInput);
Schema.path(schema);

Conclusion

The vulnerability in mongoose (CVE-2022-2564) exposes applications to the risk of prototype pollution. It is crucial to update to the recommended versions or apply the provided workaround to mitigate the vulnerability. Regularly monitoring for vulnerabilities using tools like Vulert can help ensure the security of your application. For further support and assistance in vulnerability remediation, you can reach out to DevNack.com.

See every vulnerability recorded for mongoose →

Share this vulnerability

FAQ

Mongoose is an object modeling tool for MongoDB that provides a schema-based solution for modeling application data. It simplifies the interaction with MongoDB and allows developers to define schemas, perform validations, and create queries.

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. In the case of mongoose, the vulnerability allows an attacker to modify the Object prototype, enabling them to manipulate the behavior of all objects in the application.

The consequences of this vulnerability can be severe. An attacker can exploit prototype pollution to execute arbitrary code, bypass security measures, or cause a Denial of Service (DoS) attack. It is crucial to patch this vulnerability to prevent these potential risks.

You can use Vulert's playground (https://vulert.com/scanner) to check if your application is affected by this vulnerability. Vulert monitors and alerts in real-time for open-source vulnerabilities, using just the package-lock.json file. It provides an easy way to assess the security of your application without requiring code access or installation.

You can find more information about this vulnerability, including its technical details and affected versions, in the advisory published by GitHub at the following link: https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2022/07/GHSA-f825-f98c-gj3g/GHSA-f825-f98c-gj3g.json

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