CVE-2026-142608: Mongoose Plain Objects With A Forged Vulnerability

LOW
Advisory Identifier: GHSA-rxm2-55pg-68q6
CVSS 0.0
CWE-843
Published
Advisory Summary

CVE-2026-142608 is a LOW (CVSS 0.0) plain objects with a forged vulnerability (CWE-843: Access of Resource Using Incompatible Type ('Type Confusion')) affecting Mongoose libraries in the npm ecosystem. The issue involves plain objects with a forged _bsontype bypass objectid and string casting, leaking and replaying data from other command. Remediation is available by upgrading affected packages to version 6.13.13.

CVE-2026-142608 at a Glance

CVE Identifier CVE-2026-142608
GHSA Identifier GHSA-rxm2-55pg-68q6
Severity LOW
CVSS v3.1 Base Score 0.0
CWE Classification CWE-843: Access of Resource Using Incompatible Type ('Type Confusion')
Affected Product Mongoose
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 0.0

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:N/I:N/A:N).

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 None (C:N)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2026-142608

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: 6.13.13
npm install mongoose@6.13.13
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-2026-142608, 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 6.13.13), 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-843: Access of Resource Using Incompatible Type ('Type Confusion'), where the product allocates or initializes a resource such as a pointer, object, or variable using one type, but it later accesses that resource using a type that is incompatible with the original type. 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

### Summary From 6.3.5-6.13.12, Mongoose 6 decides whether a value is a BSON type by checking only its _bsontype property. A plain object such as {"_bsontype":"ObjectID","id":""} therefore passes the ObjectId cast. bson 4.x then writes no id bytes but still advances 12 bytes in its serialization buffer, so the value sent to MongoDB is whatever the previous command left at that offset. Request bodies, cookies and Express 4 query strings can all produce such an object. sanitizeFilter doesn’t catch it because it has no $ keys. ### Details `lib/helpers/isBsonType.js` returned true for any object whose `_bsontype` matched. This led to three problems: 1. Queries by id replay another request’s id. findById(forged) sends the `_id` from the last command with the same layout, such as another request’s `findById` on the same collection. Likewise, `findByIdAndDelete(forged)` and `findByIdAndUpdate(forged)` act on the document another request just modified with `findOneAndUpdate`. This works with `sanitizeFilter` on. 2. Stored ObjectIds leak command bytes. `create()`, `$set` and other writes store 12 bytes of earlier commands, such as filter values and updated fields. Anyone who can read the document can read those bytes. This happens in the default configuration. 3. Forged regexes on String paths. `{"_bsontype":"BSONRegExp","pattern":"^a","options":""}` passes the String query cast and is sent as a regular expression, bypassing sanitizeFilter. `mongoose.isObjectIdOrHexString()` also returns true for the forged object. The fix makes `isBsonType()` ignore `_bsontype` when it is an own property. bson defines `_bsontype` on the prototype (except for the `Timestamp` class, which Mongoose does not check), so real bson values still pass. ### Proof of concept ```javascript mongoose.set('sanitizeFilter', true); const User = mongoose.model('User', new mongoose.Schema({ email: String, password: String })); const Comment = mongoose.model('Comment', new mongoose.Schema({ post: mongoose.ObjectId })); const alice = await User.create({ email: 'alice@example.com', password: 'S3cret' }); const forged = () => JSON.parse('{"_bsontype":"ObjectID","id":""}'); // 1. Query by id: replays the _id from the previous command await User.findById(alice._id); // another request await User.findById(forged()); // alice's document // 2. String path: forged BSONRegExp is sent as a regex await User.findOne({ password: JSON.parse('{"_bsontype":"BSONRegExp","pattern":"^S3","options":""}') }); // alice's document // 3. Stored value (default config): stores 12 bytes of the previous command await User.updateOne({ email: 'victim@example.com' }, { $set: { password: 'resetcode123' } }); // another request const c = await Comment.create({ post: forged() }); (await Comment.findById(c._id)).post.id.toString('latin1'); // 'il\x00\x13\x00\x00\x00victi' ``` ### Impact Applications on 6.3.5 to 6.13.12 are affected if they pass request values into queries or writes on ObjectId or String paths without checking that the values are primitive values. An attacker can: 1. read, modify or delete documents that another request just accessed, even with sanitizeFilter, express-mongo-sanitize or mongo-sanitize enabled; 2. read fragments of other requests’ database commands, such as emails, reset codes or API keys, by storing forged ObjectIds and reading them back; 3. run regex matches against String fields despite sanitizeFilter. Workaround: check that request values are strings, or use `mongoose.isValidObjectId()`, before passing them to Mongoose.

CVE-2026-142608 Affected Mongoose Versions

1 component(s)
Fixed Versions:
6.13.13
Product / Package Ecosystem Affected Versions Fixed Version
mongoose
npm
≥ 6.3.5
< 6.13.13
6.13.13

References

Frequently Asked Questions

