Skip to content
KitploitKITPLOIT
工具漏洞利用博客
Log in
提交
工具漏洞利用博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

订阅源联系隐私© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
CVE-2026-105437 — 针对 CVE-2026-105437 的 PoC 与实验环境,该漏洞是 Git 的 xdiff 三方合并中的 32 位整数溢出,可通过 git merge-tree 和 conflict-marker-size 导致堆缓冲区溢出。 | Kitploit
工具/GitHubGitHub/googlesky/cve-2026-105437
代码分析漏洞利用模糊测试二进制利用实验室与实践
GitHubgooglesky/cve-2026-105437

CVE-2026-105437

针对 CVE-2026-105437 的 PoC 与实验环境,该漏洞是 Git 的 xdiff 三方合并中的 32 位整数溢出,可通过 git merge-tree 和 conflict-marker-size 导致堆缓冲区溢出。

查看仓库
4天前尚未审核
分享

CVE-2026-105437 — Git 三方合并堆缓冲区溢出

CVECVE-2026-105437
组件Git — 三方合并机制,xdiff/xmerge.c(xdl_fill_merge_buffer())
受影响版本Git ≤ 2.56.0(以及 2.50 – 2.55 系列)
修复版本Git 2.56.1,以及 2.50.2 / 2.51.3 / 2.52.1 / 2.53.1 / 2.54.1 / 2.55.1
CWECWE-190(整数溢出)导致 CWE-787(越界写入)
影响在合并攻击者控制的内容时发生堆缓冲区溢出(越界写入)
向量git merge-tree --write-tree,即合并请求的可合并性检查
触发条件一个已提交的 .gitattributes 携带 conflict-marker-size=<huge>,再加上一次产生大量冲突的合并

任何能够向仓库推送分支并创建合并请求的用户,都可以使托管服务的合并机制崩溃。Git 使用 32 位 int 计算合并输出缓冲区的大小;当冲突足够多且 conflict-marker-size 属性足够大时,累加器会发生回绕,malloc() 返回的缓冲区远小于所需大小,合并结果便被写入到缓冲区末尾之外。

分配该 CVE 的 GitLab 将 git merge-tree 列为主要攻击面——托管服务器运行它来判断合并请求是否可以被合并。用户只需提交一个 .gitattributes 文件并推送一个分支即可。

除溢出本身之外,本仓库还记录了 GitLab 随公告发布的缓解措施中的一个缺陷:info/attributes 变通方案按原文所述无法生效,会使服务仍然处于暴露状态。


1. 根本原因

在写入合并结果之前,Git 会计算输出缓冲区需要多大。在 xdiff/xmerge.c(Git 2.56.0)中:

static int fill_conflict_hunk(..., int size, ..., int marker_size)
{
	...
	if (!dest) {
		size += marker_size + 1 + needs_cr + marker1_size;   /* (1) */
	} else {
		memset(dest + size, '<', marker_size);
		size += marker_size;
		...
	}
	...
	if (!dest) {
		size += marker_size + 1 + needs_cr;                    /* (2) */
	} else {
		memset(dest + size, '=', marker_size);
		...
	}
	...
	if (!dest) {
		size += marker_size + 1 + needs_cr + marker2_size;     /* (3) */
	} else {
		memset(dest + size, '>', marker_size);
		...
	}
	return size;
}

static int xdl_fill_merge_buffer(..., int marker_size)
{
	int size, i;                        /* <-- 32-bit accumulator */
	for (size = i = 0; m; m = m->next) {
		...
		size = fill_conflict_hunk(..., size, ..., marker_size);
	}
	...
}

并精确分配相应数量的字节:

/* xdl_do_merge() */
int size = xdl_fill_merge_buffer(xe1, name1, xe2, name2,
                                 ancestor_name, favor, changes, NULL, style,
                                 marker_size);
result->ptr = xdl_malloc(size);
...
/* second pass: write into the buffer */
xdl_fill_merge_buffer(xe1, name1, xe2, name2, ancestor_name, favor, changes,
                      result->ptr, style, marker_size);

累加器是一个 int(32 位),而真正起作用的加数有:

  • 冲突标记文本,每个标记 marker_size 字节,以及
  • 每个冲突块三个标记(<<<<<<<、=======、>>>>>>>)。

