uutils / uutils/coreutils

install: post-copy finalization reopens destination by path, allowing symlink-swap redirection

Open
#12,062 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

U - install
Dominant language
Rust
Stars
24.1k
Forks
2k
Avg merge
1d 5h
Merged PRs (30d)
365

Description

install safely creates the destination file relative to a parent directory fd, but then falls back to path-based post-copy finalization on the original destination pathname.

That finalization path includes --strip-program, chmod, timestamp updates, and some SELinux handling. If an attacker can replace the destination leaf with a symlink after the copy step but before finalization, those later operations can be redirected to a different file.

This is reproducible with install -s --strip-program ...: a delayed strip helper gives enough time to swap dest to dest -> victim, and the helper then writes to victim instead of the file install created.

Impact:

  • Real TOCTOU vulnerability on Unix
  • High risk when install is used in a privileged workflow
  • The safe write phase and the finalization phase do not stay bound to the same inode

Root cause:

  • Safe create/write by fd
  • Unsafe finalization by pathname

Suggested fix:

  • Keep the destination file open through finalization
  • Perform strip/metadata updates via that file handle
  • Reject destination path changes before success
  • Use O_NOFOLLOW | O_EXCL for fd-based destination creation

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the install implementation's fd-based destination creation and path-based post-copy finalization, especially the --strip-program flow. Reproduce the symlink swap with a delayed strip helper, then trace chmod, timestamp, and SELinux handling. Done means finalization remains bound to the created file and destination path changes cannot redirect operations.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, security
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.