Repository navigation
test(transfer): comprehensive symlink-swap attack regression (SEC-1.m) - #4675
Merged
Merged
Conversation
4 tasks
oferchen
force-pushed
the
test/sec-1-m-symlink-swap-attack
branch
from
May 21, 2026 14:53
e74fa91 to
ee1efd2
Compare
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
force-pushed
the
test/sec-1-m-symlink-swap-attack
branch
from
May 21, 2026 15:50
ee1efd2 to
fbee3c3
Compare
Merged
3 tasks
3 of 4 tasks
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
crates/transfer/tests/sec_1_m_symlink_swap_attack.rs: a consolidated end-to-end attack harness that ties the SEC-1.f (lstat-class, feat(fast_io,engine): replace lstat/symlink_metadata with fstatat(AT_SYMLINK_NOFOLLOW) (SEC-1.f) #4668 merged) and SEC-1.g (unlink-class, feat(fast_io,transfer): replace remove_file/remove_dir with unlinkat (SEC-1.g) #4671 in CI) primitives together at the receiver-pipeline integration level.lstat_via_sandbox_or_fallbackandunlink_via_sandbox_or_fallbackhelpers, on filesystem state shaped exactly the way the receiver shapes it.fstatat_swap_resistance.rs,unlinkat_swap_resistance.rs) cover the helpers on quiescent trees only.Scenarios
Scenario 1 - lstat-class invariant under live race. Attacker swaps
dest/leaffor 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.Scenario 2 - unlink-class invariant under live race. Attacker swaps
dest/follower(a hardlink ofdest/leader) for a symlink todest/leaderbetween the receiver's decide-to-delete moment and the sandbox-anchored unlinkat. The leader must survive every interleaving; a path-basedremove_filewould have followed the symlink and deleted the leader, which is exactly the regression SEC-1.g prevents.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
docs/audits/sec-1-a-path-syscall-surface-2026-05-20.md(path-syscall surface inventory).Constraints honoured
unsafeoutsidefast_io.#[allow(...)]waivers.tempfileandcrossbeam-channelare already intransferdev-dependencies.#![cfg(unix)]gate at the crate root - the entire test file compiles to nothing on Windows sinceDirSandboxis Unix-only.crossbeam-channelbounded(1) handshakes; nosleep-based races (perproject_concurrent_dispatch_test_flake).Test plan
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features --no-deps -- -D warningscargo nextest run -p transfer --test sec_1_m_symlink_swap_attack(3 tests; gated to Unix; requires feat(fast_io,transfer): replace remove_file/remove_dir with unlinkat (SEC-1.g) #4671 merged first)