CVE-2018-20969
📋 TL;DR
CVE-2018-20969 is a command injection vulnerability in GNU patch's ed script processing. It allows attackers to execute arbitrary commands by crafting malicious patch files containing '!' characters. This affects systems using GNU patch to apply patches from untrusted sources.
💻 Affected Systems
- GNU patch
📦 What is this software?
⚠️ Risk & Real-World Impact
Worst Case
Full system compromise with arbitrary command execution as the user running patch, potentially leading to privilege escalation, data theft, or complete system takeover.
Likely Case
Local privilege escalation or remote code execution when processing patches from untrusted sources, particularly in automated patching systems.
If Mitigated
Limited impact if patch only processes trusted sources and runs with minimal privileges.
🎯 Exploit Status
Exploitation requires the victim to process a malicious patch file. Public exploit details exist in security advisories.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: 2.7.7 and later
Vendor Advisory: https://access.redhat.com/errata/RHSA-2019:2798
Restart Required: No
Instructions:
1. Update GNU patch to version 2.7.7 or later. 2. For Red Hat systems: yum update patch. 3. For other distributions: use package manager to update patch package.
🔧 Temporary Workarounds
Input validation
linuxValidate patch files before processing to ensure they don't contain '!' commands in ed scripts.
# Example: grep -q "^!" patchfile && echo "Rejecting patch with ed commands"
Run with minimal privileges
linuxExecute patch with non-privileged user accounts to limit impact.
sudo -u lowprivuser patch -p1 < patchfile
🧯 If You Can't Patch
- Restrict patch usage to trusted sources only
- Implement strict input validation for all patch files
🔍 How to Verify
Check if Vulnerable:
Check patch version: patch --version | head -1
Check Version:
patch --version | head -1
Verify Fix Applied:
Verify version is 2.7.7 or later: patch --version | grep -q '2\.7\.[7-9]\|2\.[8-9]'
📡 Detection & Monitoring
Log Indicators:
- Failed patch applications with error messages
- Unexpected process executions during patching
Network Indicators:
- Unusual outbound connections from patch processes
SIEM Query:
process.name:"patch" AND (process.cmdline:"!" OR process.parent.cmdline:"!")
🔗 References
- http://packetstormsecurity.com/files/154124/GNU-patch-Command-Injection-Directory-Traversal.html
- https://access.redhat.com/errata/RHSA-2019:2798
- https://access.redhat.com/errata/RHSA-2019:2964
- https://access.redhat.com/errata/RHSA-2019:3757
- https://access.redhat.com/errata/RHSA-2019:3758
- https://access.redhat.com/errata/RHSA-2019:4061
- https://git.savannah.gnu.org/cgit/patch.git/commit/?id=3fcd042d26d70856e826a42b5f93dc4854d80bf0
- https://github.com/irsl/gnu-patch-vulnerabilities
- https://seclists.org/bugtraq/2019/Aug/29
- http://packetstormsecurity.com/files/154124/GNU-patch-Command-Injection-Directory-Traversal.html
- https://access.redhat.com/errata/RHSA-2019:2798
- https://access.redhat.com/errata/RHSA-2019:2964
- https://access.redhat.com/errata/RHSA-2019:3757
- https://access.redhat.com/errata/RHSA-2019:3758
- https://access.redhat.com/errata/RHSA-2019:4061
- https://git.savannah.gnu.org/cgit/patch.git/commit/?id=3fcd042d26d70856e826a42b5f93dc4854d80bf0
- https://github.com/irsl/gnu-patch-vulnerabilities
- https://seclists.org/bugtraq/2019/Aug/29