The SentinelOne Annual Threat Report - A Defenders Guide from the FrontlinesThe SentinelOne Annual Threat ReportGet the Report
Experiencing a Breach?Blog
Get StartedContact Us
SentinelOne
  • Platform
    Platform Overview
    • Singularity Platform
      Welcome to Integrated Enterprise Security
    • AI for Security
      Leading the Way in AI-Powered Security Solutions
    • Securing AI
      Accelerate AI Adoption with Secure AI Tools, Apps, and Agents.
    • How It Works
      The Singularity XDR Difference
    • Singularity Marketplace
      One-Click Integrations to Unlock the Power of XDR
    • Pricing & Packaging
      Comparisons and Guidance at a Glance
    Data & AI
    • Purple AI
      Accelerate SecOps with Generative AI
    • Singularity Hyperautomation
      Easily Automate Security Processes
    • AI-SIEM
      The AI SIEM for the Autonomous SOC
    • AI Data Pipelines
      Security Data Pipeline for AI SIEM and Data Optimization
    • Singularity Data Lake
      AI-Powered, Unified Data Lake
    • Singularity Data Lake for Log Analytics
      Seamlessly Ingest Data from On-Prem, Cloud or Hybrid Environments
    Endpoint Security
    • Singularity Endpoint
      Autonomous Prevention, Detection, and Response
    • Singularity XDR
      Native & Open Protection, Detection, and Response
    • Singularity RemoteOps Forensics
      Orchestrate Forensics at Scale
    • Singularity Threat Intelligence
      Comprehensive Adversary Intelligence
    • Singularity Vulnerability Management
      Application & OS Vulnerability Management
    • Singularity Identity
      Identity Threat Detection and Response
    Cloud Security
    • Singularity Cloud Security
      Block Attacks with an AI-Powered CNAPP
    • Singularity Cloud Native Security
      Secure Cloud and Development Resources
    • Singularity Cloud Workload Security
      Real-Time Cloud Workload Protection Platform
    • Singularity Cloud Data Security
      AI-Powered Threat Detection for Cloud Storage
    • Singularity Cloud Security Posture Management
      Detect and Remediate Cloud Misconfigurations
    Securing AI
    • Prompt Security
      Secure AI Tools Across Your Enterprise
  • Why SentinelOne?
    Why SentinelOne?
    • Why SentinelOne?
      Cybersecurity Built for What’s Next
    • Our Customers
      Trusted by the World’s Leading Enterprises
    • Industry Recognition
      Tested and Proven by the Experts
    • About Us
      The Industry Leader in Autonomous Cybersecurity
    Compare SentinelOne
    • Arctic Wolf
    • Broadcom
    • CrowdStrike
    • Cybereason
    • Microsoft
    • Palo Alto Networks
    • Sophos
    • Splunk
    • Trellix
    • Trend Micro
    • Wiz
    Verticals
    • Energy
    • Federal Government
    • Finance
    • Healthcare
    • Higher Education
    • K-12 Education
    • Manufacturing
    • Retail
    • State and Local Government
  • Services
    Managed Services
    • Managed Services Overview
      Wayfinder Threat Detection & Response
    • Threat Hunting
      World-Class Expertise and Threat Intelligence
    • Managed Detection & Response
      24/7/365 Expert MDR Across Your Entire Environment
    • Incident Readiness & Response
      DFIR, Breach Readiness, & Compromise Assessments
    Support, Deployment, & Health
    • Technical Account Management
      Customer Success with Personalized Service
    • SentinelOne GO
      Guided Onboarding & Deployment Advisory
    • SentinelOne University
      Live and On-Demand Training
    • Services Overview
      Comprehensive Solutions for Seamless Security Operations
    • SentinelOne Community
      Community Login
  • Partners
    Our Network
    • MSSP Partners
      Succeed Faster with SentinelOne
    • Singularity Marketplace
      Extend the Power of S1 Technology
    • Cyber Risk Partners
      Enlist Pro Response and Advisory Teams
    • Technology Alliances
      Integrated, Enterprise-Scale Solutions
    • SentinelOne for AWS
      Hosted in AWS Regions Around the World
    • Channel Partners
      Deliver the Right Solutions, Together
    • SentinelOne for Google Cloud
      Unified, Autonomous Security Giving Defenders the Advantage at Global Scale
    • Partner Locator
      Your Go-to Source for Our Top Partners in Your Region
    Partner Portal→
  • Resources
    Resource Center
    • Case Studies
    • Data Sheets
    • eBooks
    • Reports
    • Videos
    • Webinars
    • Whitepapers
    • Events
    View All Resources→
    Blog
    • Feature Spotlight
    • For CISO/CIO
    • From the Front Lines
    • Identity
    • Cloud
    • macOS
    • SentinelOne Blog
    Blog→
    Tech Resources
    • SentinelLABS
    • Ransomware Anthology
    • Cybersecurity 101
  • About
    About SentinelOne
    • About SentinelOne
      The Industry Leader in Cybersecurity
    • Investor Relations
      Financial Information & Events
    • SentinelLABS
      Threat Research for the Modern Threat Hunter
    • Careers
      The Latest Job Opportunities
    • Press & News
      Company Announcements
    • Cybersecurity Blog
      The Latest Cybersecurity Threats, News, & More
    • FAQ
      Get Answers to Our Most Frequently Asked Questions
    • DataSet
      The Live Data Platform
    • S Foundation
      Securing a Safer Future for All
    • S Ventures
      Investing in the Next Generation of Security, Data and AI
  • Pricing
