fix(sandbox): drop ~/.config and ~/.local from auto write-set - #305
Conversation
auto mode bound ~/.config and ~/.local writable inside the sandbox. Both sit on the user's shell $PATH / rc-load path (~/.local/bin, ~/.config/fish, ~/.config/npm, ...), so a sandboxed command could plant an executable or rc backdoor that runs UNSANDBOXED later — a persistence/escape vector widening the per-command blast radius. Drops both from the bwrap AUTO_HOME_DIRS array and the sandbox-exec auto profile. Package caches (~/.npm, ~/.cargo, ~/.cache, ...) which are not on $PATH are kept. Closes #299
Review — LGTM, good catchThis is a genuinely subtle one and the reasoning in the comment is exactly right: the distinction that matters is not "dot-dir in home" but "on a path that gets executed or sourced later". The macOS tests assert the actual denial rather than just the config change, which is the right level. Two follow-on thoughts, not blocking:
Please also mirror the rationale into |
#299) Review asked for the 'why' to live in the design doc a future contributor reads, not just the code comment. Adds an amendment to a7-sandbox-loosen-auto.md explaining the on-$PATH / rc-load distinction that drove dropping ~/.config and ~/.local, the residual ~/.cargo/bin acceptance, and the lack of a $HOME/.config auto-mode escape hatch. References #299
|
Addressed in 5ca581c — added an amendment to docs/design/a7-sandbox-loosen-auto.md capturing the on-$PATH / rc-load rationale and the residual ~/.cargo/bin acceptance, so the 'why' lives in the design doc a future contributor reads. The ~/.config escape-hatch knob is noted there as the better future answer than --sandbox off. |
Summary
automode bound~/.configand~/.localwritable inside the sandbox. Both sit on the user's shell$PATH/ rc-load path (~/.local/bin,~/.config/fish,~/.config/npm, …), so a sandboxed command could plant an executable or rc backdoor that runs unsandboxed later — a persistence/escape vector that widens the per-command blast radius.This drops both from:
bwrapAUTO_HOME_DIRSarray, andsandbox-execauto profile.Package caches (
~/.npm,~/.cargo,~/.cache, …) — which are not on$PATH— are kept.autois documented as "not a security boundary"; this narrows the obvious persistence surface. Real isolation remains--sandbox strict.Test plan
npm run typecheck && npm run lint && npm run format:check && npm test— all pass (844 tests)~/.configand~/.localare now blocked in auto mode (permission denied); existing~/.npm/~/.cache/~/Library/Cachesallow tests still pass.Tradeoff (for reviewers)
Some tools write first-run config to
~/.config(e.g.gh auth). Underautothose may now fail until run once outside the sandbox. Acceptable for the security gain; users can opt out with--sandbox off. Alternative considered: narrow~/.localto~/.local/share— happy to switch if reviewers prefer the less aggressive option.Closes #299