{"id":"GHSA-pcrw-h46h-c93h","revision":"59886d96d6f54bd682908cf4acfb881a","records":[{"revision":"59886d96d6f54bd682908cf4acfb881a","observedAt":"2026-11-10T20:21:38.779+00:00","statement":{"source":"osv","id":"GHSA-pcrw-h46h-c93h","aliases":["CVE-2026-125120"],"title":"Mongoose: sanitizeFilter not applied on countDocuments","description":"### Impact\n\n`sanitizeFilter` is Mongoose's mechanism for protecting against query selector injection attacks. In older versions of Mongoose, `sanitizeFilter` was not applied for `countDocuments()` queries.\n\n### Patches\n\nPatches have been released for all supported Mongoose major release lines. Please upgrade to the following versions depending on which major version of Mongoose applications are using.\n\n1. `^9.9.2`\n2. `^8.24.3`\n3. `^7.8.12`\n4. `^6.13.11`\n\n### Workarounds\n\nMiddleware:\n\n```javascript\nmongoose.plugin(function() {\n  schema.pre('countDocuments', function() {\n    // This will always apply `sanitizeFilter` on `countDocuments`\n    mongoose.sanitizeFilter(this.getFilter());\n  });\n});\n```","state":0,"publishedAt":"2026-11-10T19:37:32+00:00","modifiedAt":"2026-11-10T19:45:09.6635131+00:00","affected":[{"ecosystem":"npm","name":"mongoose","ranges":[{"type":"SEMVER","events":[{"kind":"introduced","version":"0"},{"kind":"fixed","version":"6.13.11"}]}],"versions":[],"rawVersionEvidence":null},{"ecosystem":"npm","name":"mongoose","ranges":[{"type":"SEMVER","events":[{"kind":"introduced","version":"7.0.0"},{"kind":"fixed","version":"7.8.12"}]}],"versions":[],"rawVersionEvidence":null},{"ecosystem":"npm","name":"mongoose","ranges":[{"type":"SEMVER","events":[{"kind":"introduced","version":"8.0.0"},{"kind":"fixed","version":"8.24.3"}]}],"versions":[],"rawVersionEvidence":null},{"ecosystem":"npm","name":"mongoose","ranges":[{"type":"SEMVER","events":[{"kind":"introduced","version":"9.0.0"},{"kind":"fixed","version":"9.9.2"}]}],"versions":[],"rawVersionEvidence":null}],"metrics":[{"system":"CVSS_V3","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":null,"severity":null},{"system":"Publisher rating","vector":null,"score":null,"severity":"CRITICAL"}],"references":["https://github.com/Automattic/mongoose/security/advisories/GHSA-pcrw-h46h-c93h","https://nvd.nist.gov/vuln/detail/CVE-2026-125120","https://github.com/Automattic/mongoose/commit/7e912af3fac52cb0eea4cd71e24d65318916831a","https://github.com/Automattic/mongoose/commit/8b10d5760bb181f5bf5d01495cde161c8aed0557","https://github.com/Automattic/mongoose/commit/b1df045aab076b740fdaec14a15a44c694b85b7d","https://github.com/Automattic/mongoose/commit/b5003d3915db1cf9209c38a4b93cf3a92cddd710","https://github.com/Automattic/mongoose","https://github.com/Automattic/mongoose/releases/tag/6.13.11","https://github.com/Automattic/mongoose/releases/tag/7.8.12","https://github.com/Automattic/mongoose/releases/tag/8.24.3","https://github.com/Automattic/mongoose/releases/tag/9.9.2"],"sourceUrl":"https://github.com/advisories/GHSA-pcrw-h46h-c93h","license":"GitHub Advisory Database · CC-BY-4.0","key":"osv:GHSA-pcrw-h46h-c93h","identifiers":["GHSA-pcrw-h46h-c93h","CVE-2026-125120"]},"retained":false,"historicalAffected":[]}],"coverage":[]}