Cabeçalho penumbroso

CVE-2026-142608: Validate Mongoose Inputs Before BSON Casting

CVE-2026-142608 affects Mongoose 6 applications that pass request-derived objects into certain query or write paths. The root problem is type confusion: Mongoose accepted an ordinary object that supplied its own _bsontype property and treated it as a trusted BSON value. Depending on the schema path and command layout, this can bypass expected casting or sanitization behavior and may expose or replay bytes from an earlier MongoDB command.

The CVE identifier appeared in the CVE record on December 2 UTC, which is December 3 in Asia/Shanghai. Automattic’s GitHub security advisory was already public on November 23, so the new identifier is not the date the issue was first disclosed.

A forged `_bsontype` marker can affect ObjectId serialization or bypass String casting through BSONRegExp; impact depends on the application path and command layout.

Start Your First Authorized Test

How the forged BSON marker changes the path

Mongoose 6 used _bsontype as a signal that an object was already a BSON type. A caller-controlled plain object could imitate that marker and reach code paths that expected a genuine BSON value. The fix commit tightens BSON type recognition instead of trusting an arbitrary object property.

The advisory describes two consequential cases:

  • ObjectId handling: one path can serialize stale bytes from an earlier command buffer into a later write, exposing a fragment of prior command data. A separate compatible-layout and buffer-offset condition can make a forged ObjectId value reuse bytes as an identifier, enabling identifier replay and potentially unauthorized read-modify-delete behavior. These are conditional paths, not evidence that every request leaks arbitrary database contents.
  • String-path handling: a forged BSONRegExp object can bypass normal casting to a String schema path and bypass Mongoose’s sanitizeFilter handling. Applications should not assume that this sanitizer makes every request-derived value safe if an object can masquerade as a BSON type.

Both cases are about what happens when untrusted object values cross into Mongoose’s BSON-aware query or write logic. The CVE does not establish a universal cross-tenant read, a remote-code-execution path, or impact in applications that reject the unexpected value before it reaches Mongoose.

Check the exact dependency range

O CVE Project record lists Mongoose versions 6.3.5 through 6.13.12 as affected and 6.13.13 as fixed. The GHSA page’s structured version table appears to drop a digit and display 6.3.12/6.3.13, while its narrative and the CVE record give 6.13.12/6.13.13. Use 6.13.13 as the minimum fixed Mongoose 6 release and verify the resolved package, not only the range in a manifest.

The public scoring metadata is also weak: the GHSA interface shows 0.0 while labeling the severity Low, and the CVE record lists 0.0 / None. That score is not a useful substitute for evaluating whether your application lets attacker-controlled objects reach affected paths.

Validate request values as primitive strings or approved identifiers, upgrade Mongoose 6.13.13, and verify the deployed dependency tree.

Start Your First Authorized Test

Trace request values into queries and writes

Start with the deployed dependency graph and search for Mongoose 6 installations, including nested dependencies and container or serverless build artifacts. Then trace values from JSON bodies, cookies, and query parsers into Mongoose filters, update documents, and ObjectId construction. Express 4 query parsing can produce object-shaped values; validate the runtime type at the boundary instead of assuming a value is a string because the route expects one.

For each affected path, ask:

Review question Evidence to collect
Can a remote user control an object value? Route schemas, body/query/cookie parsers, and request validation
Does that object reach a Mongoose 6 query or write? Query builders, update helpers, model methods, and shared repository code
Is the target path typed as ObjectId or String? Mongoose schema definitions and runtime casts
Are BSON-like instances intentionally accepted? Internal API contracts and validation rules; do not accept caller-supplied _bsontype as proof
Could command layout or buffer reuse make stale bytes relevant? The specific MongoDB command path and the advisory’s documented compatibility conditions

Prefer rejecting non-primitive values at external boundaries, then validate identifier syntax before constructing an ObjectId. For String paths, require a primitive string rather than an object that happens to pass through a cast. Keep sanitizeFilter enabled where appropriate, but do not treat it as the boundary validator for BSON-like objects.

Patch and add regression checks

Upgrade Mongoose 6 to 6.13.13 or later within a supported compatibility plan. Add tests that submit object-shaped values to every request-controlled ObjectId and String filter or write path. The expected result should be a validation error or a deliberate, safe conversion; no forged BSON-like object should be accepted because of a caller-supplied _bsontype field. Include multi-request tests only when they can safely confirm that identifiers or database command bytes are not carried across requests; do not reproduce the issue against production data.

After deployment, verify the resolved Mongoose version in the installed dependency tree and the actual application artifact. Recheck any custom query wrapper that performs its own BSON type checks, since upgrading the package does not correct separate application code that trusts _bsontype directly.

The following Penligent 3.0 video demonstrates a general product workflow. It is not evidence of exploitation or remediation of CVE-2026-142608.

The practical decision is narrow: identify Mongoose 6 request paths where object values can reach BSON-aware operations, upgrade to 6.13.13, and verify primitive-type checks at those boundaries. A newly assigned CVE number should prompt that review, but it should not be mistaken for a same-day vendor disclosure or proof that every Mongoose application is exploitable.

Compartilhe a postagem:
Publicações relacionadas
pt_BRPortuguese