CVE-2026-115207: Patch: filename validation bypass in reversal fallback allows file creation outside the working directory
A flaw was found in GNU patch. An attacker can achieve arbitrary file creation outside the intended working directory by enticing a user or automated workflow to apply a specially crafted patch file. Due to missing validation during automatic patch reversal, absolute file paths in patch headers are accepted rather than rejected. Consequently, the utility can create files in arbitrary locations with the permissions of the executing user.
Other sources
A flaw was found in GNU patch. The reversal fallback in intuitdifftype() in src/pch.c selects a filename from the patch headers without applying the nameisvalid() check that normally rejects absolute paths. A crafted unified diff that appears to delete a nonexistent file, with an absolute filename in both headers and an epoch timestamp for the new file, can trigger automatic reversal when applied with patch -p0 -t. The unvalidated absolute filename reaches the filesystem operations, allowing attacker-controlled file creation outside the working directory with the permissions of the account running patch. Exploitation requires a user or workflow to apply the crafted patch; it does not bypass operating-system filesystem permissions.
— Red Hat
Affected Software
Event History
Frequently Asked Questions
Which environments are realistically exposed?
Users or automated workflows that apply attacker-supplied patch files with patch -p0 -t are exposed if the crafted patch triggers automatic reversal. The files can be created with the permissions of the account running patch.
What does an attacker need to provide to trigger the behavior?
The attacker needs to persuade a user or workflow to apply a crafted unified diff. The described trigger uses a patch that appears to delete a nonexistent file, includes an absolute filename in both headers, and has an epoch timestamp for the new file.
Does successful exploitation bypass filesystem permissions?
No. File creation remains constrained by the operating-system permissions of the user or service account executing patch.