Wave icon indicating copy to clipboard operation
Wave copied to clipboard

Prevent a symlinked default target directory from bypassing cleanup ownership checks

Open LunaStev opened this issue 3 weeks ago • 0 comments

Problem

Cleanup compares a custom directory against the resolved default target path. If checkout/target points at unowned data, selecting that real directory obtains the default-path exception and deletes its contents.

Reproduction and evidence

Audited canonical master 69a67c6e0fb700f37ee6114f5a66d37ee13771a5 (0.0.1-alpha-dev). Matching checkout-built compiler/std were used for compiler probes on Linux amd64 with Rust 1.89.0 and LLVM 21.1.8. Artifact inspection, mocked/projection checks and foreign-target object emission are identified below and are not native execution on those operating systems.

Use a disposable checkout-shaped tree only. Copy tests/cases/cases.toml into it so Manifest::load succeeds; create user-data/KEEP and a target symlink to user-data, without a .wave-cargo-owner marker. Invoke:

wave_tools::build::clean_outputs(&checkout, &checkout.join("user-data"), &checkout.join("dist"))

Observed: Ok; user-data/KEEP and user-data are removed while target remains a dangling link. No real user directory was used in the audit.

Scope

Base the default-directory exception on the selected directory entry/ownership, not an arbitrary target reached by resolving a default symlink. Keep validation before any deletion.

Starting points: tools/src/build.rs:146.

Completion criteria

  • [ ] Reject an unmarked real directory reached through this alias without mutating it.
  • [ ] Cleaning a selected symlink unlinks that entry rather than its referent.
  • [ ] Retain normal owned/default cleanup and checkout/ancestor protection using disposable fixtures.

Related: #822. Related broad trackers or completed implementations are context, not claims that their entire scope is unfinished.

LunaStev avatar Nov 12 '26 12:11 LunaStev