Skip to content

test(transfer): comprehensive symlink-swap attack regression (SEC-1.m) - #4675

Merged
oferchen merged 1 commit into
masterfrom
test/sec-1-m-symlink-swap-attack
May 21, 2026
Merged

oferchen merged 1 commit into
masterfrom
test/sec-1-m-symlink-swap-attack

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

Scenarios

  1. Scenario 1 - lstat-class invariant under live race. Attacker swaps dest/leaf for a symlink pointing into a sibling sensitive tree between the receiver's decide-to-stat moment and the sandbox-anchored lstat. The helper must report the leaf itself (file or symlink), never the dereferenced target outside the sandbox. The sensitive tree must be byte-identical after the race.

  2. Scenario 2 - unlink-class invariant under live race. Attacker swaps dest/follower (a hardlink of dest/leader) for a symlink to dest/leader between the receiver's decide-to-delete moment and the sandbox-anchored unlinkat. The leader must survive every interleaving; a path-based remove_file would have followed the symlink and deleted the leader, which is exactly the regression SEC-1.g prevents.

  3. Scenario 3 - tight race-window stress. 64 iterations of swap-vs-stat-vs-unlink with deterministic crossbeam-channel handshakes (not sleep-based, per the concurrent-dispatch flake learning - scheduler hiccups on Windows / macOS CI runners turn sleep-based races into flakes). The sensitive tree must remain byte-identical across every iteration regardless of who wins each individual race.

Dependency on #4671

This test file consumes the SEC-1.g API surface (fast_io::UnlinkFlags, fast_io::unlink_via_sandbox_or_fallback) added in #4671. It will not compile until #4671 merges; CI failures on this PR before #4671 merges are expected. Sequencing: rebase / wait for #4671 to merge first, then merge this.

Audit cite

Constraints honoured

  • No unsafe outside fast_io.
  • No #[allow(...)] waivers.
  • No new workspace dependencies; tempfile and crossbeam-channel are already in transfer dev-dependencies.
  • #![cfg(unix)] gate at the crate root - the entire test file compiles to nothing on Windows since DirSandbox is Unix-only.
  • Deterministic synchronisation via crossbeam-channel bounded(1) handshakes; no sleep-based races (per project_concurrent_dispatch_test_flake).

Test plan

Add a consolidated end-to-end attack harness that ties the SEC-1.f
(lstat-class) and SEC-1.g (unlink-class) primitives together at the
receiver-pipeline integration level. The two existing per-primitive
test files cover the helpers on quiescent trees; this harness pins
the documented SEC-1 TOCTOU invariant against an active attacker
thread that races the receiver.

Three scenarios:

1. Lstat-class invariant under live race: attacker swaps the
   destination leaf for a symlink pointing into a sibling sensitive
   tree between the receiver's decide-to-stat moment and the
   sandbox-anchored lstat. The helper must report the leaf itself
   (file or symlink), never the dereferenced target outside the
   sandbox.

2. Unlink-class invariant under live race: attacker swaps a
   hardlink follower for a symlink to the leader between the
   receiver's decide-to-delete moment and the sandbox-anchored
   unlinkat. The leader must survive every interleaving; a
   path-based remove_file would have deleted the leader through
   the swapped symlink (the exact regression SEC-1.g prevents).

3. Tight race-window stress: 64 iterations of swap-vs-stat-vs-unlink
   with deterministic crossbeam-channel handshakes (not sleep-based,
   per the concurrent-dispatch flake learning). The sensitive tree
   must remain byte-identical across every iteration regardless of
   who wins each race.

Dependencies / sequencing:

- Consumes the SEC-1.g API surface (fast_io::UnlinkFlags,
  fast_io::unlink_via_sandbox_or_fallback) added in #4671. CI
  failures before #4671 merges are expected; rebase after merge.
- No unsafe outside fast_io, no allow waivers, no new workspace
  deps (crossbeam-channel and tempfile are already dev-deps).
- Gated #[cfg(unix)] since DirSandbox is Unix-only.
@oferchen
oferchen force-pushed the test/sec-1-m-symlink-swap-attack branch from ee1efd2 to fbee3c3 Compare May 21, 2026 15:50
@oferchen
oferchen merged commit 2e654b0 into master May 21, 2026
55 checks passed
@oferchen
oferchen deleted the test/sec-1-m-symlink-swap-attack branch May 22, 2026 06:40
oferchen added a commit that referenced this pull request Aug 24, 2026
#4675)

Add a consolidated end-to-end attack harness that ties the SEC-1.f
(lstat-class) and SEC-1.g (unlink-class) primitives together at the
receiver-pipeline integration level. The two existing per-primitive
test files cover the helpers on quiescent trees; this harness pins
the documented SEC-1 TOCTOU invariant against an active attacker
thread that races the receiver.

Three scenarios:

1. Lstat-class invariant under live race: attacker swaps the
   destination leaf for a symlink pointing into a sibling sensitive
   tree between the receiver's decide-to-stat moment and the
   sandbox-anchored lstat. The helper must report the leaf itself
   (file or symlink), never the dereferenced target outside the
   sandbox.

2. Unlink-class invariant under live race: attacker swaps a
   hardlink follower for a symlink to the leader between the
   receiver's decide-to-delete moment and the sandbox-anchored
   unlinkat. The leader must survive every interleaving; a
   path-based remove_file would have deleted the leader through
   the swapped symlink (the exact regression SEC-1.g prevents).

3. Tight race-window stress: 64 iterations of swap-vs-stat-vs-unlink
   with deterministic crossbeam-channel handshakes (not sleep-based,
   per the concurrent-dispatch flake learning). The sensitive tree
   must remain byte-identical across every iteration regardless of
   who wins each race.

Dependencies / sequencing:

- Consumes the SEC-1.g API surface (fast_io::UnlinkFlags,
  fast_io::unlink_via_sandbox_or_fallback) added in #4671. CI
  failures before #4671 merges are expected; rebase after merge.
- No unsafe outside fast_io, no allow waivers, no new workspace
  deps (crossbeam-channel and tempfile are already dev-deps).
- Gated #[cfg(unix)] since DirSandbox is Unix-only.
oferchen added a commit that referenced this pull request Aug 24, 2026
…n/.k/.l ship state

Update CVE-2026-29518 and CVE-2026-43619 entries to "Mostly fixed",
reflecting the SEC-1 sub-tasks now in master:

- .a/.b/.c/.d/.e: DirSandbox carrier, openat2 detection, receiver wiring
- .f: lstat to fstatat (PR #4668)
- .g: remove to unlinkat (PR #4671)
- .h: mkdir/symlink/hard_link to *at variants (PR #4683)
- .k: macOS verified
- .l: Windows audited (NTFS handle-based, not affected)
- .m: symlink-swap attack regression (PR #4675)
- .n: legitimate symlink interop regression (PR #4678)

Remaining work explicitly listed:

- .i (chmod/lchown/utimes to *at) - in flight
- .j (rename to renameat) - in flight
- mknodat for device/FIFO nodes - deferred (not daemon-reachable)
- Receiver wiring for SEC-1.i helpers - deferred (carrier-first staging)

Target full-Fixed status: when SEC-1.i and SEC-1.j ship and all receiver
call sites are wired through DirSandbox.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant