CVE-2026-142595
### Summary Mongoose's `sanitizeFilter` option is meant to block query selector injection. Before this fix, it only refused four top-level operators by name: `$jsonSchema`, `$where`, `$expr` and `$text`. Any other top-level `$` operator was passed to MongoDB unchanged. That includes undocumented internal operators like `$_internalSchemaXor` and `$_internalSchemaCond`, which take sub-filters, and `sanitizeFilter` never inspected those sub-filters. An attacker who controls the keys of a query filter could use them to slip arbitrary query selectors like `$ne` or `$regex` past `sanitizeFilter`. ### Details With `sanitizeFilter` enabled, Mongoose: - wraps any object value containing `$` keys in `$eq`, so `{ password: { $ne: null } }` becomes `{ password: { $eq: { $ne: null } } }`; - recurses into `$and`, `$or` and `$nor`; - throws on `$jsonSchema`, `$where`, `$expr` and `$text` unless the value is wrapped in `mongoose.trusted()`. Every other top-level key starting with `$` was left alone. MongoDB accepts several internal match expressions at the top level that contain nested filters, for example: - `$_internalSchemaXor: [filter1, filter2]` - `$_internalSchemaCond: [ifFilter, thenFilter, elseFilter]` Because `sanitizeFilter` doesn't recurse into these, the nested filters can contain any query selector. The fix makes `sanitizeFilter` refuse every top-level key that starts with `$`, except `$and`, `$or` and `$nor`, which it recurses into, and values wrapped in `mongoose.trusted()`. Nested `$and`/`$or`/`$nor` filters are checked the same way. This also means `sanitizeFilter` now refuses: - **`$comment`:** a user-supplied comment ends up in MongoDB's profiler and logs. Use `Query.prototype.comment()` instead, which sets the comment outside the filter. - **`$sampleRate`, `$alwaysTrue`, `$alwaysFalse`, and top-level `$ref`/`$id`/`$db`.** A top-level `$`-prefixed field name can't be queried with a plain equality filter in the first place: MongoDB rejects `{ $userId: 42
Properties
- Severity
- medium
- Summary
- Mongoose: `sanitizeFilter` bypass via MongoDB internal top-level query operators such as `$_internalSchemaXor`
- Nvd fetched at
- 2026-12-04T15:00:48.841578+00:00
- Epss score
- 0.00835
- Cvss severity
- MEDIUM
- Cvss score
- 6.5
- Retrieved at
- 2026-12-04T15:02:58+00:00
- Ghsa published
- 2026-12-04T00:05:04Z
- Source url
- https://github.com/advisories/GHSA-25v4-hrwm-qj9f
- Ghsa updated
- 2026-12-04T00:05:05Z
- Ghsa id
- GHSA-25v4-hrwm-qj9f
- Last source
- FIRST EPSS
- Score
- 6.5
- Cvss version
- 3.1
- Cve id
- CVE-2026-142595
- Cvss vector
- CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:N
- First seen by Signal
- 2026-12-02T22:45:38+00:00
- Name
- CVE-2026-142595
- Is ghsa only
- false
- Vector
- CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:N
Related Entities (3)
AFFECTS (1)
HAS_WEAKNESS (1)
VULNERABLE_TO (1)
Related research
Explore deeper with Ninja Signal's threat intelligence graph