CVE-2026-142608
Mongoose: Plain objects with a forged _ bsontype bypass ObjectId and String casting, leaking and replaying data from other command (npm)
- Severity
- 0.0NoneNetwork attack, no privileges, no user interactionCVSS 3.1, CVE List
- Exploitation
- Proof of conceptCISA reports one, no source links it
- Exploit chance
- 0.70% in 30 daysPercentile54thEPSS, scored
- Listed fix
6.13.13for mongooseFrom GitHub Advisories and OSV
Overview
Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. From 6.3.5 until 6.13.13, Mongoose treats a plain object with an own _bsontype property as a BSON value, allowing forged ObjectID values to replay an identifier from a preceding database command when that command has a compatible layout and buffer offset, or to store and disclose other command-buffer fragments, while forged BSONRegExp values bypass String-path filtering. Applications that pass request-derived values into ObjectId or String queries and writes can consequently read, modify, or delete documents accessed by another request under the compatible-layout condition, store and disclose fragments such as reset codes or API keys without that identifier-replay condition, or execute unintended regular-expression matches even when sanitizeFilter or common MongoDB sanitizers are enabled. This issue is fixed in version 6.13.13.
CVSS 3.1 vector
Exploitability
- Attack vector
- Network
- Complexity
- Low
- Privileges needed
- None
- User interaction
- None
Impact
- Scope
- Unchanged
- Confidentiality
- None
- Integrity
- None
- Availability
- None
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:NExploit chance over time
Affected
Packages 1
| Package | Affected | Fixed |
|---|---|---|
mongoosenpm | 6.3.5 up to 6.13.13 | 6.13.13 |
Products 1
Sources
CVE List Score usedCVSS 3.10.0
Mongoose: Plain objects with a forged _bsontype bypass ObjectId and String casting, leaking and replaying data from other command
Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. From 6.3.5 until 6.13.13, Mongoose treats a plain object with an own _bsontype property as a BSON value, allowing forged ObjectID values to replay an identifier from a preceding database command when that command has a compatible layout and buffer offset, or to store and disclose other command-buffer fragments, while forged BSONRegExp values bypass String-path filtering. Applications that pass request-derived values into ObjectId or String queries and writes can consequently read, modify, or delete documents accessed by another request under the compatible-layout condition, store and disclose fragments such as reset codes or API keys without that identifier-replay condition, or execute unintended regular-expression matches even when sanitizeFilter or common MongoDB sanitizers are enabled. This issue is fixed in version 6.13.13.
- Record
CVE-2026-142608- CVSS 3.1
- 0.0 None
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N - Weakness
- CWE-843
- Updated
- 2026-12-03
EUVDEUVD-2026-141932No score
Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. From 6.3.5 until 6.13.13, Mongoose treats a plain object with an own _bsontype property as a BSON value, allowing forged ObjectID values to replay an identifier from a preceding database command when that command has a compatible layout and buffer offset, or to store and disclose other command-buffer fragments, while forged BSONRegExp values bypass String-path filtering. Applications that pass request-derived values into ObjectId or String queries and writes can consequently read, modify, or delete documents accessed by another request under the compatible-layout condition, store and disclose fragments such as reset codes or API keys without that identifier-replay condition, or execute unintended regular-expression matches even when sanitizeFilter or common MongoDB sanitizers are enabled. This issue is fixed in version 6.13.13.
- Record
EUVD-2026-141932- Updated
- 2026-12-03
GitHub AdvisoriesGHSA-rxm2-55pg-68q6CVSS 3.10.0
Mongoose: Plain objects with a forged _bsontype bypass ObjectId and String casting, leaking and replaying data from other command
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:
- Queries by id replay another request’s id. findById(forged) sends the
_idfrom the last command with the same layout, such as another request’sfindByIdon the same collection. Likewise,findByIdAndDelete(forged)andfindByIdAndUpdate(forged)act on the document another request just modified withfindOneAndUpdate. This works withsanitizeFilteron. - Stored ObjectIds leak command bytes.
create(),$setand 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. - 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
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:
- read, modify or delete documents that another request just accessed, even with sanitizeFilter, express-mongo-sanitize or mongo-sanitize enabled;
- read fragments of other requests’ database commands, such as emails, reset codes or API keys, by storing forged ObjectIds and reading them back;
- run regex matches against String fields despite sanitizeFilter.
Workaround: check that request values are strings, or use mongoose.isValidObjectId(), before passing them to Mongoose.
- Record
GHSA-rxm2-55pg-68q6- CVSS 3.1
- 0.0 None
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N - Weakness
- CWE-843
- Updated
- 2026-12-03
NVDCVSS 3.10.0
Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. From 6.3.5 until 6.13.13, Mongoose treats a plain object with an own _bsontype property as a BSON value, allowing forged ObjectID values to replay an identifier from a preceding database command when that command has a compatible layout and buffer offset, or to store and disclose other command-buffer fragments, while forged BSONRegExp values bypass String-path filtering. Applications that pass request-derived values into ObjectId or String queries and writes can consequently read, modify, or delete documents accessed by another request under the compatible-layout condition, store and disclose fragments such as reset codes or API keys without that identifier-replay condition, or execute unintended regular-expression matches even when sanitizeFilter or common MongoDB sanitizers are enabled. This issue is fixed in version 6.13.13.
- Record
CVE-2026-142608- CVSS 3.1
- 0.0 None
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N - Weakness
- CWE-843
- Updated
- 2026-12-03
OSVCVSS 3.10.0
Mongoose: Plain objects with a forged _bsontype bypass ObjectId and String casting, leaking and replaying data from other command
Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. From 6.3.5 until 6.13.13, Mongoose treats a plain object with an own _bsontype property as a BSON value, allowing forged ObjectID values to replay an identifier from a preceding database command when that command has a compatible layout and buffer offset, or to store and disclose other command-buffer fragments, while forged BSONRegExp values bypass String-path filtering. Applications that pass request-derived values into ObjectId or String queries and writes can consequently read, modify, or delete documents accessed by another request under the compatible-layout condition, store and disclose fragments such as reset codes or API keys without that identifier-replay condition, or execute unintended regular-expression matches even when sanitizeFilter or common MongoDB sanitizers are enabled. This issue is fixed in version 6.13.13.
- Record
CVE-2026-142608- CVSS 3.1
- 0.0 None
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N - Weakness
- CWE-843
- Updated
- 2026-12-03
OSVGHSA-rxm2-55pg-68q6CVSS 3.10.0
Mongoose: Plain objects with a forged _bsontype bypass ObjectId and String casting, leaking and replaying data from other command
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:
- Queries by id replay another request’s id. findById(forged) sends the
_idfrom the last command with the same layout, such as another request’sfindByIdon the same collection. Likewise,findByIdAndDelete(forged)andfindByIdAndUpdate(forged)act on the document another request just modified withfindOneAndUpdate. This works withsanitizeFilteron. - Stored ObjectIds leak command bytes.
create(),$setand 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. - 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
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:
- read, modify or delete documents that another request just accessed, even with sanitizeFilter, express-mongo-sanitize or mongo-sanitize enabled;
- read fragments of other requests’ database commands, such as emails, reset codes or API keys, by storing forged ObjectIds and reading them back;
- run regex matches against String fields despite sanitizeFilter.
Workaround: check that request values are strings, or use mongoose.isValidObjectId(), before passing them to Mongoose.
- Record
GHSA-rxm2-55pg-68q6- CVSS 3.1
- 0.0 None
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N - Weakness
- CWE-843
- Updated
- 2026-12-03
History
Recorded by Every CVE
| Day | Changed | Sources |
|---|---|---|
| Published date | EUVD, NVD | |
| Key facts, references | CVE List | |
| Published date | EUVD | |
| Affected packages, references | OSV | |
| Affected packages, key facts, references | GitHub Advisories | |
| Other IDs, references | OSV | |
| Other IDs, published date | EUVD, NVD | |
| First indexed | CVE List |
Upstream dates may differ.
References
github.com/Automattic/mongoose/security/advisories/GHSA-rxm2-55pg-68q6
github.com/Automattic/mongoose/commit/61d7d7829716d4728d250aa0f0c712f318cf2aad
github.com/advisories/GHSA-rxm2-55pg-68q6
github.com/CVEProject/cvelistV5/tree/main/cves/2026/142xxx/CVE-2026-142608.json
nvd.nist.gov/vuln/detail/CVE-2026-142608
github.com/Automattic/mongoose