marker_size 来自 conflict-marker-size git 属性,直接从仓库的 .gitattributes 中读取 (merge-ll.c:ll_merge_marker_size() → strtol_i() 存入 int,除 INT_MAX 外没有 上限)。

设冲突块数量为 N、标记大小为 M,总量约为 3 * N * M 字节。一旦超过 INT_MAX,累加器就会回绕:

  • 如果回绕为负值 → malloc() 收到一个巨大的 size_t, 分配失败,Git 报告一个虚假的内存不足错误;
  • 如果回绕为一个较小的正值 → malloc() 成功,但 缓冲区远小于所需大小,写入过程会越过分配区域的末尾 → 堆缓冲区溢出。

上游修复(Git 2.56.1)将累加器和所有加数转换为 size_t,并使用带检查的算术运算(st_add()、st_add5()):

288266c11d91  xdiff: use size_t for merge buffer size computations
b1313872cefe  xdiff: check for overflow when computing merge buffer size
0dc3b5c0224b  git-compat-util: add st_add5() helper to detect size_t overflow

证明(Git 2.56.0 的 AddressSanitizer 构建)

==1386014==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7b85df1fe9fb
WRITE of size 3495254 at 0x7b85df1fe9fb thread T0
    #0 memset
    #1 fill_conflict_hunk            xdiff/xmerge.c:269
    #2 xdl_fill_merge_buffer         xdiff/xmerge.c:297
    #3 xdl_do_merge                  xdiff/xmerge.c:671
    #4 xdl_merge                     xdiff/xmerge.c:726
    #5 ll_xdl_merge                  merge-ll.c:144
    #6 ll_merge                      merge-ll.c:448
    #7 merge_3way                    merge-ort.c:2161
    #8 handle_content_merge          merge-ort.c:2260
    #9 process_entry                 merge-ort.c:4345
   #10 process_entries               merge-ort.c:4566
   #11 merge_ort_nonrecursive_internal  merge-ort.c:5288
   #12 merge_ort_internal            merge-ort.c:5390
   #13 merge_incore_recursive        merge-ort.c:5449
   #14 real_merge                    builtin/merge-tree.c:490
   #15 cmd_merge_tree                builtin/merge-tree.c:696
0x7b85df1fe9fb is located 0 bytes to the right of 109108118-byte region
SUMMARY: AddressSanitizer: heap-buffer-overflow xdiff/xmerge.c:269 in fill_conflict_hunk

2. 攻击面

GitLab 的公告将 git merge-tree 列为主要攻击向量:

“分配了 CVE-2026-105437 的 GitLab 表示,代码托管服务器最有可能通过 git merge-tree 成为攻击目标。服务器可能会运行该命令,以检查拉取请求或合并请求是否可以合并。”

以及:

“conflict-marker-size 属性可以在提交到仓库的 .gitattributes 文件中设置。如果服务器从仓库读取属性,那么任何能够推送分支并打开拉取请求或合并请求的用户都可以触发该漏洞。”

流程:

 attacker (any user who can push)            hosting service (Gitaly)
 ─────────────────────────────────────────    ────────────────────────────────
 1. commit .gitattributes:                    4. merge request opened /
      big.txt conflict-marker-size=3495254       mergeability check
 2. push main / feature/ours / feature/theirs 5. git merge-tree --write-tree \
 3. open a merge request                          feature/ours feature/theirs
                                                 6. GIT_ATTR_SOURCE points at the
                                                    repository tree, so the
                                                    committed .gitattributes is
                                                    honoured
                                                 7. *** heap buffer overflow ***

GIT_ATTR_SOURCE 是指针对裸仓库运行的服务器如何让 Git 从仓库树而不是工作树中读取 .gitattributes —— 这正是 Gitaly 的做法。

GitLab 发布的变通方案 —— 按原文所述无法生效

GitLab 的公告称:

“作为此缺陷的变通方案,暂时无法升级的服务器可以在每个仓库的 info/attributes 文件中添加 conflict-marker-size=7,或对不受信任的仓库关闭这些合并检查。”

该变通方案并不能防止崩溃。针对 Git 2.56.0 实测:

