CVE Database›Document archive›CVE-2026-5958

CVE-2026-5958

sed: GNU sed TOCTOU race condition

Loading…

Severity

Moderate

Red Hat Product Security

6.3

CVSS 3.1

Review impact separately from score.

Published · April 19, 2026

Updated · September 1, 2026

Description

A Time-of-Check Time-of-Use (TOCTOU) race condition was found in GNU sed. When the -i (in-place) and --follow-symlinks options are used together, sed resolves the symlink but reopens the path for writing. An attacker with write access to the directory containing the symlink can swap it between the check and the open operations. If a privileged user executes sed in this manner on a path influenced by the attacker, it can lead to arbitrary file overwrites and potential privilege escalation.

Statement

This is a Moderate severity flaw in GNU sed that allows for arbitrary file overwrite. The vulnerability is a Time-of-Check Time-of-Use (TOCTOU) race condition in the --follow-symlinks option, enabling an attacker to cause sed -i --follow-symlinks to read attacker-controlled content and write it to an unintended file. Exploitation requires a privileged process to execute sed on a path that an attacker can influence.

CVSS score applicability

The CVSS score(s) listed for this vulnerability do not reflect the associated product's status, and are included for informational purposes to better understand the severity of this vulnerability.

Mitigation

To mitigate this vulnerability, avoid using the sed -i --follow-symlinks command in privileged contexts or on paths that can be influenced by untrusted users. This flaw specifically affects the --follow-symlinks option, which, when used by a privileged process on an attacker-controlled path, can lead to arbitrary file overwrite. Restricting the use of this specific option in sensitive operations can reduce the risk of exploitation.

CVSS / CWE

CVSS 3.1 · 6.3
CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:H

CWE-367 · Time-of-check Time-of-use (TOCTOU) Race Condition