CVE-2026-106119: MongoDBChatMessageHistory Query Injection Vulnerability in @langchain/mongodb

@langchain/mongodb Updated 09 Oct 2026

Summary

08/10/2026
Yes i
Moderate
6.0

CVE-2026-106119: LangChain: MongoDBChatMessageHistory query injection can allow cross-session access. Affects @langchain/mongodb versions < 1.3.1. Fixed in 1.3.1. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

The @langchain/mongodb package is designed to facilitate the storage and retrieval of chat message histories in MongoDB databases. It allows applications to manage user conversations efficiently. However, the package has a vulnerability that arises from improper handling of session identifiers, which can lead to unauthorized access to user data.

Vulnerability Detail

The vulnerability in @langchain/mongodb stems from the failure to enforce the expected string type for session identifiers at runtime. This oversight allows structured session identifiers to be interpreted as MongoDB query conditions, potentially enabling an attacker to read, modify, or delete another user's chat history. This issue is particularly concerning in applications that store multiple users' histories in the same collection and pass untrusted session identifier input to the MongoDBChatMessageHistory.

How To Fix

Latest published version: 1.3.1 as of 22 Oct 2026

npm install @langchain/mongodb@1.3.1

The newest release already contains this fix.

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If an immediate upgrade is not feasible, implement the following workaround: Reject session identifiers that are not non-empty strings. Ensure that session identifiers are derived from an authenticated, server-controlled value and are not directly passed from untrusted request fields. Example code to validate session identifiers could look like this:

function validateSessionId(sessionId) {
  if (typeof sessionId !== 'string' || sessionId.trim() === '') {
    throw new Error('Invalid session identifier');
  }
  return sessionId;
}

Conclusion

The @langchain/mongodb package has a significant vulnerability that can lead to unauthorized access to user chat histories due to improper handling of session identifiers. It is crucial for users to upgrade to the patched version 1.3.1 or implement the suggested workarounds to mitigate risks.

See every vulnerability recorded for @langchain/mongodb →

Share this vulnerability

FAQ

The vulnerability allows for query injection through improperly validated session identifiers, potentially leading to unauthorized access to user chat histories.

Applications using @langchain/mongodb versions prior to 1.3.1 that store multiple users' chat histories in the same collection are at risk.

You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

Implement the recommended workaround by validating session identifiers to ensure they are non-empty strings derived from secure sources.

The CVSS score for this vulnerability is 6.0, indicating a moderate severity level.

How To Fix

Latest published version: 1.3.1 as of 22 Oct 2026

npm install @langchain/mongodb@1.3.1

The newest release already contains this fix.

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback