Описание
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:
- resolves symlink to its target and stores the resolved path for determining when output is written,
- 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.
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.
Отчет
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.
Меры по смягчению последствий
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.
Затронутые пакеты
| Платформа | Пакет | Состояние | Рекомендация | Релиз |
|---|---|---|---|---|
| Red Hat Enterprise Linux 10 | sed | Fix deferred | ||
| Red Hat Enterprise Linux 6 | sed | Fix deferred | ||
| Red Hat Enterprise Linux 7 | sed | Fix deferred | ||
| Red Hat Enterprise Linux 8 | sed | Fix deferred | ||
| Red Hat Enterprise Linux 9 | sed | Fix deferred | ||
| Red Hat OpenShift Container Platform 4 | rhcos | Fix deferred | ||
| Red Hat Hardened Images | sed-main-4.10-1.hum1 | Fixed | RHSA-2026:10995 | 27.04.2026 |
Показывать по
Дополнительная информация
Статус:
6.3 Medium
CVSS3
Связанные уязвимости
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.
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.
When sed is invoked with both -i (in-place edit) and --follow-symlinks ...
6.3 Medium
CVSS3