What is CVE-2026-142608?
CVE-2026-142608 is a security vulnerability in Mongoose involving Plain objects with a forged _bsontype bypass ObjectId and String casting, leaking and replaying data from other command under CWE-843: Access of Resource Using Incompatible Type ('Type Confusion').
Which Mongoose versions are affected?
Affected versions include releases prior to 6.13.13 across affected packages: mongoose.
What version fixes CVE-2026-142608?
Upgrading to 6.13.13 (or the latest patched release for your respective branch) resolves the vulnerability.
Is mongoose affected?
Yes, mongoose is affected in releases prior to 6.13.13. Upgrade your dependency to 6.13.13 or later.
What is the CVSS score of CVE-2026-142608?
CVE-2026-142608 has a CVSS v3.1 base score of 0.0 (LOW) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N.
What CWE is associated with CVE-2026-142608?
CVE-2026-142608 is classified under CWE-843: Access of Resource Using Incompatible Type ('Type Confusion') (The product allocates or initializes a resource such as a pointer, object, or variable using one type, but it later accesses that resource using a type that is incompatible with the original type.).
How can I check npm dependencies for CVE-2026-142608?
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-rxm2-55pg-68q6",
  "modified" : "2026-12-03T00:29:57Z",
  "published" : "2026-12-03T00:29:57Z",
  "aliases" : [ "CVE-2026-142608" ],
  "summary" : "Mongoose: Plain objects with a forged _bsontype bypass ObjectId and String casting, leaking and replaying data from other command",
  "details" : "### Summary\n\nFrom 6.3.5-6.13.12, Mongoose 6 decides whether a value is a BSON type by checking only its _bsontype property. A plain object such as {\"_bsontype\":\"ObjectID\",\"id\":\"\"} therefore passes the ObjectId cast. bson 4.x then writes no id bytes but still advances 12 bytes in its serialization buffer, so the value sent to MongoDB is whatever the previous command left at that offset. Request bodies, cookies and Express 4 query strings can all produce such an object. sanitizeFilter doesn’t catch it because it has no $ keys.\n\n### Details\n\n`lib/helpers/isBsonType.js` returned true for any object whose `_bsontype` matched. This led to three problems:\n\n1. Queries by id replay another request’s id. findById(forged) sends the `_id` from the last command with the same layout, such as another request’s `findById` on the same collection. Likewise, `findByIdAndDelete(forged)` and `findByIdAndUpdate(forged)` act on the document another request just modified with `findOneAndUpdate`. This works with `sanitizeFilter` on.\n2. Stored ObjectIds leak command bytes. `create()`, `$set` and other writes store 12 bytes of earlier commands, such as filter values and updated fields. Anyone who can read the document can read those bytes. This happens in the default configuration.\n3. Forged regexes on String paths. `{\"_bsontype\":\"BSONRegExp\",\"pattern\":\"^a\",\"options\":\"\"}` passes the String query cast and is sent as a regular expression, bypassing sanitizeFilter.\n\n`mongoose.isObjectIdOrHexString()` also returns true for the forged object.\n\nThe fix makes `isBsonType()` ignore `_bsontype` when it is an own property. bson defines `_bsontype` on the prototype (except for the `Timestamp` class, which Mongoose does not check), so real bson values still pass.\n\n### Proof of concept\n\n```javascript\nmongoose.set('sanitizeFilter', true);\nconst User = mongoose.model('User', new mongoose.Schema({ email: String, password: String }));\nconst Comment = mongoose.model('Comment', new mongoose.Schema({ post: mongoose.ObjectId }));\nconst alice = await User.create({ email: 'alice@example.com', password: 'S3cret' });\nconst forged = () => JSON.parse('{\"_bsontype\":\"ObjectID\",\"id\":\"\"}');\n\n// 1. Query by id: replays the _id from the previous command\nawait User.findById(alice._id); // another request\nawait User.findById(forged()); // alice's document\n\n// 2. String path: forged BSONRegExp is sent as a regex\nawait User.findOne({ password: JSON.parse('{\"_bsontype\":\"BSONRegExp\",\"pattern\":\"^S3\",\"options\":\"\"}') }); // alice's document\n\n// 3. Stored value (default config): stores 12 bytes of the previous command\nawait User.updateOne({ email: 'victim@example.com' }, { $set: { password: 'resetcode123' } }); // another request\nconst c = await Comment.create({ post: forged() });\n(await Comment.findById(c._id)).post.id.toString('latin1'); // 'il\\x00\\x13\\x00\\x00\\x00victi'\n```\n\n### Impact\n\nApplications on 6.3.5 to 6.13.12 are affected if they pass request values into queries or writes on ObjectId or String paths without checking that the values are primitive values. An attacker can:\n\n1. read, modify or delete documents that another request just accessed, even with sanitizeFilter, express-mongo-sanitize or mongo-sanitize enabled;\n2. read fragments of other requests’ database commands, such as emails, reset codes or API keys, by storing forged ObjectIds and reading them back;\n3. run regex matches against String fields despite sanitizeFilter.\n\nWorkaround: check that request values are strings, or use `mongoose.isValidObjectId()`, before passing them to Mongoose.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "mongoose"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "6.3.5"
      }, {
        "fixed" : "6.13.13"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/Automattic/mongoose/security/advisories/GHSA-rxm2-55pg-68q6"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Automattic/mongoose/commit/61d7d7829716d4728d250aa0f0c712f318cf2aad"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/Automattic/mongoose"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-843" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-12-03T00:29:57Z",
    "nvd_published_at" : null
  }
}