本文へ移動
English version →
中 4.8

Mongoose: Discriminator key values matching inherited properties (e.g. __t: 'constructor') bypass schema casting and can poison collections

CVE-2026-125116 SecPulse初出

影響パッケージ

パッケージ影響を受ける版 → 修正版
Automatticmongoose —
npmmongoose
9.0.0 以上 9.11.4 未満→ 9.11.4
Bitnamimongoose
6.13.12 未満→ 6.13.12
7.0.0 以上 7.8.13 未満→ 7.8.13
8.0.0 以上 8.24.7 未満→ 8.24.7
9.0.0 以上 9.11.4 未満→ 9.11.4
原文の説明 取得元が公開している説明をそのまま載せています (多くは英語)。

Summary

Mongoose chooses which discriminator model or schema to use by looking up the discriminator key value (__t by default) in a plain object of registered discriminators, for example Model.discriminators[doc.__t]. That value comes from user documents and query filters. Because the lookup did not check own properties, a value that names a property inherited from Object.prototype resolves to that inherited value instead of a discriminator. Examples are 'constructor', 'toString' and 'hasOwnProperty'.

  • __t: 'constructor' resolves to the global Object function. Mongoose then calls new Object(doc), which returns the raw user object where a Mongoose document is expected.
  • __t: 'toString' and similar names resolve to built-in functions that throw when used as a constructor or schema.

The most serious effect: through bulkWrite() insertOne with skipValidation: true, the raw user object is stored as-is, without schema casting or strict filtering. After that, every query that returns the stored document throws, until the document is removed from the database.

Details

The registries that hold discriminators are plain objects: Model.discriminators, schema.discriminators, and the embedded discriminator registries on document arrays and single nested subdocuments. Several code paths indexed them directly with a value taken from the document or filter:

Code path Input
Model constructor (new Model(doc)) document
`Mod…

出典: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory

参照URL

当サイトでは、アクセス解析と広告の効果測定のためにCookieを使います。株式会社Gameのサイト共通の設定です。 詳しく