LangChain: MongoDBChatMessageHistory query injection can allow cross-session access
Impact
MongoDBChatMessageHistory did not enforce the documented string type for session identifiers at runtime. In affected applications, a structured session identifier could be interpreted as a MongoDB query condition rather than as a literal identifier.
Applications are affected when they pass untrusted session identifier input to MongoDBChatMessageHistory and store multiple users’ histories in the same collection. An attacker who can invoke chat-history operations may be able to read, modify, or delete another user’s stored conversation.
Applications that derive the session identifier from an authenticated, server-controlled value and enforce its type are not affected by this path.
Patches
The issue is fixed in @langchain/mongodb version 1.3.1.
Users of affected versions should upgrade to version 1.3.1 or later. The patched version validates session identifiers at runtime and ensures they are compared as literal values in MongoDB queries.
Workarounds
If an immediate upgrade is not possible, applications must reject session identifiers that are not non-empty strings. Session identifiers should be derived from an authenticated, server-controlled value and must not be passed directly from an untrusted request field.
Upgrading remains the recommended remediation.
Affected software
Click a technology to see all vulnerabilities affecting it.
| Platform | Package | Vulnerable versions | Fixed in |
|---|---|---|---|
| npm package | @langchain/mongodb | < 1.3.1 | 1.3.1 |
References
- https://github.com/langchain-ai/langchainjs/security/advisories/GHSA-m6rx-h84q-8r95
- https://nvd.nist.gov/vuln/detail/CVE-2026-106119
- https://github.com/langchain-ai/langchainjs/pull/11672
- https://github.com/langchain-ai/langchainjs/commit/946e3d856ff1f8ce7f7b9374c83f680a6ada79af
- https://github.com/langchain-ai/langchainjs
- https://github.com/langchain-ai/langchainjs/releases/tag/@langchain/mongodb@1.3.1
- CVSS vector
CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:H/VI:L/VA:N/SC:N/SI:N/SA:N- Weakness (CWE)
CWE-943- Platform
- npm
- Package
@langchain/mongodb- Disclosed
- 08.10.2026
- Updated
- 11.10.2026 10:22
Sources and licenses
OSV / GitHub Advisory Database - GHSA-m6rx-h84q-8r95 - CC BY 4.0
Vulnerability history: @langchain/mongodb
All published vulnerabilities of this package (npm package), newest first. Shows whether this is a one-off slip or a package that needs watching.
This is the only known vulnerability of this package.
Know which vulnerabilities affect your application
With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.