ThinkFacility Sign in
  1. Home
  2. Security
  3. npm package (mongoose)
Highnpm package (mongoose)

Mongoose 8.5 to 9.12: sanitizeProjection could leak hidden fields like password hashes, update now

Node.js developers whose apps use Mongoose with sanitizeProjection on and let users choose which fields a query returns.

How to fix it

You haveUpdate to
>= 8.5.0, < 8.24.10→8.24.10>= 9.0.0, < 9.12.2→9.12.2

Check your version

Which version your project has
npm ls mongoose

Update

In your project
npm update mongoose
npm ls mongoose
Still old? A dependency pins it
npm explain mongoose
Then check what's left
npm audit

sanitizeProjection is meant to stop a projection from the user pulling in fields the schema hides with select: false, like password hashes and reset tokens. Several projection forms got around it, so those fields could leak.

If npm ls still shows an old version under another package, update that package, or add an "overrides" entry for this one in package.json.

Sources