{"id":"GHSA-gg4r-jv3p-qx3c","revision":"aa5ceda68fc247eb8f8978319da0eb8f","records":[{"revision":"aa5ceda68fc247eb8f8978319da0eb8f","observedAt":"2026-11-10T20:21:38.779+00:00","statement":{"source":"osv","id":"GHSA-gg4r-jv3p-qx3c","aliases":["CVE-2026-125119"],"title":"Mongoose: Connection-level sanitizeFilter not applied","description":"### Summary\n\nsanitizeFilter exists to stop query selector injection: it wraps operator objects such as `{ $ne: null }` in filter values in `$eq`, so they are matched literally. Set on a connection with `mongoose.connect()` or `createConnection(uri, { sanitizeFilter: true })`, the connection reports it as enabled but queries never apply it. An application that relies on the connection-level option and passes an attacker-controlled object into a filter therefore remains open to selector injection, and a password value of `{ $ne: null }` returns the account record without the password.\n\n### Details\n\n`NativeConnection#createClient()` at `lib/drivers/node-mongodb-native/connection.js:270-272` moves `options.sanitizeFilter` into `Connection.config` and deletes the original option. `Query#_castConditions()` at `lib/query.js:2413-2423` checks `Connection.options`, the global `options`, and the per-query options, but never `Connection.config`. The defense therefore does not run even though `Connection#get('sanitizeFilter')` returns true. This storage was introduced in Mongoose 6.0.0 and the same mismatch is present in 9.11.2.\n\n### Proof of concept\n\n```javascript\nimport mongoose from 'mongoose'\n\nconst conn = await mongoose.createConnection('<MONGODB_URI>', { sanitizeFilter: true }).asPromise()\nconst User = conn.model('User', new mongoose.Schema({\n  username: String,\n  password: String,\n  marker: String\n}))\n\nawait User.create({\n  username: 'victim',\n  password: 'correct-password',\n  marker: 'PROTECTED_RECORD'\n})\n\nconst filter = { username: 'victim', password: { $ne: null } }\nconsole.log(conn.get('sanitizeFilter'))\nconsole.log((await User.findOne(filter).lean()).marker)\n```\n\nA control query with a literal wrong password returned no document in the same run, confirming the filter is otherwise enforced.\n\n### Impact\n\nConnection-level `sanitizeFilter` option is not respected. Any user that relies on connection-level config and `sanitizeFilter` to defend against query selector injection is affected. Users that set `sanitizeFilter` globally using `mongoose.set('sanitizeFilter')` or on specific queries using `Model.find().sanitizeFilter()` are not affected.","state":0,"publishedAt":"2026-11-10T19:56:12+00:00","modifiedAt":"2026-11-10T20:00:05.0347511+00:00","affected":[{"ecosystem":"npm","name":"mongoose","ranges":[{"type":"SEMVER","events":[{"kind":"introduced","version":"6.0.0"},{"kind":"fixed","version":"6.13.12"}]}],"versions":[],"rawVersionEvidence":null},{"ecosystem":"npm","name":"mongoose","ranges":[{"type":"SEMVER","events":[{"kind":"introduced","version":"7.0.0"},{"kind":"fixed","version":"7.8.13"}]}],"versions":[],"rawVersionEvidence":null},{"ecosystem":"npm","name":"mongoose","ranges":[{"type":"SEMVER","events":[{"kind":"introduced","version":"8.0.0"},{"kind":"fixed","version":"8.24.7"}]}],"versions":[],"rawVersionEvidence":null},{"ecosystem":"npm","name":"mongoose","ranges":[{"type":"SEMVER","events":[{"kind":"introduced","version":"9.0.0"},{"kind":"fixed","version":"9.11.4"}]}],"versions":[],"rawVersionEvidence":null}],"metrics":[{"system":"CVSS_V3","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","score":null,"severity":null},{"system":"Publisher rating","vector":null,"score":null,"severity":"HIGH"}],"references":["https://github.com/Automattic/mongoose/security/advisories/GHSA-gg4r-jv3p-qx3c","https://nvd.nist.gov/vuln/detail/CVE-2026-125119","https://github.com/Automattic/mongoose/commit/4bb659478be2f30655a7bdd78bc251bdf111cd29","https://github.com/Automattic/mongoose/commit/4f4f9a79f860786a54133bee2c9af967ec691491","https://github.com/Automattic/mongoose/commit/83eda6af1489e9ef60bb8eee8cf9ee005771b9d5","https://github.com/Automattic/mongoose/commit/b8970c25998c23fbccd17f76c0398b902ff4911d","https://github.com/Automattic/mongoose","https://github.com/Automattic/mongoose/releases/tag/6.13.12","https://github.com/Automattic/mongoose/releases/tag/7.8.13","https://github.com/Automattic/mongoose/releases/tag/8.24.7","https://github.com/Automattic/mongoose/releases/tag/9.11.4"],"sourceUrl":"https://github.com/advisories/GHSA-gg4r-jv3p-qx3c","license":"GitHub Advisory Database · CC-BY-4.0","key":"osv:GHSA-gg4r-jv3p-qx3c","identifiers":["GHSA-gg4r-jv3p-qx3c","CVE-2026-125119"]},"retained":false,"historicalAffected":[]}],"coverage":[]}