PatchSiren cyber security CVE debrief
CVE-2026-5958 GNU CVE debrief
A race condition vulnerability exists in GNU sed when invoked with both the -i (in-place edit) and --follow-symlinks options. The function open_next_file() performs two separate, non-atomic filesystem operations: first resolving a symlink to its target path for determining output location, then opening the original symlink path to read content. An attacker who can atomically replace the symlink between these two operations can cause sed to read from an attacker-chosen file and write processed output to the originally resolved target path, resulting in arbitrary file overwrite with attacker-controlled content. This vulnerability requires local access and precise timing, with a CVSS 4.0 score of 2.1 (LOW severity). The issue was fixed in GNU sed version 4.10.
- Vendor
- GNU
- Product
- Sed
- CVSS
- LOW 2.1
- CISA KEV
- Not listed in stored evidence
- Original CVE published
- 2026-04-20
- Original CVE updated
- 2026-05-19
- Advisory published
- 2026-04-20
- Advisory updated
- 2026-05-19
Who should care
System administrators and developers using sed -i --follow-symlinks in automated scripts, particularly in multi-user environments or on filesystems where untrusted users can manipulate symlinks. Security teams assessing local privilege escalation risks in hardened environments.
Technical summary
The vulnerability stems from a time-of-check to time-of-use (TOCTOU) race condition in sed's open_next_file() function. When --follow-symlinks is used with -i, the code path: (1) calls realpath() or equivalent to resolve and store the symlink target, then (2) opens the original symlink path for reading. The window between resolution and open allows an attacker with appropriate filesystem permissions to replace the symlink via atomic rename operations. Successful exploitation results in content from an attacker-controlled file being processed and written to the attacker's chosen destination. The attack requires local filesystem access and winning a race condition, limiting practical exploitability.
Defensive priority
low
Recommended defensive actions
- Upgrade GNU sed to version 4.10 or later to eliminate the race condition vulnerability
- Avoid using sed with both -i and --follow-symlinks options on untrusted filesystem paths
- Implement filesystem access controls to restrict symlink manipulation in directories where sed operates
- Monitor for unexpected file modifications in environments where sed in-place editing is performed on symlinks
- Apply principle of least privilege to processes invoking sed with in-place editing capabilities
Evidence notes
The vulnerability description is sourced from NVD with additional context from CERT.PL advisory. The CVSS 4.0 vector indicates local attack vector, low attack complexity, and partial timing attack requirements. CWE-367 (Time-of-check Time-of-use Race Condition) is identified as the weakness type.
Official resources
-
CVE-2026-5958 CVE record
CVE.org
-
CVE-2026-5958 NVD detail
NVD
-
Source item URL
nvd_modified
- Source reference
- Source reference
-
Source reference
af854a3a-2127-422b-91ae-364da2661108
CVE-2026-5958 was published on 2026-04-20 and last modified on 2026-05-19. The vulnerability was disclosed through CERT.PL and discussed on the oss-security mailing list.