Skip to content

test(transfer): legitimate symlink transfers must not regress (SEC-1.n) - #4678

Merged
oferchen merged 1 commit into
masterfrom
test/sec-1-n-legitimate-symlinks-interop
May 21, 2026
Merged

oferchen merged 1 commit into
masterfrom
test/sec-1-n-legitimate-symlinks-interop

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

SEC-1.n is the SAFETY-of-LEGITIMATE-USE counterpart to SEC-1.m's attack harness (#4675, in CI). The sandbox-anchored helpers introduced by SEC-1.f (fstatat(AT_SYMLINK_NOFOLLOW), #4668 merged) and extended by SEC-1.g (unlinkat family, #4671 in CI) tighten how the receiver stats and unlinks destination obstacles. This test pins the inverse invariant: every legitimate symlink rsync emits with -l / -a must continue to land on disk verbatim, with target text byte-identical and adjacent inodes / contents untouched.

Six scenarios mirror upstream rsync legitimate-use cases:

  1. Plain relative symlink - dir/link -> target.txt preserved verbatim.
  2. Absolute symlink - dir/link -> /etc/hostname preserved verbatim, even without --copy-unsafe-links.
  3. Symlink to directory - dir/link -> subdir/ preserved as a symlink; subdir/file.txt lands once as a regular file, not duplicated through the link.
  4. Broken symlink - dir/dangling -> nonexistent preserved; the sandbox-anchored stat reports the symlink (not ENOENT via follow); receiver does not fail.
  5. Symlink chain - a -> b -> c -> file.txt preserved link-by-link, never flattened.
  6. Hardlink-with-symlink mixed - with -aH, hl1/hl2 share an inode AND sl -> hl1 is preserved as a symlink (distinct inode from the hardlinked pair).

Compile compatibility

The file uses only the SEC-1.f API surface present in current master (fast_io::DirSandbox, fast_io::LstatOutcome, fast_io::lstat_via_sandbox_or_fallback from #4668). It deliberately does NOT consume the SEC-1.g UnlinkFlags / unlink_via_sandbox_or_fallback surface from #4671, so the test compiles cleanly against master while #4671 is still in CI. Once #4671 lands, the unlink-class assertions can be tightened in a follow-up without changing this file.

Like SEC-1.m, this harness does not stand up a full receiver pipeline. The SEC-1 invariants live in fast_io::lstat_via_sandbox_or_fallback and the receiver consumes them through the DirSandbox carrier (SEC-1.e). Each scenario shapes a receiver-style destination tree the same way the receiver's create_symlinks and create_hardlinks paths shape it, then calls the same helpers the receiver calls.

Gated #![cfg(unix)]; Windows skips the test module entirely.

Closes #2532.

Test plan

  • cargo nextest run -p transfer --all-features -E 'test(sec_1_n)' passes on Linux
  • Same on macOS
  • Windows: skipped via cfg(unix)
  • Full transfer-crate suite remains green

@github-actions github-actions Bot added the test label May 21, 2026
@oferchen
oferchen force-pushed the test/sec-1-n-legitimate-symlinks-interop branch from 945c1f7 to 43628d6 Compare May 21, 2026 14:55
Add a six-scenario integration regression that pins the SAFETY-of-
legitimate-use counterpart to SEC-1.m's attack harness. The
sandbox-anchored helpers introduced by SEC-1.f (and extended by
SEC-1.g) tighten how the receiver stats and unlinks destination
obstacles; this test asserts they do not regress legitimate symlink
workflows the receiver emits every run with -l / -a:

  1. Plain relative symlink preserved verbatim
  2. Absolute symlink preserved verbatim (no --copy-unsafe-links)
  3. Symlink to directory preserved with unique underlying contents
  4. Broken symlink preserved without follow-error
  5. Symlink chain preserved link-by-link, never flattened
  6. Hardlink pair plus symlink-to-leader preserved together

Each scenario shapes a receiver-style destination tree the same way
the receiver's create_symlinks / create_hardlinks paths shape it,
calls fast_io::lstat_via_sandbox_or_fallback (the SEC-1.f cutover
the receiver already routes through), and asserts every legitimate
symlink lands on disk with its target text byte-identical and
adjacent inodes / contents untouched.

The file uses only the SEC-1.f API surface present in current master
(DirSandbox, LstatOutcome, lstat_via_sandbox_or_fallback), so it
compiles cleanly while the SEC-1.g unlinkat surface is still in CI.
@oferchen
oferchen force-pushed the test/sec-1-n-legitimate-symlinks-interop branch from 43628d6 to d068fde Compare May 21, 2026 15:50
@oferchen
oferchen merged commit db09828 into master May 21, 2026
55 checks passed
@oferchen
oferchen deleted the test/sec-1-n-legitimate-symlinks-interop branch May 22, 2026 06:40
oferchen added a commit that referenced this pull request Aug 24, 2026
…n) (#4678)

Add a six-scenario integration regression that pins the SAFETY-of-
legitimate-use counterpart to SEC-1.m's attack harness. The
sandbox-anchored helpers introduced by SEC-1.f (and extended by
SEC-1.g) tighten how the receiver stats and unlinks destination
obstacles; this test asserts they do not regress legitimate symlink
workflows the receiver emits every run with -l / -a:

  1. Plain relative symlink preserved verbatim
  2. Absolute symlink preserved verbatim (no --copy-unsafe-links)
  3. Symlink to directory preserved with unique underlying contents
  4. Broken symlink preserved without follow-error
  5. Symlink chain preserved link-by-link, never flattened
  6. Hardlink pair plus symlink-to-leader preserved together

Each scenario shapes a receiver-style destination tree the same way
the receiver's create_symlinks / create_hardlinks paths shape it,
calls fast_io::lstat_via_sandbox_or_fallback (the SEC-1.f cutover
the receiver already routes through), and asserts every legitimate
symlink lands on disk with its target text byte-identical and
adjacent inodes / contents untouched.

The file uses only the SEC-1.f API surface present in current master
(DirSandbox, LstatOutcome, lstat_via_sandbox_or_fallback), so it
compiles cleanly while the SEC-1.g unlinkat surface is still in CI.
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