NoSQL injection in LINQ pipeline translation
Medium6.5CVE-2026-81527 · Published Aug 27, 2026
### Impact A NoSQL/expression injection weakness exists in the LINQ-to-aggregation query translation layer of the MongoDB C# Driver. When application-supplied values are embedded in certain query constructs, special elements contained within those values are not properly escaped before the resulting query is transmitted to the database, so portions of the value may be interpreted by the database as query logic rather than as data. An authenticated user of an application that incorporates untrusted values into affected queries may thereby cause unintended data to be returned or query results to be altered. ### Patches From driver version 3.11.1, application-supplied values in LINQ queries are escaped with `$literal` where the server would otherwise evaluate them, an explicit `$eq` is retained around values that would be read as query operators, and field names derived from application data that cannot be represented safely are rejected with an `ExpressionNotSupportedException`. ### Workarounds Never build document keys from untrusted data, and do not accept user-supplied strings starting with $ where they will be evaluated as part of an aggregation expression — projections, `Grou...
Affected versions
| Package | Affected | Fixed in |
|---|---|---|
| MongoDB.Driver NuGet | >= 2.14.0, < 3.11.1 | 3.11.1 |
Details and references
### Impact A NoSQL/expression injection weakness exists in the LINQ-to-aggregation query translation layer of the MongoDB C# Driver. When application-supplied values are embedded in certain query constructs, special elements contained within those values are not properly escaped before the resulting query is transmitted to the database, so portions of the value may be interpreted by the database as query logic rather than as data. An authenticated user of an application that incorporates untrusted values into affected queries may thereby cause unintended data to be returned or query results to be altered. ### Patches From driver version 3.11.1, application-supplied values in LINQ queries are escaped with `$literal` where the server would otherwise evaluate them, an explicit `$eq` is retained around values that would be read as query operators, and field names derived from application data that cannot be represented safely are rejected with an `ExpressionNotSupportedException`. ### Workarounds Never build document keys from untrusted data, and do not accept user-supplied strings starting with $ where they will be evaluated as part of an aggregation expression — projections, `GroupBy` keys, `$expr` filters. This applies to expression filters passed to `UpdateMany` and `DeleteMany`. ### References [CSHARP-6178](https://jira.mongodb.org/browse/CSHARP-6178), [CSHARP-6156](https://jira.mongodb.org/browse/CSHARP-6156),[CSHARP-6185](https://jira.mongodb.org/browse/CSHARP-6185), [Fix](https://github.com/mongodb/mongo-csharp-driver/commit/230d4492e62915b6aa5e788cdcc38d0ab0ebd965), [CVE](https://www.cve.org/CVERecord?id=CVE-2026-81527)
- CVSS 3.1
- CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N
- Severity from
- GitHub (reviewed advisory)
- Weakness
- CWE-943
More MongoDB advisories
All MongoDB| Date | Advisory | Severity | Fixed in |
|---|---|---|---|
| Aug 27 | NoSQL injection via array replacement bypassing update shape validation in driver write path | Medium5.4 | 3.11.1 |
| Aug 27 | KMS master key exposure via unredacted credential serialization in driver settings string | Medium5.6 | 3.11.1 |
| Aug 27 | Connection-option injection via unescaped settings in the canonical MongoDB URL builder | High7.1 | 3.11.1 |
| Aug 27 | Cross-tenant database retargeting via dot/NUL injection in namespace strings in the PHP Driver | High8.1 | 1.21.4+1 more |
| Aug 27 | Cross-database write retargeting via unvalidated dotted database name in Client.BulkWrite | High7.1 | 2.8.2 |
| Aug 27 | Cross-database write redirection via unvalidated dotted database name in bulk write namespaces | Medium6.5 | 3.8.2 |