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.
Published: 2026-04-20
Score: 2.1 Low
EPSS: n/a
KEV: No
Impact: Arbitrary file overwrite
Action: Update Sed
AI Analysis

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.

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

Remediation

No vendor fix or workaround currently provided.

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

No advisories yet.

History

Mon, 20 Apr 2026 14:15:00 +0000

Type Values Removed Values Added
Metrics ssvc

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


Mon, 20 Apr 2026 13:45:00 +0000

Type Values Removed Values Added
First Time appeared Gnu
Gnu sed
Vendors & Products Gnu
Gnu sed

Mon, 20 Apr 2026 12:15:00 +0000

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'}


cve-icon MITRE

Status: PUBLISHED

Assigner: CERT-PL

Published:

Updated: 2026-04-20T13:25:59.530Z

Reserved: 2026-04-09T09:42:24.687Z

Link: CVE-2026-5958

cve-icon Vulnrichment

Updated: 2026-04-20T13:25:56.168Z

cve-icon NVD

Status : Awaiting Analysis

Published: 2026-04-20T12:16:08.433

Modified: 2026-04-20T19:05:30.750

Link: CVE-2026-5958

cve-icon Redhat

No data.

cve-icon OpenCVE Enrichment

Updated: 2026-04-20T14:00:08Z

Weaknesses