Get StartedContact Us
CVE Vulnerability Database
Vulnerability Database/CVE-2026-5958

CVE-2026-5958: sed Race Condition Vulnerability

CVE-2026-5958 is a race condition vulnerability in sed that enables arbitrary file overwrite through symlink manipulation. This article covers the technical details, affected versions, impact, and mitigation.

Published: April 23, 2026

CVE-2026-5958 Overview

CVE-2026-5958 is a Time-of-Check Time-of-Use (TOCTOU) race condition vulnerability in GNU sed that affects the handling of symlinks when using the -i (in-place edit) and --follow-symlinks options together. The vulnerability exists in the open_next_file() function, which performs two separate, non-atomic filesystem operations on the same path, creating a window of opportunity for an attacker to manipulate the symlink target between these operations.

Critical Impact

An attacker can exploit this race condition to achieve arbitrary file overwrite with attacker-controlled content in the context of the sed process, potentially leading to data corruption or privilege escalation scenarios on multi-user systems.

Affected Products

  • GNU sed versions prior to 4.10

Discovery Timeline

  • April 20, 2026 - CVE-2026-5958 published to NVD
  • April 20, 2026 - Last updated in NVD database

Technical Details for CVE-2026-5958

Vulnerability Analysis

This vulnerability is classified as CWE-367 (Time-of-Check Time-of-Use Race Condition). The flaw manifests in the open_next_file() function when GNU sed is invoked with both -i (in-place edit) and --follow-symlinks options. The function performs two distinct filesystem operations that are not atomic:

  1. First, it resolves the symlink to its target and stores the resolved path for determining where output should be written
  2. Second, it opens the original symlink path (not the resolved one) to read the file contents

The time gap between these two operations creates a race window that an attacker can exploit. If the attacker atomically replaces the symlink with a different target during this window, sed will read content from the new (attacker-chosen) symlink target while writing the processed result to the path recorded in the first step.

Root Cause

The root cause of this vulnerability is the non-atomic nature of the symlink resolution and file open operations in the open_next_file() function. By separating the symlink resolution from the actual file open operation, the code introduces a race condition where the filesystem state can change between these two operations. This violates the principle of atomic operations when dealing with symbolic links, particularly in security-sensitive contexts where file paths may be controlled or influenced by untrusted users.

Attack Vector

The attack requires local access to the system where sed is being executed. An attacker must be able to manipulate symlinks in a directory where a privileged or targeted sed process is operating. The exploitation involves:

  1. Identifying a scenario where sed is invoked with -i --follow-symlinks on a path the attacker can manipulate
  2. Creating a symlink pointing to a benign file that the attacker controls
  3. Rapidly replacing the symlink target with a different file during the race window
  4. Causing sed to write processed (attacker-influenced) content to an unintended target file

The vulnerability is exploited through precise timing of symlink manipulation. An attacker would create a symlink and then rapidly swap its target between the check (symlink resolution) and use (file open) operations. This could be automated using a loop or monitoring filesystem events to time the swap precisely.

