GHSA-wpg9-53fq-2r8h

Suggest an improvement
Source
https://github.com/advisories/GHSA-wpg9-53fq-2r8h
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/05/GHSA-wpg9-53fq-2r8h/GHSA-wpg9-53fq-2r8h.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-wpg9-53fq-2r8h
Aliases
  • CVE-2026-42334
Published
2026-05-05T21:48:06Z
Modified
2026-05-14T21:05:57.896393Z
Severity
  • 7.5 (High) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N CVSS Calculator
Summary
Mongoose's Improper Sanitization of $nor in sanitizeFilter May Allow NoSQL Injection
Details

Impact

This vulnerability allows bypassing Mongoose’s sanitizeFilter query sanitization mechanism via the $nor operator.

When sanitizeFilter is enabled, Mongoose wraps query operators in $eq to neutralize them. However, prior to the fix, $nor was not included in the set of logical operators that are recursively sanitized. Because $nor accepts an array (like $and and $or), and arrays do not trigger hasDollarKeys(), malicious operators such as $ne, $gt, or $regex could be injected inside a $nor clause without being sanitized.

This may lead to:

  • Authentication bypass
  • Unauthorized data access
  • Data exfiltration

Affected users:

Applications that:

  • Explicitly enable sanitizeFilter
  • Pass unsanitized user-controlled input directly into query methods (e.g., Model.findOne(req.body)) and rely on sanitizeFilter to strip out query selectors

Applications that validate input schemas, whitelist fields, or avoid passing raw request bodies into queries are not affected. For example, Model.findOne({ user: req.body.user, pwd: req.body.pwd }) is not affected.

Patches

Patches have been released for all supported Mongoose release lines:

  • ^6.13.9
  • ^7.8.9
  • ^8.22.1
  • ^9.1.6

Workarounds

Delete $nor keys, use an additional schema validation library, or write middleware to strip out $nor from query filters.

Resources

sanitizeFilter documentation: https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.sanitizeFilter()

Original blog post on sanitizeFilter: https://thecodebarbarian.com/whats-new-in-mongoose-6-sanitizefilter.html

Database specific
{
    "severity": "HIGH",
    "cwe_ids": [
        "CWE-74"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-05-05T21:48:06Z",
    "nvd_published_at": "2026-05-14T18:16:47Z"
}
References

Affected packages

npm / mongoose

Package

Affected ranges

Type
SEMVER
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
6.13.9

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/05/GHSA-wpg9-53fq-2r8h/GHSA-wpg9-53fq-2r8h.json"

npm / mongoose

Package

Affected ranges

Type
SEMVER
Events
Introduced
7.0.0
Fixed
7.8.9

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/05/GHSA-wpg9-53fq-2r8h/GHSA-wpg9-53fq-2r8h.json"
last_known_affected_version_range
"<= 7.8.8"

npm / mongoose

Package

Affected ranges

Type
SEMVER
Events
Introduced
8.0.0
Fixed
8.22.1

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/05/GHSA-wpg9-53fq-2r8h/GHSA-wpg9-53fq-2r8h.json"
last_known_affected_version_range
"<= 8.22.0"

npm / mongoose

Package

Affected ranges

Type
SEMVER
Events
Introduced
9.0.0
Fixed
9.1.6

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/05/GHSA-wpg9-53fq-2r8h/GHSA-wpg9-53fq-2r8h.json"
last_known_affected_version_range
"<= 9.1.5"