目标达成 感谢每一位支持者 — 我们达成了 100% 目标!

目标: 1000 元 · 已筹: 1359 元

100%

CVE-2021-21300 PoC — Git 后置链接漏洞

来源
关联漏洞
标题: Git 后置链接漏洞 (CVE-2021-21300)
Description:Git是一套免费、开源的分布式版本控制系统。 Git 存在后置链接漏洞,该漏洞允许攻击者利用特别制作的存储库导致just-checked脚本执行而克隆到一个不区分大小写的文件系统。
介绍
# CVE-2021-21300: Arbitrary Code Execution via Malicious Git Hooks

## 📌 Summary

CVE-2021-21300 is a critical vulnerability in Git (versions 2.14.2 to 2.30.1) that allows attackers to execute arbitrary code on victim machines by exploiting symbolic links and case-insensitive file systems.

---

## 🧠 Problem Statement

- **Vulnerability**: Arbitrary code execution via malicious Git hooks.
- **Root Cause**: Case-insensitive filesystems (e.g., Windows/macOS) resolve `A/post-checkout` as `.git/hooks/post-checkout`.
- **Impact**: Attackers can inject and execute malicious hooks when a user clones the infected repository.

---

## 🔍 Theoretical Background

### The Trick

Git allows user-defined hooks stored in `.git/hooks/`. On case-insensitive file systems:
- A crafted folder like `A/post-checkout` may be interpreted as `.git/hooks/post-checkout`.
- A symbolic link replaces `A/` with `.git/hooks/`, bypassing restrictions.

### The Exploit

1. Create directory `A` and a file `A/post-checkout` containing malicious commands.
2. Stage the directory and its contents for Git.
3. Remove the directory and replace `A` with a symlink to `.git/hooks/`.
4. When Git executes `A/post-checkout`, it actually runs the malicious file in `.git/hooks/`.

---

## ⚠️ Trigger Conditions

- Case-insensitive filesystem (Windows/macOS).
- Symbolic link to `.git/hooks/`.
- Global Git LFS filters enabled.
- Victim has permission to execute malicious code.

---

## 🛠️ Attack Workflow

### Malicious Repo Generation
- Create `.gitattributes` to trigger LFS processing of `A/post-checkout`.
- Add a malicious script `A/post-checkout` (e.g., prints "PWNED").
- Add fake files `A/a`, `A/b` to make it look legitimate.
- Replace `A/` with symlink to `.git/hooks/`.
- Commit and push the changes.

---

## 🛡 Existing Defenses

### Configuration-Based
- Disable symbolic link following:
  ```sh
  git clone -c core.symlinks=true
  git config --system core.symlinks true
##💡 **Other Potential Defenses**
- Automate Safe Cloning with Git Alias
- Make directory.
- Enable case sensitivity (Windows):
  ```sh
  fsutil file setcasesensitiveinfo <DESTINATION FOLDER> enable
- Clone into that directory.

- Create a Git alias to automate these steps for safer cloning.
文件快照

登录后查看神龙缓存的 POC 文件快照

登录查看
备注
    1. 建议优先通过来源进行访问。
    2. 本地 POC 快照面向订阅用户开放;当原始来源失效或无法访问时,本地镜像作为订阅权益的一部分提供。
    3. 持续抓取、验证、维护这份 POC 档案需要不少投入,因此本地快照已纳入付费订阅。您的订阅是让这份资料能继续走下去的关键,由衷感谢。 查看订阅方案 →