CVE-2023-25652
📋 TL;DR
CVE-2023-25652 is a path traversal vulnerability in Git's `git apply --reject` command that allows attackers to write partially controlled content to arbitrary files outside the working directory. This affects all Git users who apply patches from untrusted sources using the `--reject` flag. The vulnerability can lead to file corruption, data loss, or potential code execution depending on what files are overwritten.
💻 Affected Systems
- Git
📦 What is this software?
Fedora by Fedoraproject
Fedora by Fedoraproject
Git by Git Scm
Git by Git Scm
Git by Git Scm
Git by Git Scm
Git by Git Scm
Git by Git Scm
Git by Git Scm
Git by Git Scm
Git by Git Scm
Git by Git Scm
Git by Git Scm
⚠️ Risk & Real-World Impact
Worst Case
An attacker could overwrite critical system files (like configuration files, scripts, or binaries) leading to system compromise, data destruction, or remote code execution if the overwritten file is executed.
Likely Case
Attackers could corrupt project files, configuration files, or scripts in the parent directories of the working tree, causing data loss, service disruption, or privilege escalation if sensitive files are modified.
If Mitigated
With proper controls, the impact is limited to denial of service through file corruption in non-critical directories, with no privilege escalation or remote code execution.
🎯 Exploit Status
Exploitation requires the victim to apply a specially crafted patch with the `--reject` flag. The vulnerability is well-documented with proof-of-concept examples in security advisories.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: 2.30.9, 2.31.8, 2.32.7, 2.33.8, 2.34.8, 2.35.8, 2.36.6, 2.37.7, 2.38.5, 2.39.3, or 2.40.1
Vendor Advisory: https://github.com/git/git/security/advisories/GHSA-2hvf-7c8p-28fx
Restart Required: No
Instructions:
1. Check current Git version: `git --version`. 2. Update Git using your package manager: For Ubuntu/Debian: `sudo apt update && sudo apt upgrade git`. For RHEL/CentOS: `sudo yum update git`. For macOS: `brew upgrade git`. 3. Verify update: `git --version` should show patched version.
🔧 Temporary Workarounds
Avoid git apply --reject with untrusted patches
allDo not use the --reject flag when applying patches from untrusted sources
# Instead of: git apply --reject patch.patch
# Use: git apply --stat patch.patch to inspect first, then apply without --reject if safe
Inspect patches before applying
allUse git apply --stat to examine patch contents before applying
git apply --stat patch.patch
# Review output for suspicious paths or operations
# Only apply if patch looks safe
🧯 If You Can't Patch
- Implement strict patch review processes: require manual review of all patches before application
- Use sandboxed environments for patch application: apply patches in isolated containers or VMs with limited filesystem access
🔍 How to Verify
Check if Vulnerable:
Check Git version: if version is earlier than 2.30.9, 2.31.8, 2.32.7, 2.33.8, 2.34.8, 2.35.8, 2.36.6, 2.37.7, 2.38.5, 2.39.3, or 2.40.1, and you use `git apply --reject`, you are vulnerable.
Check Version:
git --version
Verify Fix Applied:
Run `git --version` and confirm version is 2.30.9, 2.31.8, 2.32.7, 2.33.8, 2.34.8, 2.35.8, 2.36.6, 2.37.7, 2.38.5, 2.39.3, or 2.40.1 or later.
📡 Detection & Monitoring
Log Indicators:
- Failed patch applications with --reject flag
- Unexpected file modifications outside working directory
- Error messages about path traversal in git apply operations
Network Indicators:
- Downloads of patch files from untrusted sources followed by git apply commands
SIEM Query:
Process execution logs showing 'git apply --reject' command followed by file modification events outside expected directories
🔗 References
- http://www.openwall.com/lists/oss-security/2023/04/25/2
- https://github.com/git/git/commit/18e2b1cfc80990719275d7b08e6e50f3e8cbc902
- https://github.com/git/git/commit/668f2d53613ac8fd373926ebe219f2c29112d93e
- https://github.com/git/git/security/advisories/GHSA-2hvf-7c8p-28fx
- https://lists.debian.org/debian-lts-announce/2024/06/msg00018.html
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/BSXOGVVBJLYX26IAYX6PJSYQB36BREWH/
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/PI7FZ4NNR5S5J5K6AMVQBH2JFP6NE4L7/
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/RKOXOAZ42HLXHXTW6JZI4L5DAIYDTYCU/
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/YFZWGQKB6MM5MNF2DLFTD7KS2KWPICKL/
- https://security.gentoo.org/glsa/202312-15
- http://www.openwall.com/lists/oss-security/2023/04/25/2
- https://github.com/git/git/commit/18e2b1cfc80990719275d7b08e6e50f3e8cbc902
- https://github.com/git/git/commit/668f2d53613ac8fd373926ebe219f2c29112d93e
- https://github.com/git/git/security/advisories/GHSA-2hvf-7c8p-28fx
- https://lists.debian.org/debian-lts-announce/2024/06/msg00018.html
- https://lists.debian.org/debian-lts-announce/2024/09/msg00009.html
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/BSXOGVVBJLYX26IAYX6PJSYQB36BREWH/
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/PI7FZ4NNR5S5J5K6AMVQBH2JFP6NE4L7/
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/RKOXOAZ42HLXHXTW6JZI4L5DAIYDTYCU/
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/YFZWGQKB6MM5MNF2DLFTD7KS2KWPICKL/
- https://security.gentoo.org/glsa/202312-15