GNU sed In-Place Edit and Symlink Follow Vulnerability Allowing Arbitrary File Overwrite

Vulnerability

A vulnerability exists in GNU sed versions from 4.1e prior to 4.10, when the tool is used with the '-i' option for in-place editing and '--follow-symlinks'. The issue arises from a time-of-check time-of-use (TOCTOU) race condition, where the 'open_next_file()' function performs two separate, non-atomic operations on the same symlinked path. First, it resolves the symlink to its target and records the resolved path for output purposes. Then, it opens the original symlink path to read the file. This creates a race window during which an attacker could replace the symlink with a different target. As a result, sed could read content from the new, attacker-chosen target and write the processed output to the previously recorded path, leading to an arbitrary file overwrite with attacker-controlled content.

Impact

Exploitation of this vulnerability allows for arbitrary file overwrites with content chosen by the attacker, within the context of the sed process.

Remediation

Users can upgrade to GNU sed version 4.10 or later to address this vulnerability.

Added: Apr 20, 2026, 12:58 PM
Updated: Apr 20, 2026, 12:58 PM

Vulnerability Rating

Custom Algorithm
spread
7.8
impact
2.5
exploitability
2.9
remediation
0.0
relevance
6.3
threat
0.0
urgency
2.9
incentive
0.0

Our algorithm analyzes dozens of metrics to generate these 8 key vulnerability categories, which are then combined to calculate the overall risk score.