Repository navigation
[0.0.24] fix(security): set no_new_privs before landlock_restrict_self - #2284
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 23 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Post-fix matrix probe (evidence)Re-ran the 0.0.24 matrix probe for The confinement refusal is gone. An instrumented run shows the admitted Before the fix the same probe reported, before any process existed: The probe now advances past the spawn gate and still FAILs on a different, That number is deterministic across four runs and two host working Evidence: CodeRabbit reported its review-limit warning on this PR (no findings posted). |
Cover the full `v0.0.23..main` range instead of the earlier partial passes: all 71 merged commits are grouped under Added, Changed, Fixed, Security, and Documentation, with PR numbers and the affected CTX tasks. Explicit call-outs: copy keeps combining marks and ZWJ (#2266), multi-line paste duplication and ghost fixed by the cursor clamp across wide spacers (#2272), combining marks paint so decomposed `é` matches precomposed (#2279), kitty font query and `bitty +show-font` (#2277), bounded native clipboard acquisition path B (#2273), bounded `bitty.fs.list` (#2271), the `bitty.history` Lua surface (#2268), the production ComponentBroker plus activation state (#2267, #2276), Enter-confirm paste (#2269), the `fill` DPI fix (#2283), landlock `no_new_privs` (#2284), and spawn descriptor reservation (#2289). Partials are marked honestly: #2254's request surface is still pending, the #2213 disposition stays open, #2286 is feature-gated and unwired, the macOS clipboard read stays a typed refusal, and the RC-1 fuel accounting fix is not claimed because PR #2292 is unmerged. The heading reads `unreleased` because the release is on hold; the tag date is set at tag time. Docs-only: no code, scripts, workflows, or pins touched.
Cover the full `v0.0.23..main` range instead of the earlier partial passes: all 71 merged commits are grouped under Added, Changed, Fixed, Security, and Documentation, with PR numbers and the affected CTX tasks. Explicit call-outs: copy keeps combining marks and ZWJ (#2266), multi-line paste duplication and ghost fixed by the cursor clamp across wide spacers (#2272), combining marks paint so decomposed `é` matches precomposed (#2279), kitty font query and `bitty +show-font` (#2277), bounded native clipboard acquisition path B (#2273), bounded `bitty.fs.list` (#2271), the `bitty.history` Lua surface (#2268), the production ComponentBroker plus activation state (#2267, #2276), Enter-confirm paste (#2269), the `fill` DPI fix (#2283), landlock `no_new_privs` (#2284), and spawn descriptor reservation (#2289). Partials are marked honestly: #2254's request surface is still pending, the #2213 disposition stays open, #2286 is feature-gated and unwired, the macOS clipboard read stays a typed refusal, and the RC-1 fuel accounting fix is not claimed because PR #2292 is unmerged. The heading reads `unreleased` because the release is on hold; the tag date is set at tag time. Docs-only: no code, scripts, workflows, or pins touched.
Priority: P1 | Area: runtime | Labels: fix,P1,area:runtime,area:security | Milestone: 0.0.24 | RFC: OQ-012 | Task: CTX-1376
Closes #2282
Problem
Every admitted Layer-2 tool spawn on Linux was refused on an unprivileged
host, which the 0.0.24 runtime matrix caught through
git-panel:Root cause
crates/bitty-sandbox/src/linux.rsapplied the LandlockEXECUTEruleset inthe child
pre_exechook by callinglandlock_restrict_selfwithout firstsetting
PR_SET_NO_NEW_PRIVS. Landlock requires that prerequisite forunprivileged callers (or
CAP_SYS_ADMIN), so the syscall answeredEPERMandCommand::spawnfailed;plugin_runtime/spawn.rsreported the fail-closedconfinement refusal.
Evidence:
EPERMfromlandlock_restrict_self, and0afterprctl(PR_SET_NO_NEW_PRIVS, 1);unshare -rm(CAP_SYS_ADMIN in a user namespace) made the pre-fix testspass without the prerequisite, proving it was the only blocker;
cargo test -p bitty-sandboxprintedSKIP: host forbids unprivileged landlock_restrict_self (Operation not permitted)for all threeconfinement tests — the skip is what hid the defect.
Fix
no_new_privsin the same childpre_execpath, immediately beforerestrict_self, and keep the failure mode fail-closed with the existingtyped diagnostic.
no_new_privsis not optional hardening here: it is whatkeeps the confined exec tree from regaining privilege through a
setuid/setgid binary, so it belongs with the ruleset.
EPERMskip from the confinement tests (a spawn error is now aregression, never host policy) and add
confined_child_sets_no_new_privs,which reads
/proc/self/statusfrom inside the confined child.admitted_git_spawn_runs_under_inherited_confinementnow requires a completed confined
git statusin a temp repository insteadof accepting a fail-closed refusal.
Security model unchanged: no allow-all, no ambient PATH, no confinement
bypass. The
[tools.git]verb/arg gate, theprocess.spawn:gitinstall grant,and the exec allowlist still gate the spawn; this only restores the inherited
confinement that was already accepted.
Regression (grant/deny pair)
granted_production_backend_runs_confined_git— granted + realgit_spawn_backend: confinedgit statusruns,exit_code == 0,untrusted == true.spawn_without_grant_is_capability_denied— no grant:E_CAPABILITY_DENIED(existing).
production_backend_denies_unallowlisted_verbs_without_spawning+host_tools_authorizer_enforces_the_accepted_contract— undeclaredexecutable / non-allowlisted verb denied before any process (existing).
shell_escape_denied_at_os_level,non_allowlisted_initial_exec_denied—OS-level denial still enforced (now actually executed, not skipped).
Gates
cargo fmt --all -- --check— clean.just clippy(workspace all-targets +dev-tools,-D warnings) — clean.cargo nextest run -p bitty-sandbox -p bitty-runtime -p bitty-lua --locked— 2933 passed, 2 skipped.
cargo check --target x86_64-pc-windows-gnu --workspace --all-targets—clean.
just scratch-paths— OK.just ci-localnot run: the shared filesystem hit 100% during the build(host-level caches from concurrent tasks); the local gate set above plus
remote CI covers this change.
Post-merge: re-run the 0.0.24 matrix probe for
plugin-git-panelfrom pinnedorigin/main.