Detection Methods for CVE-2026-5958

Indicators of Compromise

  • Unexpected modification timestamps on sensitive system files
  • Log entries showing sed processes accessing files through symlinks in world-writable directories like /tmp
  • Evidence of rapid symlink creation and deletion in directories where sed processes operate

Detection Strategies

  • Monitor for sed processes using both -i and --follow-symlinks flags, particularly when operating on paths in shared or world-writable directories
  • Implement file integrity monitoring (FIM) on critical system files to detect unexpected modifications
  • Use process auditing to track sed invocations and their associated file operations

Monitoring Recommendations

  • Enable auditd rules to log all sed process executions with their command-line arguments
  • Monitor filesystem events in temporary and shared directories for suspicious symlink activity
  • Implement SentinelOne's behavioral AI to detect anomalous file access patterns indicative of TOCTOU exploitation attempts

How to Mitigate CVE-2026-5958

Immediate Actions Required

  • Upgrade GNU sed to version 4.10 or later where this issue has been fixed
  • Avoid using the -i --follow-symlinks combination on files in directories where untrusted users have write access
  • Review scripts and automation that invoke sed with in-place editing on symlinked files

Patch Information

This vulnerability was fixed in GNU sed version 4.10. Users should upgrade to this version or later to remediate the vulnerability. For more information about GNU sed, visit the GNU Sed Software Information page. Additional technical details are available in the CERT Post on CVE-2026-5958.

Workarounds

  • Remove the --follow-symlinks option when using -i for in-place editing if symlink following is not strictly required
  • Ensure sed operations on symlinked files are performed only in directories where the user has exclusive write access
  • Use the -i option without --follow-symlinks and manually resolve symlinks before invoking sed if symlink handling is necessary
bash
# Safe alternative: resolve symlink manually before editing
TARGET=$(readlink -f /path/to/symlink)
sed -i 's/pattern/replacement/' "$TARGET"

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

  • Vulnerability Details
  • TypeRace Condition

  • Vendor/TechSed

  • SeverityLOW

  • CVSS Score2.1

  • EPSS Probability0.00%

  • Known ExploitedNo
  • CVSS Vector
  • 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/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityNone
  • AvailabilityNone
  • CWE References
  • CWE-367
  • Technical References
  • CERT Post on CVE-2026-5958

  • GNU Sed Software Information
  • Latest CVEs
  • CVE-2025-52479: HTTP.jl & URIs.jl CRLF Injection Flaw

  • CVE-2026-31740: Linux Kernel Race Condition Vulnerability

  • CVE-2026-31743: Linux Kernel Buffer Overflow Vulnerability

  • CVE-2026-31744: Linux Kernel NULL Pointer Vulnerability
Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the World’s Most Advanced Cybersecurity Platform

See how our intelligent, autonomous cybersecurity platform can protect your organization now and into the future.

Try SentinelOne
  • Get Started
  • Get a Demo
  • Product Tour
  • Why SentinelOne
  • Pricing & Packaging
  • FAQ
  • Contact
  • Contact Us
  • Customer Support
  • SentinelOne Status
  • Language
  • Platform
  • Singularity Platform
  • Singularity Endpoint
  • Singularity Cloud
  • Singularity AI-SIEM
  • Singularity Identity
  • Singularity Marketplace
  • Purple AI
  • Services
  • Wayfinder TDR
  • SentinelOne GO
  • Technical Account Management
  • Support Services
  • Verticals
  • Energy
  • Federal Government
  • Finance
  • Healthcare
  • Higher Education
  • K-12 Education
  • Manufacturing
  • Retail
  • State and Local Government
  • Cybersecurity for SMB
  • Resources
  • Blog
  • Labs
  • Case Studies
  • Videos
  • Product Tours
  • Events
  • Cybersecurity 101
  • eBooks
  • Webinars
  • Whitepapers
  • Press
  • News
  • Ransomware Anthology
  • Company
  • About Us
  • Our Customers
  • Careers
  • Partners
  • Legal & Compliance
  • Security & Compliance
  • Investor Relations
  • S Foundation
  • S Ventures

©2026 SentinelOne, All Rights Reserved.

Privacy Notice Terms of Use

English