Unsafe at Any Copy: Name Collisions from Mixing Case Sensitivities

Aditya Basu, John Sampson, Zhiyun Qian, Trent Jaeger

Introduction

Moving files between case-sensitive (e.g., Linux) and case-insensitive (e.g., Windows) environments has become a common practice with the rise of the Windows Subsystem for Linux (WSL), cloud syncing services, and per-directory case-insensitivity in Linux filesystems like ext4. However, this mixing of semantics creates a silent security minefield. Standard utilities such as 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 potential remote code execution.

Taxonomy of Name Confusion

The researchers identified a "diffusion of responsibility" where OS developers, utility maintainers, and application programmers each assume another layer is handling these collisions. To clarify the risks, they developed a taxonomy of file name vulnerabilities categorized into three types: Alias (multiple names for one resource), Squat (temporal ambiguity), and Collision (multiple resources for one name).

Taxonomy of Name Confusion (NC) showing the hierarchical relationship between Alias, Squat, and Collision vulnerabilities.

The Collision Problem

The core issue is the name collision. On a case-sensitive system, Config.php and config.php are two distinct files. When copied to a case-insensitive system, they collide. The researchers built an automated tool using auditd to monitor how utilities interact with the filesystem during these events. They found that many tools fail to provide warnings, leading to "unsafe effects" where one file silently overwrites another or metadata is incorrectly merged.

A visual demonstration of a name collision during a copy operation where distinct source directories (dir/ and DIR/) are merged into a single target directory.

Key Insights and Empirical Analysis

The study analyzed the Debian 11.2.0 ecosystem, scanning over 74,000 packages. They discovered 12,237 filenames that would collide if installed on a case-insensitive filesystem, potentially compromising system integrity.

Key findings include:

  • Silent Data Loss: tar was found to be particularly ruthless, deleting existing files and recreating them upon collision without any error message.
  • Metadata Mismatch: Collisions can lead to a file having the content of one source but the (potentially insecure) permissions of another.
  • Link Traversal: In rsync, a collision between a directory and a symbolic link can trick the utility into writing files to arbitrary locations on the disk.
  • Invocation Matters: Using shell expansion (e.g., cp -a src/* dst/) often bypasses internal utility checks that might otherwise catch a collision, making it more dangerous than direct directory copying.

Real-World Impact

The researchers demonstrated practical exploits in widely used systems:

  • dpkg: An attacker could craft a package that overwrites critical configuration files (like /etc/shadow) via name collision on a case-insensitive filesystem.
  • Apache httpd: Migrating a web root via tar could cause a collision that overwrites a restrictive .htaccess file with a permissive one, exposing private data.

Conclusion and Future Work

Addressing these vulnerabilities is challenging because user-space applications cannot easily determine the case-folding rules of a target filesystem. The authors propose OS-level defenses, such as a new O_EXCL_NAME system call flag to prevent opening files if a case-variant name already exists. Until such standards are adopted, the movement of data across heterogeneous filesystems remains a significant, often overlooked, security risk.

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