feat(runtime): add Linux filesystem worker and one-shot permissions - #1399
Conversation
Astro-Han
left a comment
There was a problem hiding this comment.
I found one blocking issue and will leave it inline.
- [P2]
packages/runtime/src/builtin-tools.ts:988creates every missing exact-write target before the command starts, butpreparedTargetsis dropped whensandboxCommandreturns. Cleanup runs only when sandbox transformation fails. A spawn failure, abort, nonzero exit, or command that never writes the target leaves an empty file behind. A failed one-shot request should not mutate the filesystem. - [P2]
apps/desktop/src/main/tool-assembly.ts:219and:290remove theEditfilter even whenfilesystemWorkeris undefined. On Windows,createBuiltinSandboxManager()returns undefined, so Desktop now exposes the generic-executorEdittool despite this PR stating that Windows behavior is unchanged. The new source-regex test enforces filter removal but never checks the platform-specific tool surface. KeepEditconditional on a worker, or cover and document the Windows behavior explicitly.
The inline exact-write race can redirect an approved write, so this revision needs changes before merge.
|
Overall, I think the layering here is clear and the Linux parity direction is sound: capability detection → CLI/Desktop wiring → one-shot permission planning → sandbox transformation → worker launch/resource mounts → operation-level revalidation. The synthetic cwd handling and seccomp-FD propagation are especially good additions. I found two concrete product-level issues worth addressing:
There is also a theoretical pathname TOCTOU/symlink concern around missing exact writes. Under Maka's current single-user, trusted-host-process threat model, I would treat that as defense-in-depth rather than a merge blocker; an FD-pinned/atomic-open design would still be a useful future hardening step. So overall: the architecture and decomposition look good; the main remaining work is tightening the lifecycle and platform-surface behavior rather than changing the overall approach. |
…em-worker # Conflicts: # apps/desktop/src/main/tool-assembly.ts # packages/runtime/src/__tests__/builtin-tools.test.ts
Astro-Han
left a comment
There was a problem hiding this comment.
Reviewed at 29605d5d. The three earlier issues are fixed: the Bash missing-target handoff is inode-pinned, placeholder ownership now lasts through terminal completion, and Desktop keeps Edit behind the filesystem worker on both parent and child surfaces. CI is green, including the mandatory Linux sandbox smoke.
I left two P2 follow-ups inline. Neither is a blocker under the current merge policy and threat model. Please push back if either assumption is wrong; these should be evaluated, not accepted mechanically.
No P0/P1. Approving.
Summary
PermissionProfilerequire_escalatedexecutionWhy
The Linux sandbox previously enforced command isolation, cwd canonicalization, realpath checks, and symlink containment, but the full filesystem-worker path and one-shot permission flow were gated to macOS. As a result, Linux hosts could not use the same operation-scoped file isolation or explicit one-call permission UX.
The worker also dropped Linux sandbox FD inputs, and bubblewrap did not receive all runtime resources needed to launch the worker and its trusted Grep helper.
Security model
For a missing exact write, bubblewrap exposes the containing directory only to the trusted single-operation worker. The worker request remains exact-path scoped, permission-hash bound, target-type checked, and symlink/realpath revalidated before the operation. The Linux smoke test verifies that the approved target succeeds while a sibling remains denied.
An otherwise-unmounted cwd is materialized as an empty directory rather than mounting its contents. Network-restricted workers retain a separate network namespace and deny
socket(); localsocketpair()remains available so Node can launch the trusted ripgrep child process.Explicit unsandboxed execution remains opt-in, approval-bound, and tied to the exact command and cwd through the existing escalation grant validation.
User impact
Linux now has the same product wiring as macOS for sandboxed file tools and one-shot permission requests. Windows behavior remains unchanged and still rejects these platform-specific options.
Validation
npm run lintnpm run clean && npm run build:testnpm run typecheckKnown baseline
The repository-wide
npm testcommand on this Windows checkout has three pre-existing script-test failures unrelated to this change: a duplicatedC:\C:\...path in the provider-matrix test, a CUA provenance hash mismatch, and the headless fixture's fixed byte-count expectation. The clean build, full typecheck, focused regressions, and required Linux smoke suites above are green.