# CVE-2026-5958: Race Condition in GNU Sed

> An attacker can exploit a race condition in GNU Sed to overwrite arbitrary files when using in-place editing with symlink following.

- **Severity:** Low 2.1 (`CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 20 Apr 2026
- **Updated:** 13 May 2026
- **Also known as:** AZL-83102, DEBIAN-CVE-2026-5958, ECHO-5725-fee5-80cd, GHSA-9r7w-j29g-xqx8, JLSEC-2026-213, MGASA-2026-0128, OESA-2026-2281, OESA-2026-2282, OESA-2026-2283, OESA-2026-2284, OESA-2026-2478, RHSA-2026:10995, SUSE-SU-2026:1659-1, SUSE-SU-2026:1699-1, SUSE-SU-2026:1941-1, SUSE-SU-2026:21413-1, SUSE-SU-2026:21448-1, SUSE-SU-2026:22256-1, SUSE-SU-2026:22325-1, UBUNTU-CVE-2026-5958, USN-8229-1, USN-8229-2, openSUSE-SU-2026:10649-1, openSUSE-SU-2026:21024-1

## What is CVE-2026-5958?

CVE-2026-5958 is a low-severity vulnerability in GNU Sed, published on 20 Apr 2026. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

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.

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

## Which versions are affected by CVE-2026-5958?


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `sed` | Red Hat:hummingbird:1 | All versions | 0:4.10-1.hum1 |
| `sed` | SUSE:Linux Enterprise Server 16.0 | All versions | 4.9-160000.3.1 |
| `sed` | SUSE:Linux Enterprise Server for SAP applications 16.0 | All versions | 4.9-160000.3.1 |
| `sed` | SUSE:Linux Micro 6.2 | All versions | 4.9-160000.3.1 |
| `sed` | openSUSE:Leap 16.0 | All versions | 4.9-160000.3.1 |
| `sed` | openSUSE:Tumbleweed | All versions | 4.10-1.1 |

## How do I fix CVE-2026-5958?

Upgrade to a fixed version.

## Is CVE-2026-5958 being exploited?

There is no known exploitation of CVE-2026-5958 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2026-5958 and fix it if it is affected.

What it is: CVE-2026-5958 is a low-severity vulnerability in GNU Sed, published on 20 Apr 2026. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2026-5958 in the wild and no public exploit code.

Affected product: GNU Sed. No package-level version data is available, so check the vendor advisory linked from the reference page.

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2026-5958/ (Markdown: https://insights.sbomify.com/CVE-2026-5958/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2026-5958
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2026-5958
- OSV: https://osv.dev/vulnerability/CVE-2026-5958

---
From sbomify Insights: https://insights.sbomify.com/CVE-2026-5958/
Summaries are generated and may contain mistakes; the official description above is the record.
