Repository navigation
fix(cli): engage Landlock sandbox on --server receiver entry (UTS-16) - #5724
Merged
Merged
Conversation
Wires fast_io::landlock::restrict_to_module_paths into the lsh.sh-style --server receiver path before the token loop. The upstream chdir-symlink-race and bare-do-open-symlink-race tests swap a destination subdir for a symlink pointing outside the requested root; without a kernel-enforced allowlist the receiver follows the symlink and chmod's a file outside the destination tree (observed: "outside file mode changed from 600 to 666 (chmod escape)" with seccomp disabled). Also: - bump landlock module from ABI::V3 to ABI::V5 so kernels with IPC scoping (6.7+, including the target test host on 7.0) tighten the ruleset further. BestEffort downgrade preserves V3 rights on older kernels. - forward the landlock feature into the CLI build on Linux so the binary links the real restrict_to_module_paths instead of the no-op stub. The wire-in only fires for ServerRole::Receiver with a destination root in config.args; sender and stat-only invocations skip the restriction so they do not deny their own reads. Sandbox engage failures surface as a typed server error - the intended sandbox did not engage and the connection must abort rather than silently degrade.
oferchen
force-pushed
the
fix/uts16-landlock-server-sandbox
branch
from
June 11, 2026 23:10
63bf271 to
ffc3b35
Compare
2 tasks
oferchen
added a commit
that referenced
this pull request
Jun 12, 2026
* chore: fix master fmt drift + filter_map_bool_then clippy lint
Master CI broke on rustfmt 1.88 and clippy 1.88:
1. `crates/cli/src/frontend/server/run.rs:244` - `use fast_io::landlock::{...}`
collapses to a single line under rustfmt 1.88 (introduced by PR #5724's
landlock wire-in).
2. `crates/transfer/src/generator/filters.rs:589` - `let split = ...` long-form
collapses to single-line under rustfmt 1.88.
3. `crates/transfer/src/generator/file_list/mod.rs:267` - rewrite
`filter_map(|(b, rel)| (b == &entry.base).then(|| rel.clone()))` as the
equivalent `filter(...).map(...)` pair so clippy 1.88's new
`filter_map_bool_then` lint stays clean. Behaviour-identical.
Unblocks PRs #5725, #5726, #5727 once they rebase onto this.
* fix: drop extraneous deref in filter predicate
In .filter(), the destructured 'b' is already &PathBuf since iter() yields
&(PathBuf, PathBuf) and filter receives &Self::Item. The extra deref made it
PathBuf, causing E0277 'can't compare PathBuf with &PathBuf'.
* chore(cli): inline format args in --partial-dir test (clippy 1.88)
uninlined_format_args lint denies the build under clippy 1.88.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…#5724) Wires fast_io::landlock::restrict_to_module_paths into the lsh.sh-style --server receiver path before the token loop. The upstream chdir-symlink-race and bare-do-open-symlink-race tests swap a destination subdir for a symlink pointing outside the requested root; without a kernel-enforced allowlist the receiver follows the symlink and chmod's a file outside the destination tree (observed: "outside file mode changed from 600 to 666 (chmod escape)" with seccomp disabled). Also: - bump landlock module from ABI::V3 to ABI::V5 so kernels with IPC scoping (6.7+, including the target test host on 7.0) tighten the ruleset further. BestEffort downgrade preserves V3 rights on older kernels. - forward the landlock feature into the CLI build on Linux so the binary links the real restrict_to_module_paths instead of the no-op stub. The wire-in only fires for ServerRole::Receiver with a destination root in config.args; sender and stat-only invocations skip the restriction so they do not deny their own reads. Sandbox engage failures surface as a typed server error - the intended sandbox did not engage and the connection must abort rather than silently degrade.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
* chore: fix master fmt drift + filter_map_bool_then clippy lint
Master CI broke on rustfmt 1.88 and clippy 1.88:
1. `crates/cli/src/frontend/server/run.rs:244` - `use fast_io::landlock::{...}`
collapses to a single line under rustfmt 1.88 (introduced by PR #5724's
landlock wire-in).
2. `crates/transfer/src/generator/filters.rs:589` - `let split = ...` long-form
collapses to single-line under rustfmt 1.88.
3. `crates/transfer/src/generator/file_list/mod.rs:267` - rewrite
`filter_map(|(b, rel)| (b == &entry.base).then(|| rel.clone()))` as the
equivalent `filter(...).map(...)` pair so clippy 1.88's new
`filter_map_bool_then` lint stays clean. Behaviour-identical.
Unblocks PRs #5725, #5726, #5727 once they rebase onto this.
* fix: drop extraneous deref in filter predicate
In .filter(), the destructured 'b' is already &PathBuf since iter() yields
&(PathBuf, PathBuf) and filter receives &Self::Item. The extra deref made it
PathBuf, causing E0277 'can't compare PathBuf with &PathBuf'.
* chore(cli): inline format args in --partial-dir test (clippy 1.88)
uninlined_format_args lint denies the build under clippy 1.88.
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
Wires `fast_io::landlock::restrict_to_module_paths` into the lsh.sh-style `--server` receiver path before the token loop. This closes the chdir-symlink-race chmod-escape surfaced by the upstream testsuite once seccomp was disabled:
```
chdir-symlink-race: -r --size-only into upload/ root:
outside file mode changed from 600 to 666 (chmod escape)
```
The receiver was following an attacker-planted symlink and chmod-ing a file outside the destination tree. The daemon path already has the SEC-1.p Landlock sandbox via `engage_landlock_sandbox` in `module_access/transfer.rs:292`; the SSH `--server` entry never engaged it.
Changes
`crates/cli/src/frontend/server/run.rs` — Engage `restrict_to_module_paths(&[dest_root])` after parsing positional args, before `run_server_stdio`. Receiver-only (sender / stat-only have no write target). Engage failures abort with a typed server error so the intended sandbox is never silently skipped.
`crates/fast_io/src/landlock.rs` — Bump `AccessFs::from_all(ABI::V3)` → `ABI::V5` so kernels 6.7+ (including the target test host on 7.0) pick up the IPC scoping surface. BestEffort downgrade preserves V3 rights on older kernels.
`crates/cli/Cargo.toml` — Forward the `landlock` feature into the CLI's `fast_io` dep on Linux. Mirrors the daemon pattern: non-Linux targets compile the stub module with the same public surface, so the call site needs no `#[cfg]` branching.
Test plan