
Demonstrates CVE-2021-21300 arbitrary code execution via malicious Git hooks on case-insensitive filesystems, including exploit steps and defensive measures.
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.
A/post-checkout as .git/hooks/post-checkout.Git allows user-defined hooks stored in .git/hooks/. On case-insensitive file systems:
A/post-checkout may be interpreted as .git/hooks/post-checkout.A/ with .git/hooks/, bypassing restrictions.A and a file A/post-checkout containing malicious commands.A with a symlink to .git/hooks/.A/post-checkout, it actually runs the malicious file in .git/hooks/..git/hooks/..gitattributes to trigger LFS processing of A/post-checkout.A/post-checkout (e.g., prints "PWNED").A/a, A/b to make it look legitimate.A/ with symlink to .git/hooks/.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):
fsutil file setcasesensitiveinfo <DESTINATION FOLDER> enable
Clone into that directory.
Create a Git alias to automate these steps for safer cloning.