CVE-2025-68664

9.3 CRITICAL

📋 TL;DR

A serialization injection vulnerability in LangChain's dumps() and dumpd() functions allows attackers to inject malicious data that gets treated as legitimate LangChain objects during deserialization. This affects all LangChain applications using these functions with user-controlled input. The vulnerability enables arbitrary object deserialization which can lead to remote code execution.

💻 Affected Systems

Products:
  • LangChain
  • LangChain Core
Versions: All versions prior to 0.3.81 and 1.2.5
Operating Systems: All operating systems running Python
Default Config Vulnerable: ⚠️ Yes
Notes: Vulnerability exists when using dumps() or dumpd() functions with user-controlled dictionaries containing 'lc' keys.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution leading to complete system compromise, data theft, and lateral movement within the environment.

🟠

Likely Case

Arbitrary code execution within the application context, potentially allowing data exfiltration, privilege escalation, or denial of service.

🟢

If Mitigated

Limited impact with proper input validation and sanitization, potentially causing application crashes or unexpected behavior.

🌐 Internet-Facing: HIGH - Web applications using LangChain with user input are directly exposed to exploitation.
🏢 Internal Only: MEDIUM - Internal applications are still vulnerable but have reduced attack surface compared to internet-facing systems.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploitation requires user input to reach vulnerable serialization functions, but the injection itself is straightforward.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 0.3.81 or 1.2.5

Vendor Advisory: https://github.com/langchain-ai/langchain/releases/tag/langchain-core%3D%3D0.3.81

Restart Required: No

Instructions:

1. Update LangChain Core: pip install --upgrade langchain-core>=0.3.81
2. Update LangChain: pip install --upgrade langchain>=1.2.5
3. Test serialization functions with your application data

🔧 Temporary Workarounds

Input Validation and Sanitization

all

Sanitize user input to remove or escape 'lc' keys before passing to serialization functions

Disable Vulnerable Functions

all

Replace dumps() and dumpd() with custom serialization that escapes 'lc' keys

🧯 If You Can't Patch

  • Implement strict input validation to reject dictionaries containing 'lc' keys
  • Use WAF rules to detect and block serialization payloads containing 'lc' key patterns

🔍 How to Verify

Check if Vulnerable:

Check if your code uses langchain.loads() or related functions with user-controlled data containing dictionaries

Check Version:

pip show langchain-core | grep Version && pip show langchain | grep Version

Verify Fix Applied:

Test that dictionaries with 'lc' keys are properly escaped during serialization and treated as plain data

📡 Detection & Monitoring

Log Indicators:

  • Unexpected deserialization errors
  • Unusual process execution from LangChain context
  • Stack traces containing langchain.loads()

Network Indicators:

  • Unusual outbound connections from LangChain processes
  • Data exfiltration patterns

SIEM Query:

source="application_logs" AND ("langchain.loads" OR "serialization error") AND ("lc" OR "injection")

🔗 References

📤 Share & Export