Unsafe at Any Copy: Name Collisions from Mixing Case Sensitivities

Aditya Basu, John Sampson, Zhiyun Qian, Trent Jaeger

TL;DR

Moving files between case-sensitive (e.g., Linux) and case-insensitive (e.g., Windows) environments is a silent security minefield. This paper reveals that standard utilities like cp, rsync, and tar handle "name collisions"—where File.txt and file.txt map to the same location—inconsistently and unsafely, leading to silent data loss, permission bypasses, and remote code execution.

What Problem Does This Paper Address?

For decades, the "case sensitivity" of a file system was tied to the Operating System: UNIX was case-sensitive, and Windows/macOS were not. Today, that boundary has blurred. With the Windows Subsystem for Linux (WSL), cross-platform cloud syncing (Dropbox), and new features in Linux (like ext4 supporting per-directory case-insensitivity), we frequently mix these semantics.

The core problem is the name collision. On a case-sensitive system, Config.php and config.php are two different files. If you copy them to a case-insensitive system, they "collide." The authors argue there is a "diffusion of responsibility": OS developers, utility maintainers, and application programmers all assume someone else is handling these collisions. This gap creates vulnerabilities where an attacker can use a collision to overwrite critical scripts, bypass access controls, or hijack symbolic links.

Methods

The researchers took a three-pronged approach to expose these risks:

  1. Taxonomy of Confusion: They categorized file name vulnerabilities into three types: Alias (multiple names for one resource), Squat (temporal ambiguity), and Collision (multiple resources for one name).
  2. Automated Testing Tool: They built a tool to stress-test common Linux utilities (cp, tar, rsync, zip). The tool generates source directories with colliding names and uses auditd (a Linux auditing daemon) to monitor exactly how the utilities interact with the file system during a copy. They looked for "unsafe effects" like silent overwrites or metadata mismatches.
  3. Real-World Case Studies: They performed deep dives into three widely used systems: the dpkg package manager, the rsync backup tool, and the Apache httpd web server to see if theoretical collisions could become practical exploits.

Datasets

The authors analyzed the Debian 11.2.0 ecosystem:

  • Utility Usage: They scanned 4,752 .deb packages to identify the most common command-line flags used with copy utilities to ensure their testing matched real-world usage.
  • Collision Potential: They analyzed 74,688 packages and found 12,237 filenames that would collide if installed on a case-insensitive file system, potentially breaking or compromising the system.

Key Insights and Ideas

  • The "cp vs. cp*" Distinction: One of the most subtle findings is that how you invoke a command matters. Using cp -a src/ dst/ behaves differently than cp -a src/* dst/ (shell expansion). The latter often leads to more dangerous overwrites because the shell passes each file individually, bypassing some of the utility's internal checks.
  • Silent Data Loss: Utilities like tar were found to be particularly "ruthless." When extracting an archive with colliding names, tar simply deletes the existing file and creates the new one. If an adversary can sneak a colliding file into an archive, they can delete a victim's data without any warning or error message.
  • Metadata Mismatch: Even if a file isn't fully overwritten, its permissions might be. If File.A (restricted) and file.a (public) collide, the final file might end up with the content of one but the (insecure) permissions of the other.
  • Link Traversal via Collision: In rsync, the researchers found that a collision between a directory and a symbolic link could trick the utility into writing files to an arbitrary location on the disk (a classic "confused deputy" attack).

Key Results

The researchers' testing of popular utilities (summarized in the paper's Table 2) showed a lack of any uniform approach:

  • tar: Deletes and recreates files on collision (Silent loss).
  • rsync & cp*: Generally overwrite existing files and merge directory contents silently.
  • Dropbox: Proactively renames files (e.g., adding "(Case Conflict)"), which is safer but inconsistent across platforms.
  • dpkg Vulnerability: They confirmed that dpkg reasons about names in a case-sensitive way regardless of the underlying file system. An attacker could craft a package that, via name collision, overwrites a configuration file (like /etc/shadow) from a completely different, legitimate package.
  • Apache Bypass: They demonstrated that migrating a web root via tar to a case-insensitive system could cause a collision that overwrites a restrictive .htaccess file with an empty or permissive one, exposing private data.

Limitations and Future Work

The authors acknowledge that fixing this is difficult because user-space applications cannot easily determine the "case folding" rules of a target file system, which may vary by locale or OS version.

Future Work includes: * OS-Level Defenses: Proposing new system call flags, such as O_EXCL_NAME, which would prevent opening a file if a name exists that differs only by case. * Uniformity: Developing a standard approach for utilities to handle collisions (e.g., always prompting the user or using a consistent renaming scheme). * Wider Audits: Expanding the research to Windows-native utilities and other cloud sync providers.

Summary updated

BibTeX
@inproceedings{basu2023unsafe,
  author = {Aditya Basu and John Sampson and Zhiyun Qian and Trent Jaeger},
  title = {{Unsafe at Any Copy: Name Collisions from Mixing Case Sensitivities}},
  booktitle = {FAST},
  year = {2023},
}
Figure