NoSQL injection via array replacement bypassing update shape validation in driver write path
Impact
A MongoDB C# driver document-replacement code path omits the element-name/shape validation that the equivalent write paths apply, so a value supplied as a replacement is forwarded to the server without neutralization of query-language special elements. An application that passes untrusted, loosely-typed input as a replacement value therefore allows that input to be interpreted by the database as update logic rather than as data, executing under the application's own database credentials. Applications using strongly-typed document mappings are not affected.
Patches
From driver version 3.11.1, a replacement that is not a document is rejected with an ArgumentException instead of being sent to the server.
Workarounds
Make sure the replacement you pass to ReplaceOne, FindOneAndReplace or a bulk-write replace is a document, not a raw value such as an array.
References
[CSHARP-6158](https://jira.mongodb.org/browse/CSHARP-6158), [Fix](https://github.com/mongodb/mongo-csharp-driver/commit/27bc81ddeb407348fff57b3370aba360a13c5404), [CVE](https://www.cve.org/CVERecord?id=CVE-2026-81528)
Affected versions
| Package | Affected | Fixed in |
|---|---|---|
| MongoDB.Driver NuGet | >= 2.9.0, < 3.11.1 | 3.11.1 |
Details and references
- CVSS 3.1
- CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:N
- Severity from
- GitHub (reviewed advisory)
- Weakness
- CWE-943