Composer-patches plugin flaw lets local users tamper with patches in shared temp directories
According to a post on the oss-security mailing list, the composer-patches plugin for PHP's Composer uses predictable system temp directories unsafely, tracked as CVE-2026-145738. NVD says version 2.0.0 lets local users gain privileges by modifying stored patches.
PHPWebVulnerabilitiesKey points
- The composer-patches plugin for Composer reportedly uses predictable temp-directory paths unsafely (CVE-2026-145738).
- One issue is a race condition on remote patches during download and hashing; the other is a fallback cache used when Composer's cache is unavailable.
- NVD describes local privilege escalation via modified patches in /tmp/composer-patches or /tmp/patches for version 2.0.0.
- No confirmed exploitation or fixed version is stated in the sources.
According to a post on the oss-security mailing list, the composer-patches plugin for PHP's Composer package manager handles predictable subdirectories of the system temporary directory, such as /tmp, in an unsafe way. The report is tracked as CVE-2026-145738.
Two related problems
The first concerns using such a directory as a staging area for remote patches while they download. The poster argues that an attacker could replace a patch in transit, during the window when its sha256 hash is computed, which makes this a race condition. The poster adds that hashing is slow, which widens that window. GitHub issue 654 in the composer-patches project tracks this problem.
The second concerns using the same kind of directory as a fallback patch cache when Composer's own cache is off or unusable. The poster says this can happen when Composer runs with the --no-cache option, or when a user runs it after switching through sudo to an account without a home directory.
Scope and severity
The NVD entry for the plugin, version 2.0.0, describes the impact as local users being able to gain privileges by modifying patches stored in /tmp/composer-patches or /tmp/patches. According to the poster, the risk is minor for users who download patch files locally rather than referencing patches by URL. The report does not indicate confirmed exploitation in the wild. The sources do not state a fixed version or a patch release.
Suggested workaround
The poster suggests a wrapper script that creates a private directory with mktemp -d and points PHP's sys_temp_dir setting at it for each Composer run. The poster notes this limits the benefit of the local cache but makes the process safe.
The full details are in the original oss-security posting.
What to do
- Check whether the composer-patches plugin is installed and whether it is version 2.0.0.
- Review whether your projects reference patches by URL, which the poster considers higher risk than local patch files.
- Follow GitHub issue 654 in the composer-patches project for a fix, since no patch release is mentioned in the sources.
- Consider the poster's workaround of a private temp directory set through sys_temp_dir for each Composer run, accepting that it reduces cache benefits.
Original report
“CVE-2026-145738: composer-patches vulnerable tmpdir handling”
Posted by Michael Orlitzky on Dec 06 Anyone using PHP's composer with the patches plugin[0] should check on this one. Predictable subdirectories of the system temporary directory (e.g. /tmp) are being used unsafely in two ways: 1. As a temporary download location for remote patches in transit. A bad guy can replace the patch in-flight while its sha256 is being computed. It's a race condition, but…