info/attributes 内容结果
conflict-marker-size=7(与发布内容完全一致)仍然崩溃(SIGSEGV)
big.txt conflict-marker-size=7(按路径形式)被阻止,合并完成

原因在于 Git 如何解析不带路径模式的属性行。在 attr.c:parse_attr_line() 中,第一个空白之前的文本被当作属性名,因此该行

conflict-marker-size=7

被解析为一个名为 conflict-marker-size=7 的属性——整行 成为模式,因此它永远不会匹配任何路径:

$ git check-attr conflict-marker-size -- big.txt
big.txt: conflict-marker-size: unspecified     # no path pattern -> no match
$ git check-attr conflict-marker-size -- big.txt    # with a "big.txt " prefix
big.txt: conflict-marker-size: 7

gitattributes 行仅对其匹配的路径生效,因此缓解措施必须指明该路径(或使用 glob):

echo '* conflict-marker-size=7' > $GIT_DIR/info/attributes

上游的回归测试(t/t4300-merge-tree.sh)未覆盖 info/attributes 路径,因此该缺口在那里也未被捕获。


3. 复现环境

Podman 网络 cve105437lab;每个容器都受限(--cpus 2 --memory 4g)。

容器角色
gitlab-vulnGit 2.56.0,普通构建 + AddressSanitizer 构建(存在漏洞)
gitlab-fixedGit 2.56.1,普通构建 + AddressSanitizer 构建(对照组)
poc 运行器(临时)Python + git;推送载荷并通过实验网络驱动合并检查

两个服务器运行相同的镜像,仅执行的 Git 二进制不同(GIT_BIN / GIT_ASAN),因此除 Git 本身外,漏洞侧与修复侧逐字节完全相同。该镜像还包含两棵 Git 源码树,0day 扫描会链接它们。

服务端实现了托管服务所运行的合并可行性检查:git daemon 接受推送,一个 HTTP 端点运行 git merge-tree --write-tree <ours> <theirs>,并将 GIT_ATTR_SOURCE 设置为目标分支树,因此仓库自身的 .gitattributes 会被遵循。Git 调用作为子进程运行,因此崩溃会被观察到,而不会导致服务宕机——这正是 Gitaly 执行 Git 的方式。

4. 复现

make prepare      # build the lab image + the poc image
make up           # create the network + start gitlab-vuln / gitlab-fixed
make check-vuln   # VULNERABLE  (git child killed by SIGSEGV)
make check-fixed  # SAFE        (merge completes)
make exploit-vuln # full chain: push the payload, then trigger the merge check
make exploit-vuln-asan   # same, against the ASAN build -> full ASAN report
make mitigation-vuln     # GitLab's published info/attributes workaround
make 0day         # ASAN/UBSAN sweep of libxdiff, 2.56.0 vs 2.56.1
make evidence     # collect everything into evidence/
make down

PoC 模式(poc/poc.py,在 poc runner 容器内运行):

下载工具

最受欢迎

查看全部 →

发现我们社区最常用的工具。

  • 1

    OsintHunter

    letox4/osinthunter

    🎯 终极 OSINT 工具包:调查图谱、置信度评分、别名家族、地图、时间线和报告。49 个模块、400+ 个站点,无需 API 密钥。

    897
  • 2

    ghostlock-app

    yukonga/ghostlock-app

    GhostLock 一键执行应用(CVE-2026-43499)

    853
  • 3

    wifit3

    derv82/wifit3

    Wifite 但仅限 USB 且跨平台。

    668
  • 4

    jumpserver

    jumpserver/jumpserver

    JumpServer是一个开源的特权访问管理(PAM)平台,为DevOps和IT团队提供通过Web浏览器按需安全访问SSH、RDP、Kubernetes、数据库和RemoteApp端点的能力。

    448
  • 5

    looking-glass

    anonghosty/looking-glass

    CSIRT 平台,可将 Shadowserver 报告导入 MongoDB,并将其重放为交互式地图、分析、发现、公告和高管仪表板。

    417
  • 6

    SafeLine

    chaitin/safeline

    自托管WAF和反向代理,可过滤恶意HTTP流量、阻止SQL注入、XSS和机器人攻击,具备速率限制和动态HTML/JS加密功能。

    400

探索所有工具

浏览我们的工具集合

查看所有工具 →