Repository navigation
Conversation
The 2.1 native jail (StartJailedExecWithResources) launched bash -> systemd-run --scope -> bwrap with the target's environment as `--setenv KEY VALUE` arguments. /proc/<pid>/cmdline is readable by every process of the same user, so a token a host passed in the environment was visible on the launcher's, systemd-run's and bwrap's command lines for as long as the command ran. Setting the variables on the launcher's environment instead would expose them to those host-side programs and let a value such as LD_PRELOAD or BASH_ENV run code there. The --setenv triples are now written NUL-separated to a private file (0600 in a fresh 0700 directory under $XDG_RUNTIME_DIR or the temp dir, never under a grant). The launcher shim opens it as descriptor 9 and deletes it before closing every other inherited descriptor, and bwrap reads it with `--args 9`. native_jail_argv(_with_programs) now returns a NativeJailLaunch that owns the file and removes it on drop, in case the launcher never runs; the module holds it for the execution. Not in this change: the namespace box backend's exec also passes --setenv on bwrap's command line, and its host may be remote (SSH), which needs its own transport.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Tiny Sweeper reviewReviewed head: Verdict: Ready for maintainer review · Priority: none Diagnostics and supporting detailsFull summaryPull request purpose (title): Keep a resource jail's environment off every command line. Tiny Sweeper completed its review; deterministic results follow. Review snapshot
Completeness: Complete What changedEnvironment values for the resource jail are moved off the command line: `env_file::EnvArgsFile::create` serializes the map into `--setenv`/key/value byte runs separated by NULs into a 0600 file created with `create_new` inside a fresh 0700 directory, drawing the base directory from `$XDG_RUNTIME_DIR` else the temp directory, canonicalized and rejected if it falls under the jail's root or any read-only/read-write grant, with random hex naming from `/dev/urandom` and cleanup on `Drop`. `native_bwrap_argv` now emits `--args 9` instead of per-variable `--setenv` triples, and the launcher shim script takes the env-file path as its first argument, opens it on descriptor 9, unlinks it, removes the parent directory, and preserves descriptor 9 while closing every other non-stdio descriptor. `native_jail_argv` and `native_jail_argv_with_programs` return a new `NativeJailLaunch` pairing the argv with the owned file handle, re-exported from the crate root and sandbox module. In the module, `NativeResourceBackend` gains a `launch` slot and a `keep` method so the handle is held until the execution's backend drops, and `configure_resource_launcher` binds and clones the new argv rather than assigning a `Vec<String>`. Latest-push delta: unavailable. The review state carries the prior reviewed head `7f2b0f1f2d0bd9f1133f6161fd50ee3a0fb786d2` and the current head `b23e4ec813aab68fcb842428039058367c2e0e5b`, but no trusted base-to-head diff comparison, so the whole-pull-request diff is not presented as a push delta. Features
TestsNo supported feature-to-test mapping was produced. Test execution is not inferred. FindingsNo active actionable findings. Before mergeNone. How this fits togetherflowchart LR
n0["NativeJailCommand<br/>changed"]:::changed
n1["native_bwrap_argv<br/>changed"]:::changed
n2["native_jail_argv_with_programs<br/>changed"]:::changed
n3["..._target_environment_after_namespace_setup<br/>changed"]:::changed
n4["configure_resource_launcher<br/>changed"]:::changed
n5["unavailable<br/>changed"]:::changed
n6["prepare_with_resources"]:::impacted
n7["tempdir"]:::impacted
n8["...d_descendants_and_preserves_stream_events"]:::impacted
n9["resource_backend"]:::impacted
n10["...cpu_limit_throttles_the_live_native_scope"]:::impacted
n1 -->|uses| n0
n2 -->|uses| n0
n2 -->|calls| n1
n3 -->|uses| n0
n3 -->|calls| n2
n3 -->|tests| n2
n3 -->|calls| n7
n3 -->|tests| n7
n4 -->|uses| n0
n4 -->|calls| n2
n4 -->|calls| n5
n6 -->|uses| n0
n6 -->|calls| n4
n6 -->|calls| n5
n8 -->|calls| n6
n8 -->|tests| n6
n8 -->|calls| n7
n8 -->|tests| n7
n8 -->|calls| n9
n8 -->|tests| n9
n10 -->|calls| n6
n10 -->|tests| n6
n10 -->|calls| n7
n10 -->|tests| n7
classDef changed fill:#0d4429,stroke:#238636,color:#e6edf3
classDef impacted fill:#161b22,stroke:#6e7681,color:#c9d1d9
classDef flagged fill:#5a1e02,stroke:#d93f0b,color:#ffffff
classDef blocking fill:#67060c,stroke:#f85149,color:#ffffff
Agent review detailscritique
security
tests
commits
description
Evidence and run details
|
# Conflicts: # crates/tinybox-module/src/tinybus_module/native_jail_tests.rs
Summary
The 2.1 native resource jail (
StartJailedExecWithResources) passed the jailed command's environment to bubblewrap as--setenv KEY VALUEarguments./proc/<pid>/cmdlineis readable by every process of the same user, so a token in that environment was readable by every such process for the life of the launcher,systemd-runandbwrapprocesses.The
--setenvtriples now go, NUL-separated, into a private file: mode 0600, in a fresh 0700 directory under$XDG_RUNTIME_DIR(else the temp directory), never inside one of the jail's grants. The launcher opens that file as descriptor 9 and deletes it before anything else runs.bwrap --args 9then reads the triples. No value appears on any command line or in any host-side process environment. The file is also removed when the launch handle drops, in case the launcher never ran.Setting the variables on the launcher's own environment was rejected: that would expose them to the host-side programs on the way, and a value such as
LD_PRELOADwould run code there.Related issue
None filed. Found reading the 2.1 launcher. The legacy bwrap backend already avoids this with its own
--argsfile (tinybox-jail/src/bwrap/launcher.rs).API or behavior changes
tinybox_linux::native_jail_argvandnative_jail_argv_with_programsreturnNativeJailLaunch { argv, .. }instead ofVec<String>. The handle owns the environment file and must outlive the spawn. Nothing outside this repo calls them.Validation
On our Linux CI runner (bubblewrap 0.9.0, user systemd session running), at b4910d6:
cargo fmt --all -- --check: clean.cargo clippy --all-targets --all-features -- -D warnings: 0 errors, same as main.cargo build --all-targets --all-featuresandRUSTDOCFLAGS="-D warnings" cargo doc: ok.cargo test -p tinybox-linux -p tinybox-module: no failures, the same as main. The live testa_resource_jail_keeps_the_target_environment_off_every_command_lineran, not skipped.--setenvback in the argv: both the argv test and the live test fail ("the launcher's own argv carries the value");Tests
env_file_tests.rs:native_jail_command_…test asserts that no target value appears anywhere in the argv.a_resource_jail_keeps_the_target_environment_off_every_command_line(live, Linux with a user systemd session and bubblewrap): it runs a jailed command with a marker value in its environment, and checks that the command sees the value and that no/proc/*/cmdlineholds it.the_command_line_scan_finds_a_running_process_argument(Linux): the/proc/*/cmdlinescan the live test relies on does find a marker on a running process's command line, so an empty result means no leak, not a broken scan.--setenvback in the argv fails both tests, and a scan that never matches fails the scan test.Documentation
Module docs in
env_file.rsand rustdoc onNativeJailLaunch.Checklist
#[allow(...)],#[ignore], or relaxed lints.envcontents in the diff or the description