Dev.to Security πŸ” Cybersecurity πŸ‘ 0 πŸ“– 4 min read

CVE-2026-35374: CVE-2026-35374: Arbitrary File Truncation via TOCTOU Race Condition in uutils coreutils split

CVE-2026-35374: Arbitrary File Truncation via TOCTOU Race Condition in uutils coreutils split Vulnerability ID: CVE-2026-35374 CVSS Score: 6.3 Published: 2026-11-20 CVE-2026-35374 is a Time-of-Check to Time-of-Use (

CVE-2026-35374: Arbitrary File Truncation via TOCTOU Race Condition in uutils coreutils split

Vulnerability ID: CVE-2026-35374
CVSS Score: 6.3
Published: 2026-11-20

CVE-2026-35374 is a Time-of-Check to Time-of-Use (TOCTOU) race condition (CWE-367) in the split utility of uutils coreutils. The utility validates that the input and output paths do not refer to the same file before opening the output file with truncation flags. A local attacker with write permissions in the destination directory can replace the output file path with a symbolic link during this race window, causing the process to truncate and overwrite arbitrary files accessible to the user executing split.

TL;DR

A TOCTOU race condition in the uutils coreutils split utility allows a local attacker with write access to the destination directory to cause arbitrary file truncation and data loss by swapping the target output path with a symbolic link between path validation and file opening.

⚠️ Exploit Status: POC

Technical Details

  • Vulnerability Type: CWE-367: Time-of-Check Time-of-Use (TOCTOU) Race Condition
  • Affected Component: uutils coreutils split utility (uu_split)
  • Attack Vector: Local (Requires write permissions in the destination directory)
  • CVSS v3.1 Score: 6.3 Medium (CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:H)
  • EPSS Score: 0.08% (0.11th Percentile)
  • Security Impact: Arbitrary file truncation and data overwrite (High Integrity & Availability Impact)
  • Exploit Status: Regression test available; no active exploitation reported
  • CISA KEV Status: Not Listed

Affected Systems

  • uutils coreutils (uu_split)
  • coreutils (uu_split): < 0.2.2 (prior to commit 58040feb5c66fce588a7ffac299b3a23bd55cd81) (Fixed in: 0.2.2)

Code Analysis

Commit: 58040fe

Harden split output file creation against TOCTOU symlink swaps using atomic create_new and fd-based identity checks prior to truncation

File: src/uu/split/src/platform/unix.rs
@@ -128,37 +128,33 @@ impl Drop for FilterWriter {
 /// Instantiate either a file writer or a "write to shell process's stdin" writer
 pub fn instantiate_current_writer(
     filter: Option<&str>,
+    input: &OsStr,
     filename: &OsStr,
     is_new: bool,
 ) -> Result<BufWriter<Box<dyn Write>>> {
     match filter {
         None => {
             let file = if is_new {
-                // create new file
-                std::fs::OpenOptions::new()
-                    .write(true)
-                    .create(true)
-                    .truncate(true)
-                    .open(Path::new(filename))
-                    .map_err(|e| match e.kind() {
-                        ErrorKind::IsADirectory => Error::other(
-                            translate!("split-error-is-a-directory", "dir" => filename.quote()),
-                        ),
-                        _ => Error::other(
-                            translate!("split-error-unable-to-open-file", "file" => filename.quote()),
-                        ),
-                    })?
+                create_or_truncate_output_file(input, filename)?
             } else {
                 // re-open file that we previously created to append to it
-                std::fs::OpenOptions::new()
+                let file = std::fs::OpenOptions::new()
                     .append(true)
                     .open(Path::new(filename))
                     .map_err(|_| {
                         Error::other(translate!(
                             "split-error-unable-to-reopen-file",
                             "file" => filename.quote()
                         ))
                     })?;
+
+                if input_and_output_refer_to_same_file(input, &file) {
+                    return Err(Error::other(
+                        translate!("split-error-would-overwrite-input", "file" => filename.quote()),
+                    ));
+                }
+
+                file
             };
             Ok(BufWriter::new(Box::new(file) as Box<dyn Write>))
         }
@@ -169,6 +165,54 @@ pub fn instantiate_current_writer(
     }
 }

+fn create_or_truncate_output_file(input: &OsStr, filename: &OsStr) -> Result<std::fs::File> {
+    match std::fs::OpenOptions::new()
+        .write(true)
+        .create_new(true)
+        .open(Path::new(filename))
+    {
+        Ok(file) => Ok(file),
+        Err(e) if e.kind() == ErrorKind::AlreadyExists => {
+            let file = std::fs::OpenOptions::new()
+                .write(true)
+                .open(Path::new(filename))
+                .map_err(|err| open_file_error(filename, err.kind()))?;
+
+            if input_and_output_refer_to_same_file(input, &file) {
+                return Err(Error::other(
+                    translate!("split-error-would-overwrite-input", "file" => filename.quote()),
+                ));
+            }
+
+            file.set_len(0)
+                .map_err(|err| open_file_error(filename, err.kind()))?;
+            Ok(file)
+        }
+        Err(e) => Err(open_file_error(filename, e.kind())),
+    }
+}

Mitigation Strategies

  • Upgrade uutils coreutils to include commit 58040feb5c66fce588a7ffac299b3a23bd55cd81 (version 0.2.2 or later).
  • Execute split only within private directories owned exclusively by the invoking user (mode 0700).
  • Enforce Linux kernel symlink traversal protections (fs.protected_symlinks = 1) on multi-user systems.

Remediation Steps:

  1. Audit automated scripts, cron jobs, and CI/CD pipelines to ensure uutils split does not output directly into /tmp, /var/tmp, or shared directories.
  2. Update the uutils coreutils binary or uu_split Rust crate to a build containing commit 58040feb5c66fce588a7ffac299b3a23bd55cd81.
  3. Verify that fs.protected_symlinks is set to 1 in /etc/sysctl.conf or /etc/sysctl.d/ on Linux hosts.

References

Read the full report for CVE-2026-35374 on our website for more details including interactive diagrams and full exploit analysis.

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.