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 hasnpm ls mongoose
Update
In your projectnpm update mongoose npm ls mongoose
npm explain mongoose
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.