NIST deprecates RSA-2048 from 2030. Find every one of them before attackers do.
📦
📦 npm
Not in CISA KEV
CRITICAL severity

CVE-2022-24304 — mongoose

CRITICALFix: Automattic/mongoose@6a19731

CVE-2022-24304 is a critical-severity (CVSS 9.8) remote code execution vulnerability in mongoose. A fix is available for mongoose — see the affected versions and patch details below.

Mongoose Vulnerable to Prototype Pollution in Schema Object

Published
Updated
Affected
2 pkgs
Patched
2 / 2
Exploits
None indexed
Exploitation data as of Apr 22, 2024 · OSV.dev, NVD, FIRST.org (EPSS)

Real-World Exposure

2 pkgs affected
📦mongoose📦mongoose

Real-time download stats are indexed for npm and PyPI packages. This vulnerability affects npm packages — download data is not available via public APIs for these ecosystems.

Description

Description

Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment.

Affected versions of this package are vulnerable to Prototype Pollution. The Schema.path() function is vulnerable to prototype pollution when setting the schema object. This vulnerability allows modification of the Object prototype and could be manipulated into a Denial of Service (DoS) attack.

Proof of Concept

// poc.js
const mongoose = require('mongoose');
const schema = new mongoose.Schema();

malicious_payload = '__proto__.toString'

schema.path(malicious_payload, [String])

x = {}
console.log(x.toString()) // crashed (Denial of service (DoS) attack)

Impact

This vulnerability can be manipulated to exploit other types of attacks, such as Denial of service (DoS), Remote Code Execution, or Property Injection.

Affected Packages

2 total 2 fixed
EcosystemPackageVulnerable rangeFix
📦npmmongoose≥ 6.0.0&&< 6.4.66.4.6npm install mongoose@6.4.6
📦npmmongooseall versions5.13.15npm install mongoose@5.13.15

Detection & mitigation playbook

Open-source dependency
  1. Detect

    Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for mongoose, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.

  2. Fix

    Update mongoose to 6.4.6 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2022-24304 is resolved across your whole dependency graph.

  3. Workarounds

    Cap what an attacker can consume: apply request size, rate and timeout limits in front of the affected component, and run it with memory and CPU limits so exhaustion degrades one worker rather than the whole service.

Frequently Asked Questions

### Description Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Affected versions of this package are vulnerable to Prototype Pollution. The `Schema.path()` function is vulnerable to prototype pollution when setting the `schema` object. This vulnerability allows modification of the Object prototype and could be manipulated into a Denial of Service (DoS) attack. ### Proof of Concept ```js // poc.js const mongoose = require('mongoose'); const schema = new mongoose.Schema(); malicious_payload = '__proto__.toString' schema.path(malicious_payload, [St
O3 Security · Impact-Aware SCA

Is CVE-2022-24304 in your dependencies?

Find it across npm, including transitive dependencies.

CVE-2022-24304: mongoose RCE — Fixed in 6.4.6