CVE-2026-5958
CBL Mariner vulnerability analysis and mitigation

Overview

CVE-2026-5958 is a Time-of-check Time-of-use (TOCTOU) race condition in GNU sed affecting versions 4.1e through 4.9 when invoked with both -i (in-place edit) and --follow-symlinks options. The vulnerability was discovered by Michał Majchrowicz and Marcin Wyczechowski of the AFINE Team, reported to CERT Polska, and publicly disclosed on April 20, 2026, with a fix released in sed 4.10 on April 21, 2026. It carries a CVSS v4.0 base score of 2.1 (Low), assigned by CERT.PL (GitHub Advisory, oss-security).

Technical details

The root cause is CWE-367 (TOCTOU Race Condition) in the open_next_file() function within sed/execute.c. The function first calls follow_symlink() to resolve the symlink via readlink() and stores the resolved path for output, then separately calls ck_fopen() on the original symlink path (not the resolved one) to read the file — two non-atomic filesystem operations. Between these two syscalls, an attacker can atomically swap the symlink to a different target, causing sed to read from the attacker-chosen file while writing the processed output to the originally resolved path. The one-line fix changes ck_fopen(name, ...) to ck_fopen(input->in_file_name, ...), ensuring the already-resolved path is opened for reading. The bug was introduced in sed 4.1e and reportedly reproduces reliably in approximately 14 attempts (oss-security, GitHub Advisory).

Impact

Successful exploitation allows an attacker to perform arbitrary file overwrites with attacker-controlled content in the context of the sed process. The primary risk is to system integrity — if a privileged process (e.g., running as root) invokes sed -i --follow-symlinks on a path the attacker can influence, the attacker could overwrite sensitive system files, potentially enabling privilege escalation. There is no confidentiality or availability impact; the attack is limited to unauthorized file modification (oss-security, GitHub Advisory).

Exploitability

There is no public proof-of-concept exploit and no evidence of in-the-wild exploitation as of the time of disclosure. The EPSS score is approximately 0.004–0.006%, indicating very low probability of near-term exploitation. The vulnerability is not listed in the CISA Known Exploited Vulnerabilities (KEV) catalog. Exploitation requires local access, the ability to create or manipulate symlinks in a directory where a privileged sed operation is performed, and precise timing to win the race window (GitHub Advisory, oss-security).

Exploitation steps

  1. Reconnaissance: Identify systems where a privileged process (e.g., a cron job or script running as root) invokes sed -i --follow-symlinks on a path within a directory writable by the attacker.
  2. Setup symlink: In the writable directory, create a symlink pointing to a benign file that the privileged sed process will process (e.g., ln -s /tmp/benign.txt target_link).
  3. Prepare malicious content: Stage a file with attacker-controlled content at a chosen path (e.g., /tmp/malicious_content).
  4. Race the window: Continuously and rapidly replace the symlink atomically between the two sed syscalls — after readlink() resolves the original target but before ck_fopen() opens the symlink — using a loop such as: while true; do ln -sfn /tmp/malicious_content target_link; ln -sfn /tmp/benign.txt target_link; done.
  5. Trigger overwrite: When the race is won, sed reads from /tmp/malicious_content (the new symlink target) and writes the processed result to the originally resolved path (the benign file's location), achieving arbitrary file overwrite with attacker-controlled content in the context of the sed process (oss-security).

Indicators of compromise

  • File System: Unexpected modification timestamps on sensitive files (e.g., /etc/passwd, /etc/sudoers, cron files) coinciding with sed invocations; presence of symlinks in directories processed by privileged sed scripts that point to unexpected targets.
  • Logs: System or application logs showing sed invocations with both -i and --follow-symlinks flags on paths in world-writable or attacker-accessible directories; audit logs (auditd) recording rapid symlink creation/replacement (symlink, rename syscalls) in directories processed by sed.
  • Process: Privileged sed processes (sed running as root) observed operating on symlinks in user-writable directories; unusual file content changes in root-owned files immediately following sed execution.

Mitigation and workarounds

Upgrade GNU sed to version 4.10 or later, which contains a one-line fix that opens the already-resolved symlink path for reading rather than re-traversing the original symlink. As a workaround until patching is possible, avoid using sed with both -i and --follow-symlinks together, especially in scripts running with elevated privileges on paths accessible to untrusted users. Restrict symlink creation permissions in directories where privileged sed operations are performed. Distribution-specific updates have been released by SUSE, openSUSE, Ubuntu, and Mageia (oss-security, GitHub Advisory).

Community reactions

The vulnerability was coordinated through CERT Polska and the linux-distros mailing list prior to public disclosure. Solar Designer of Openwall noted on oss-security that Gentoo and Amazon failed to complete their contributing-back tasks (public disclosure notification), and that the issue was considered "too minor" to warrant the full distros list. The GNU sed maintainer Jim Meyering handled disclosure responsibly, releasing sed 4.10 with the fix on April 21, 2026. Multiple Linux distributions including SUSE, openSUSE, Ubuntu, and Mageia issued security advisories and updated packages (oss-security).

Additional resources


SourceThis report was generated using AI

Related CBL Mariner vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2026-47243CRITICAL9.2
  • CBL Mariner logoCBL Mariner
  • kata-containers
NoYesAug 07, 2026
CVE-2026-64580HIGH7.8
  • Linux Kernel logoLinux Kernel
  • kernel
NoYesAug 05, 2026
CVE-2026-64590HIGH7.1
  • CBL Mariner logoCBL Mariner
  • kernel
NoYesAug 06, 2026
CVE-2026-64576HIGH7.1
  • Linux Kernel logoLinux Kernel
  • linux-aws-6.17
NoYesAug 05, 2026
CVE-2026-64579MEDIUM4.1
  • Linux Kernel logoLinux Kernel
  • kernel-64k-modules-core
NoYesAug 05, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management