Skip to content
GitHub Security Advisories·Indexed by this site · Originally published· Event →SelectedAttention36

LangChain fixes query injection vulnerability in MongoDBChatMessageHistory

LangChain: MongoDBChatMessageHistory query injection can allow cross-session access

AI summary

LangChain's MongoDBChatMessageHistory component does not enforce validation of the string type of session identifiers at runtime, and structured session identifiers may be executed as MongoDB query conditions rather than literal identifiers. When an application passes untrusted session identifier input to this component and stores history for multiple users in the same collection, an attacker can read, modify, or delete conversations stored by other users. This issue has been fixed in version 1.3.1 of @langchain/mongodb, where the patch validates session identifiers at runtime and ensures they participate in queries as literal values; applications that cannot upgrade immediately should reject session identifiers other than non-empty strings and ensure identifiers come from authenticated server-controlled values.

Why it was selected

The announcement explains the affected conditions and fixed versions; teams using the LangChain MongoDB history component can use it to determine whether they are exposed.

Read originalgithub.com