Vulnerabilities in pkg:npm/@langchain/mongodb

PACKAGE
Advisory Identifier: GHSA-m6rx-h84q-8r95
Advisory Summary

CVE-2026-106119 is a MODERATE mongodbchatmessagehistory query injection can allow vulnerability (CWE-943: Improper Neutralization of Special Elements in Data Query Logic) affecting LangChain libraries in the npm ecosystem. The issue involves mongodbchatmessagehistory query injection can allow cross-session access. Remediation is available by upgrading affected packages to version 1.3.1.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/@langchain/mongodb

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/@langchain/mongodb. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-m6rx-h84q-8r95 CVE-2026-106119 MODERATE LangChain: MongoDBChatMessageHistory query injection can allow cross-session access

CVE-2026-106119 at a Glance

CVE Identifier CVE-2026-106119
GHSA Identifier GHSA-m6rx-h84q-8r95
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-943: Improper Neutralization of Special Elements in Data Query Logic
Affected Product LangChain
Package Ecosystem npm
Published Date
Last Updated

How to Fix CVE-2026-106119

To remediate this vulnerability, upgrade all affected LangChain dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

@langchain/mongodb fixed: 1.3.1
npm install @langchain/mongodb@1.3.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls @langchain/mongodb

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-106119, inspect your project dependencies using npm:

npm ls @langchain/mongodb

Analyze the terminal output to locate any version of LangChain in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.3.1), your application is affected.

Note: The npm ls @langchain/mongodb command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-943: Improper Neutralization of Special Elements in Data Query Logic, where the product generates a query intended to access or manipulate data in a data store such as a database, but it does not neutralize or incorrectly neutralizes special elements that can modify the intended logic of the query. In LangChain, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## 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.

CVE-2026-106119 Affected LangChain Versions

1 component(s)
Fixed Versions:
1.3.1
Product / Package Ecosystem Affected Versions Fixed Version
@langchain/mongodb
npm
< 1.3.1
1.3.1

References

Frequently Asked Questions

What is CVE-2026-106119?
CVE-2026-106119 is a security vulnerability in LangChain involving MongoDBChatMessageHistory query injection can allow cross-session access under CWE-943: Improper Neutralization of Special Elements in Data Query Logic.
Which LangChain versions are affected?
Affected versions include releases prior to 1.3.1 across affected packages: @langchain/mongodb.
What version fixes CVE-2026-106119?
Upgrading to 1.3.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @langchain/mongodb affected?
Yes, @langchain/mongodb is affected in releases prior to 1.3.1. Upgrade your dependency to 1.3.1 or later.
What CWE is associated with CVE-2026-106119?
CVE-2026-106119 is classified under CWE-943: Improper Neutralization of Special Elements in Data Query Logic (The product generates a query intended to access or manipulate data in a data store such as a database, but it does not neutralize or incorrectly neutralizes special elements that can modify the intended logic of the query.).
How can I check npm dependencies for CVE-2026-106119?
Run the dependency tree command: 'npm ls @langchain/mongodb'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-m6rx-h84q-8r95",
  "modified" : "2026-10-08T17:52:22Z",
  "published" : "2026-10-08T17:52:22Z",
  "aliases" : [ "CVE-2026-106119" ],
  "summary" : "LangChain: MongoDBChatMessageHistory query injection can allow cross-session access",
  "details" : "## Impact\n\n`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.\n\nApplications 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.\n\nApplications that derive the session identifier from an authenticated, server-controlled value and enforce its type are not affected by this path.\n\n## Patches\n\nThe issue is fixed in `@langchain/mongodb` version **1.3.1**.\n\nUsers 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.\n\n## Workarounds\n\nIf 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.\n\nUpgrading remains the recommended remediation.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@langchain/mongodb"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.3.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.3.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/langchain-ai/langchainjs/security/advisories/GHSA-m6rx-h84q-8r95"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-106119"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/langchain-ai/langchainjs/pull/11672"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/langchain-ai/langchainjs/commit/946e3d856ff1f8ce7f7b9374c83f680a6ada79af"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/langchain-ai/langchainjs"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/langchain-ai/langchainjs/releases/tag/@langchain/mongodb@1.3.1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-943" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-10-08T17:52:22Z",
    "nvd_published_at" : "2026-10-06T19:17:42Z"
  }
}