CVE-2026-5958

Race Condition in GNU Sed

Published Apr 20, 2026 CVSS 4.0 · 2.1 Low EPSS < 1% KEV · Not listed
Description
When sed is invoked with both -i (in-place edit) and --follow-symlinks, the function open_next_file() performs two separate, non-atomic filesystem operations on the same path:
1. resolves symlink to its target and stores the resolved path for determining when output is written,
2. opens the original symlink path (not the resolved one) to read the file.
Between these two calls there is a race window. If an attacker atomically replaces the symlink with a different target during that window, sed will: read content from the new (attacker-chosen) symlink target and write the processed result to the path recorded in step 1. This can lead to arbitrary file overwrite with attacker-controlled content in the context of the sed process.


This issue was fixed in version 4.10.

Analysis

AI-generated

Technical impact

The vulnerability is a race condition that occurs when GNU Sed is called with the -i (in-place edit) and --follow-symlinks options. The program resolves a symlink to its target and records that target, then opens the original path to read the file. Between those two operations the attacker can replace the symlink atomically, causing Sed to read from a new target and write the processed result to the original path. This flaw is a CWE‑367 concurrent modification issue and can lead to arbitrary file overwrite with attacker‑controlled content. The impact is limited to situations where Sed is run with both options; no information leaks or denial of service are described.

Affected Systems

Version information is not explicitly listed, but the advisory notes that the problem was fixed in sed 4.10. Therefore, all GNU Sed installations older than 4.10 that invoke -i together with --follow-symlinks are vulnerable. The flaw applies to systems running standard Sed binaries on Unix‑like platforms where an attacker can change the target of a symlink during the race window.

Risk and Exploitability

The CVSS score of 2.1 indicates a low‑severity vulnerability. EPS score is unavailable and the vulnerability is not in the CISA KEV catalog, meaning no large‑scale exploit activity is currently documented. The most likely attack vector is a local attacker who can run or influence a Sed process and can modify symlinks on the same filesystem. Successful exploitation requires the attacker to read from the new symlink target and overwrite the recorded target; thus the threat is limited to privileged or compromised local environments rather than remote attacks.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade GNU Sed to version 4.10 or newer to eliminate the race condition
  • If an upgrade is not immediately possible, avoid using the --follow-symlinks option together with -i
  • Restrict the permissions of the directory and symlinks involved so that only trusted users can modify them, or run sed in a restricted environment (e.g., container) where symlink changes are not possible

Generated by OpenCVE AI on April 20, 2026 at 13:50 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
Ubuntu USN Ubuntu USN USN-8229-1 sed vulnerability
Ubuntu USN Ubuntu USN USN-8229-2 sed vulnerability
History
Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'none', 'Technical Impact': 'partial'}, 'version': '2.0.3'}

Type Values Removed Values Added
First Time appeared Gnu
Gnu sed
Vendors & Products Gnu
Gnu sed
Type Values Removed Values Added
Description When sed is invoked with both -i (in-place edit) and --follow-symlinks, the function open_next_file() performs two separate, non-atomic filesystem operations on the same path: 1. resolves symlink to its target and stores the resolved path for determining when output is written, 2. opens the original symlink path (not the resolved one) to read the file. Between these two calls there is a race window. If an attacker atomically replaces the symlink with a different target during that window, sed will: read content from the new (attacker-chosen) symlink target and write the processed result to the path recorded in step 1. This can lead to arbitrary file overwrite with attacker-controlled content in the context of the sed process. This issue was fixed in version 4.10.
Title Race Condition in GNU Sed
Weaknesses CWE-367
References
Metrics cvssV4_0

{'score': 2.1, 'vector': 'CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N'}

Weaknesses
  • CWE-367

    Time-of-check Time-of-use (TOCTOU) Race Condition

Sources

Status
PUBLISHED
Assigner
CERT-PL
Published
Updated
May 13, 2026, 5:17 AM
Reserved
Apr 9, 2026, 9:42 AM
Status
Deferred
Published
Apr 20, 2026, 12:16 PM
Modified
Oct 26, 2026, 9:10 PM