mongoose
9.12.2 · 16 Nov 2026MIT9.5M / weekRepositoryHomepagenpmAtom feed
Upgrading mongoose From 5.13.23 to 9.12.2
347 releases in betweennotes for 283
Reading releases, release notes and advisories…
Counted from 283 of 347 release notes, and the breaking changes of 2 pre-releases on the way to a major. Advisories are counted from the advisory database, in full.
Before you upgrade
Tick each one off as you go- Breaking9.3.0
- Breaking9.0.0
- Breaking9.0.0
- Breaking9.0.0
- Breaking9.0.0
- Breaking9.0.0
- Breaking9.0.0
- Breaking9.0.0
- Breaking9.0.0
- Breaking9.0.0
Security
Fixes 7 advisories affecting 5.13.23
- Mongoose: Prototype pollution in mongoose update casting via __proto__-prefixed dotted path (Schema._getSchema/path getter)moderate · GHSA-664h-wqgq-64gw
- Mongoose: Prototype pollution via Schema.prototype.virtual()moderate · GHSA-6972-9mcm-vhwj
- Mongoose walks into inherited properties when hydrating, setting, and merging, allowing overwrites of built-in functions (denial of service) and shared schema statehigh · GHSA-8332-j7wj-wjw4
- Mongoose: sanitizeFilter not applied on countDocumentscritical · GHSA-pcrw-h46h-c93h
- Mongoose search injection vulnerabilitycritical · GHSA-vg7j-7cwx-8wgw
- Mongoose's Improper Sanitization of $nor in sanitizeFilter May Allow NoSQL Injectionhigh · GHSA-wpg9-53fq-2r8h
- Mongoose: Discriminator key values matching inherited properties (e.g. __t: 'constructor') bypass schema casting and can poison collectionsmoderate · GHSA-wr5m-5jph-8m96
- 9.2.2
setDefaultsOnInsert: Check child filter paths before applying defaults, fix dot-notation handling, and prevent prototype pollution #16031 #16030
- 7.3.3
Avoid prototype pollution on init
Release by release
- Fixed
query: Make sanitizeFilter catch any fields that start with $ in top-level filter to avoid bypass using $_internalSchemaXor and other MongoDB internal expressions
- Fixed
query: Hardening for sanitizeProjection
- Fixed
array: Avoid converting BigInts to numbers in addToSet() #16693 luantaraschi
- Fixed
cursor: Propagate error passed to destroy() without re-emitting if error already emitted #16686 #16610 #16609 IbrahimHafez1
- Fixed
- New
update: Avoid quadratic ancestor lookup in update validators and validate nested array subdocs once #16586 github.com/Re-cool
- New
Keep lib/ source within Latin-1 #16681 orgads
- New
map: Avoid quadratic concat() when creating a MongooseMap from an object #16677 ptweezy
- Fixed
array: Keep earlier pushed values when push() is called again with $each #16619 #16618 maxymlyskov
- New
- New
Upgrade to mongodb driver 7.8 #16772 #16667
- New
Improve for document arrays: cache paths with defaults and schemas with select paths; avoid unnecessary $isModified() lookup #16595
- Fixed
array: Compare UUIDs by value in indexOf() so pull() and addToSet() work #16606 luantaraschi
- New
- Fixed
Avoid walking into inherited properties like
toStringwhen hydrating documents, setting dotted paths, and merging updates - Fixed
Only use own properties when looking up discriminators by key
- Fixed
schema: Disallow setting special properties via virtual()
- Fixed
query: Respect connection-level sanitizeFilter in queries
- Fixed
query: Disallow special properties like
__proto__as paths in where() and mod()
- Fixed
- Fixed
update: Honor overwriteImmutable in upserts and nested timestamps #16614 #15781 #8619 AbdelrahmanHafez
- Fixed
model: Stop Model.validate() crashing on missing nested objects #16600 NotAFlightRisk
- Fixed
connection: Don't disable autoIndex/autoCreate for a primary ReadPreference instance #16592 NgoQuocViet2001
- Fixed
- New
Avoid applying saveSubdocs and sharding plugins to subdocuments #16585
- New
Upgrade to kareem@3.4.1 for mongoosejs/kareem#47 #16588
- Fixed
model: Cast array filter values in bulkWrite() #16574 #16573 OmBhandwaldar
- Fixed
schema: Allow function messages for number min/max and string minlength #16579 #16572 #8512 NotAFlightRisk
- New
- Fixed
document: Call recursive toObject() when setting a path to a nested object #16571
- Fixed
update: Keep casting array filters after a path not in the schema #16558 giaBaoJS
- Fixed
document: Apply flattenDecimals when toObject() takes the shallow fast path #16569 #16568 jeremyml
- Fixed
query: Cast operators under $not inside $elemMatch on primitive arrays #16542 #13880 breken-ai
- Fixed
- New
Use MongoDB Node.js driver 7.7.x #16550
- New
query: Add Query.prototype.findAndCount() for composable paginated queries #16508 #16504 lokeshllkumar
- Fixed
Avoid double-calling validators on document arrays underneath nested paths #16484 #16291 #5411
- New
101 other lines we could not sort, mostly version bumps
- 9.11.2
types: Make MergeType more efficiently handle MergeType<A, {}> #16581 #16580
- 9.11.1
types(schema): treat Int32 paths as number #16565 #16564 lazerg
- 9.11.1
types(models): align UpdateOneModel and UpdateManyModel update typing with UpdateQuery #16559 #16545 aipd506
- 9.11.0
types: Pass TLeanResultType into query for type narrowing support with lean() #16523 #16519
- 9.10.1
types: Relax populate Model generics to allow typed virtuals to be passed to populate in TypeScript 7 with skipLibCheck #16503
- 9.9.2
types(document): respect schema toObject and toJSON options #16431 #15594 samuelmbabhazi
- 9.9.2
types: Import BSON from mongodb instead of bson #16434 #16434 orgads
- 9.8.1
types: Respect the
_idoption when inferring StandardSchema types #16402 - 9.8.1
types(model): keep
Model.schematyped whenTSchemais omitted samuelmbabhazi - 9.7.3
types: Use @standard-schema/spec for StandardSchema types rather than inlining #16341 #16339
402 internal lines (docs, tests, tooling) left out.
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.