CVE-2025-68665
📋 TL;DR
This vulnerability allows attackers to inject malicious serialized objects into LangChain applications by exploiting improper escaping of user-controlled data containing the 'lc' key. When deserialized, these objects are treated as legitimate LangChain objects rather than plain user data, potentially leading to remote code execution. All applications using vulnerable versions of LangChain JS are affected.
💻 Affected Systems
- LangChain JS
- @langchain/core
📦 What is this software?
Langchain Core by Langchain
Langchain Core by Langchain
Langchain.js by Langchain
Langchain.js by Langchain
⚠️ Risk & Real-World Impact
Worst Case
Remote code execution leading to complete system compromise, data theft, or lateral movement within the environment.
Likely Case
Arbitrary code execution within the application context, potentially allowing data exfiltration or privilege escalation.
If Mitigated
Limited impact with proper input validation and sanitization, potentially reduced to denial of service or information disclosure.
🎯 Exploit Status
Exploitation requires user input containing specially crafted 'lc' key structures that get serialized.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: LangChain JS 0.3.37, 1.2.3; @langchain/core 0.3.80, 1.1.8
Vendor Advisory: https://github.com/langchain-ai/langchainjs/security/advisories/GHSA-r399-636x-v7f6
Restart Required: Yes
Instructions:
1. Update LangChain JS to version 0.3.37 or 1.2.3. 2. Update @langchain/core to version 0.3.80 or 1.1.8. 3. Restart the application. 4. Test functionality.
🔧 Temporary Workarounds
Input Validation and Sanitization
allImplement strict input validation to reject or sanitize user data containing 'lc' keys before serialization.
🧯 If You Can't Patch
- Implement strict input validation to reject user data containing 'lc' keys.
- Use alternative serialization methods that properly escape special keys.
🔍 How to Verify
Check if Vulnerable:
Check package.json for LangChain JS version <0.3.37 or <1.2.3, or @langchain/core version <0.3.80 or <1.1.8.
Check Version:
npm list langchain @langchain/core
Verify Fix Applied:
Verify package.json shows LangChain JS version >=0.3.37 or >=1.2.3, and @langchain/core version >=0.3.80 or >=1.1.8.
📡 Detection & Monitoring
Log Indicators:
- Unusual serialization errors
- Unexpected 'lc' key in user input logs
- Abnormal application behavior post-serialization
Network Indicators:
- Unexpected outbound connections from the application
- Suspicious data exfiltration patterns
SIEM Query:
source="application_logs" AND ("lc" OR "serialization" OR "toJSON") AND severity="ERROR"
🔗 References
- https://github.com/langchain-ai/langchainjs/commit/e5063f9c6e9989ea067dfdff39262b9e7b6aba62
- https://github.com/langchain-ai/langchainjs/releases/tag/%40langchain%2Fcore%401.1.8
- https://github.com/langchain-ai/langchainjs/releases/tag/langchain%401.2.3
- https://github.com/langchain-ai/langchainjs/security/advisories/GHSA-r399-636x-v7f6
- https://github.com/langchain-ai/langchainjs/security/advisories/GHSA-r399-636x-v7f6