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.
Sources and references
Verified primary and authoritative sources
-
CVE-2026-5958 CVE Program record
Publisher, destination, and source semantics verified
URL: https://www.cve.org/CVERecord?id=CVE-2026-5958
CVE Program - Official CVE Program record with source-provided CVE metadata.
-
CVE-2026-5958 NVD vulnerability detail
Publisher, destination, and source semantics verified
URL: https://nvd.nist.gov/vuln/detail/CVE-2026-5958
NIST National Vulnerability Database - Official NIST NVD detail page and source-specific vulnerability assessment.
Supplemental references
-
Source reference
Unverified legacy reference
URL: https://cert.pl/en/posts/2026/04/CVE-2026-5958
-
Source reference
Unverified legacy reference
URL: https://www.gnu.org/software/sed/
Methodology and review provenance
AI-assisted synthesis based on stored public vulnerability evidence. System validation, approval state, and publication status do not by themselves establish human review of this revision. PatchSiren helps prioritize defensive review and does not prove exposure or remediation on any system.