All vulnerabilities

npm

CVE-2026-142608

Mongoose: Plain objects with a forged _bsontype bypass ObjectId and String casting, leaking and replaying data from other command

Severity
Low
Published
3 Dec 2026
Last changed
3 Dec 2026
Added to UpHeron
3 Dec 2026
Fixed in
6.13.13
Weakness
CWE-843
Attack
Over the network · No login needed · No user action needed
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N
Also known as
GHSA-rxm2-55pg-68q6
Sources
OSV.dev and GitHub

Description

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.

lib/helpers/isBsonType.js returned true for any object whose _bsontype matched. This led to three problems:

  • 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.
From the GitHub Advisory Database, CC BY 4.0. Shortened; the full text is there.

Affected software

SoftwareAffected versions
mongoosenpm · osv:npm:mongoose
  • From 6.3.5 before 6.13.13

About mongoose

Weekly downloads (npm)
8,359,311npm, 1 Dec 2026

References