Time-of-check Time-of-use (TOCTOU) Affecting sed package, versions <4.9-2ubuntu0.24.04.1


Severity

Recommended
medium

Based on Ubuntu security rating.

Threat Intelligence

EPSS
0.01% (1st percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Time-of-check Time-of-use (TOCTOU) vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-UBUNTU2404-SED-16117596
  • published4 May 2026
  • disclosed20 Apr 2026

Introduced: 20 Apr 2026

NewCVE-2026-5958  (opens in a new tab)
CWE-367  (opens in a new tab)

How to fix?

Upgrade Ubuntu:24.04 sed to version 4.9-2ubuntu0.24.04.1 or higher.

NVD Description

Note: Versions mentioned in the description apply only to the upstream sed package and not the sed package as distributed by Ubuntu. See How to fix? for Ubuntu:24.04 relevant fixed versions and status.

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.

CVSS Base Scores

version 3.1