On May 17, 2026, Fedora maintainers pushed a critical security update for libgit2. That date doesn't matter anymore. What matters is that the external SSH handling in certain libgit2 versions contained a bug that could allow arbitrary command execution.
Attackers could send malformed repository names to your application and, if your software used libgit2's SSH transport, potentially run any command on your system.
Wait, arbitrary command execution through a Git library? Yes. When you use git clone with an SSH URL, libgit2 hands the repository name to your system's SSH client—but older versions didn't quote that name properly.
But patches only fix the hole after you know about it. Attackers don't send malformed IPs—they deliver malware that exploits the flaw, persists on your system, and phones home. A patched library won't stop malware that's already inside.
Here's how to secure your Fedora systems today, even if you first hear about this months from now.
Check If You're Vulnerable
# Check installed version dnf list installed libgit2_1.8 # Or check using rpm directly rpm -q libgit2_1.8
# Find any process that has libgit2 loaded lsof | grep libgit2 # Or check which installed packages depend on libgit2 dnf repoquery --whatrequires libgit2_1.8
#!/bin/bash # libgit2 Security Fix Automation Script for Fedora # Checks and updates libgit2 to the patched version 1.8.5 set -e RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' echo "=== libgit2 Security Vulnerability Check & Fix ===" # Check current version echo -e "\n${YELLOW}[*] Checking current libgit2 version...${NC}" CURRENT=$(rpm -q libgit2_1.8 2>/dev/null | tail -1) if [[ $CURRENT == *"not installed"* ]]; then echo -e "${YELLOW}[!] libgit2_1.8 is not installed. Your system may not use libgit2.${NC}" echo -e "${GREEN}[✓] No action needed for libgit2.${NC}" exit 0 fi echo " Found: $CURRENT" # Check if it's vulnerable if [[ $CURRENT == *"1.8.5"* ]]; then echo -e "${GREEN}[✓] Already at safe version 1.8.5 or higher. No action needed.${NC}" exit 0 fi echo -e "${RED}[!] Vulnerable version detected. Applying security update...${NC}" # Update libgit2 via dnf echo -e "\n${YELLOW}[*] Updating libgit2...${NC}" dnf update -y libgit2_1.8 # Verify the update UPDATED=$(rpm -q libgit2_1.8) echo " Updated to: $UPDATED" if [[ $UPDATED == *"1.8.5"* ]]; then echo -e "${GREEN}[✓] Security patch applied successfully!${NC}" # Restart any services that might be using libgit2 echo -e "\n${YELLOW}[*] Checking for services that may need restart...${NC}" # Find and optionally restart systemd services that have libgit2 loaded for service in $(systemctl list-units --type=service --state=running | grep -E "gitea|gitlab|gogs|gitness|git-http" | awk '{print $1}'); do echo " Restarting $service" systemctl restart "$service" done echo -e "\n${GREEN}[✓] Done. Your libgit2 is now patched against SSH command injection.${NC}" else echo -e "${RED}[✗] Update may have failed. Check manually: dnf update libgit2_1.8${NC}" exit 1 fi
One Script Fixes One CVE. One Book Fixes All the CVEs You've Never Seen.
Option 1: Restrict SSH-based Git operations at the firewall
# Block outgoing SSH connections to Git hosts (port 22) # But allow regular SSH to your own servers if needed iptables -A OUTPUT -p tcp --dport 22 -m state --state NEW -m owner ! --uid-owner git -j DROP # Or, if Git operations use a dedicated user account (e.g., 'git'): iptables -A OUTPUT -p tcp --dport 22 -m owner --uid-owner git -j DROP
Option 2: Use a hardened SSH configuration for Git
# Create a wrapper script at /usr/local/bin/git-ssh-wrapper #!/bin/bash # Only allow connections to known-good Git hosts ALLOWED_HOSTS=("github.com" "gitlab.com" "bitbucket.org") HOST="$1" for allowed in "${ALLOWED_HOSTS[@]}"; do if [[ "$HOST" == "$allowed" ]]; then exec /usr/bin/ssh "$@" fi done echo "ERROR: Connection to $HOST blocked due to security policy" >&2 exit 1
Option 3: Run vulnerable applications in a container
# Run your Git-dependent app in a Docker container with read-only root and network restrictions docker run --read-only --network none --security-opt=no-new-privileges:true your-app

Nenhum comentário:
Postar um comentário