fix(sandbox): hide Windows sandbox consoles and fail lock waits fast#6097
Merged
SivanCola merged 1 commit intoJul 6, 2026
Merged
Conversation
- Launch sandboxed user commands and internal icacls/taskkill with CREATE_NO_WINDOW + STARTF_USESHOWWINDOW/SW_HIDE so no black console flashes over the desktop (npm run dev / icacls windows in the report). - Record each root lock's holder (pid + command preview) in a sidecar file; the queue notice and timeout error now name the blocking command so users know what to stop instead of only being told to raise WINDOWS_SANDBOX_LOCK_MS. - Drop the interactive lock wait default to 1 minute so a queued foreground command fails fast into the existing escape-approval path; background bash jobs keep the patient 10-minute wait via Spec.LockWait (WINDOWS_SANDBOX_LOCK_MS still overrides both).
This was referenced Jul 7, 2026
Closed
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.
Problem
Users on the new native Windows sandbox path (1.17.x) reported two issues (with screenshots):
npm run dev, one titledC:\Windows\System32\icacls....windows sandbox: waiting for another sandboxed command on this workspace to finish (lock wait limit 10m0s; set WINDOWS_SANDBOX_LOCK_MS to adjust)— a long-running dev server holds the per-root lock for its whole lifetime, so every later sandboxed command silently queues for 10 minutes and then fails with a message that suggests the wrong fix (raising the cap only makes later commands wait longer).Changes
Hide sandbox child consoles. The Win32
CreateProcess*launch paths (restricted token + AppContainer) and the internalicacls.exe/taskkill.exeinvocations now start withCREATE_NO_WINDOW+STARTF_USESHOWWINDOW/SW_HIDE, matching whatproc.HideWindowalready does for ordinaryexec.Cmd. Startup-info and creation-flag construction is factored into shared helpers so the two launch paths cannot drift.Name the lock holder. Each acquired root lock records its holder (pid, start time, command preview) in a best-effort sidecar file keyed by the same root digest as the mutex. The 2-second queue notice and the timeout error now say e.g.
held by "npm run dev", pid 1234, running 25m; stop that command or set WINDOWS_SANDBOX_LOCK_MS to adjust. Records are validated against a live PID on read, so crash leftovers are ignored (the OS already releases the abandoned mutex).Fail fast in the foreground. The interactive lock-wait default drops from 10 minutes to 1 minute — a blocked foreground command now surfaces the holder-named error quickly and flows into the existing sandbox escape-approval path instead of hanging the turn. Background bash jobs (which nobody is blocked on) keep the patient 10-minute wait via a new
Spec.LockWaitbudget threaded through the helper payload.WINDOWS_SANDBOX_LOCK_MSstill overrides both. The security model is unchanged: no automatic escape, whole-run serialization stays.Docs (EN/zh-CN guides, winsandbox README) updated to match.
Tests
bashtool test asserting foreground uses the short default andrun_in_backgroundopts into the 10-minute budget.Verification
go test ./internal/winsandbox ./internal/sandbox ./internal/tool/builtin ./internal/proc✅GOOS=windows GOARCH=amd64 go test -cfor winsandbox / sandbox / builtin ✅go build ./...,cd desktop && go test .,git diff --check✅Cache-impact: none - WindowsLockWait only changes internal Windows bash execution timing; tool schema/order and provider-visible prompt bytes are unchanged.
Cache-guard: go test ./internal/tool/builtin -run TestBashSandboxLockWaitForegroundVsBackground