Repository navigation
Studio: one-click OS sandbox setup, faster sandbox checks, isolated cmd fallback on Windows - #12272
Conversation
…d setup plan per host
…picker, and show setup in Settings > Sandbox Ask every time, Auto-approve, Full access in sandbox and Bypass permissions replace the old labels; the stored values are unchanged and the labels move to i18n in all 12 locales. Picking Full access in sandbox on a computer without a working OS sandbox opens a setup dialog (install, copy the command, or use it anyway) instead of switching. Settings > Sandbox shows the install command and a Linux install row, and can install the Windows MXC runtime.
…ly when no OS sandbox is on, and warm the sandbox check at startup One shared approval decision replaces the three loop copies. Under permission mode off the route arms the confirm gate only on a stream carrying the control frames, and the loop then asks only for a high-risk python or terminal call whose cached capability is not OS isolated. The cached answer never blocks on a probe; a startup warm-up and a stale-while-revalidate probe cache keep the first call and the 15 minute recheck off the request path. GET /api/sandbox/capability reports the cached answer to any signed-in user.
…and status reads, and use the new mode names in backend messages
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
Security findingsFinding details are still loading. Check the individual review comments. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
… asks for Windows consent only when needed, shows why a setup failed, and installs the Windows runtime without an administrator prompt
…, pin every elevated setup step, and check the sandbox before answering after setup
… a running setup on the prepare route, give PowerShell a command it can run, and translate the dictation menu label
|
@codex security review |
… Unsloth cannot ask for the password
…ep Windows setup commands with host paths to the owner
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…n there is no OS sandbox
Brings in the Settings > Sandbox runtime install. The tab keeps this branch's single setup job tracker; the runtime row reads its windows-runtime runs. The runtime-only install now also works from a remote owner browser (it has no administrator prompt), the chained setup stays local-only, and Windows that cannot run MXC (not x64, or older than build 26100) is offered no setup at all.
…ed engines - Durable chat runs persisted confirm_tool_calls=False for Run automatically, which the replay read as an explicit opt-out, so the ask-before-risky-calls check never armed in normal Studio chats. Drop the forced value when saving. - The vLLM/SGLang tool loop now arms the same check as the other loops. - The picker hook and the setup dialog apply only their newest capability read, so a slow older answer cannot undo a newer one. - Saving a sandbox setting or finishing Prepare this PC drops the cached capability the chat picker reads. - pkexec setup on Alpine runs BusyBox as its sh applet.
… work The pick waited for a forced live probe even when the cached answer said the OS sandbox works, so on a slow host the menu looked unresponsive for seconds. The backend checks isolation on every call either way.
While the Windows section shows what to do (install the runtime, turn the sandbox on, prepare this PC), the Python and Terminal rows keep only their badge, and on Windows they never repeat the generic MXC remediation text. The setup reason says the PC needs its administrator step instead of naming MXC's internal step ids.
…udio-sandbox-v2 # Conflicts: # studio/backend/core/inference/sandbox_setup_plan.py # studio/backend/routes/settings.py
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Stacked on #12215 (Settings > Sandbox). Merge that first; this then retargets to
main.Python and Terminal already use bubblewrap (Linux), Seatbelt (macOS) or MXC (Windows) automatically when the live check passes. What was missing:
This PR fixes all four. The permission level names and stored values stay as they are on
main(Ask for approval, Approve for me, Run automatically, Full access;ask,auto,off,full).Setting up the sandbox
Picking Run automatically on a computer whose OS sandbox does not work opens a dialog with the reason. It offers these actions, in order:
Picking the level never starts anything by itself; only the button does, and picking it again later reopens the dialog. The menu row shows "OS sandbox not available" while that is the case.
Settings > Sandbox shows the same setup as one "OS sandbox" row: a one-line reason, the command, and the button where one is allowed. The Python and Terminal rows then show only their badge, so the long probe text is no longer repeated three times.
Settings > Sandbox on Windows shows the same idea in its own section: the runtime row, then the switch, then Prepare this PC. While that section says what to do, the Python and Terminal rows keep only their badge.
Real staging runners, Studio installed from this branch, real clicks and the real setup button (no stubbed routes). Each strip reads left to right:
Ubuntu 24.04 (bubblewrap missing): tab, dialog from picking Run automatically, after Install sandbox, tab after.
Ubuntu 22.04 (bubblewrap removed first): tab, dialog, tab after.
macOS 15 (Seatbelt works): tab, menu, Run automatically applied with no dialog.
Windows Server 2025 (MXC runtime removed first): Install runtime row, after the runtime install, dialog with consent, tab after (Python on MXC, Terminal on isolated cmd, administrator setup done).
bubblewrapwith the host's package manager (apt, dnf, pacman, zypper, apk). On Ubuntu 24.04 style hosts where AppArmor blocks unprivileged user namespaces, it also loads Ubuntu's ownbwrap-userns-restrictprofile. These are the same packages and profileinstall.shalready names, plusapt-get updateand non-interactive flags. Elevation:sudo -nwhen sudo needs no password, else onepkexecprompt on the desktop, else the command to run in a terminal. It never changes the sysctl, never makes bwrap setuid, and never runs Unsloth as root.Who can start a setup:
The endpoint takes a fixed operation name, never a command. Everyone else gets the command to copy, and the dialog says why there is no button: another account, another computer, or no way to ask for the password here.
Run automatically without an OS sandbox
In a streaming UI chat, the only place a prompt can be answered, Run automatically now asks before a risky Python or Terminal call when that tool has no working OS sandbox. Risky means the same high-risk check Approve for me uses. Everything else is unchanged:
This holds for saved chats too (the resumable runs Studio uses for normal chats) and for every local engine: llama.cpp, safetensors and vLLM/SGLang.
When the prompt is skipped because the cached answer says the tool is isolated, that call launches in strict mode. A sandbox that stopped working since then refuses the call with the setup command, instead of running it under software safeguards.
Speed
Picking Run automatically. When the sandbox is already known to work, the pick applies at once instead of waiting on a fresh check.
Startup check. The sandbox check runs in the background when the server starts (Linux and macOS), so the first Python or Terminal call does not wait for it. Windows keeps it lazy: with the MXC opt-in on, a startup check would start a container and apply the read grants at every launch.
Stale passes. A passing probe older than its 15 minute lifetime keeps being used for up to an hour while one background re-check runs, instead of making a tool call wait. A failing probe is cached for 60 s and never served stale, and a launch failure clears the cache at once.
Gate and dialog caches. The Run automatically gate reads a per-tool answer that is refreshed in the background every 60 s, and never waits on a probe. The browser caches the capability read for 30 s, and drops it when a setup finishes.
Windows Terminal
When Git Bash fails the MXC check for any reason and cmd.exe passes, the Terminal now runs isolated on cmd. Before, only the Git Bash namespace error switched it, and on a freshly prepared host Git Bash fails without that signature, so the Terminal stayed unisolated on bash. Full access and
UNSLOTH_MXC_TERMINAL_CMD=0still keep the host shell.Other changes
/usr/sbin,/usr/bin,/sbinor/bin, with a fixed environment (no inheritedPATH,LD_*orPYTHON*), so nothing a tool call writes into Studio'sPATHcan run as root.& '...'line per step), which Windows PowerShell 5.1 can run.Results
Through the UI on the latest head (the screenshots above): on ubuntu-24.04, ubuntu-22.04 and Windows Server 2025 the setup button ended with "The OS sandbox is ready. Run automatically is on." and the capability read then reported Python and Terminal OS-isolated (bubblewrap, bubblewrap, MXC). macOS needed no setup.
Staging runners, the real routes, setup job, probes and tools, owner session; passwordless sudo on Linux runners, the already elevated branch on Windows:
apt-get update, bubblewrap,apparmor-profiles, profile loaded: succeeded in 108 sgit --versionruns isolatedOn every leg a remote client got 403 for the setup and only the command from the capability read, and a second setup after success answered 409.
A second Windows Server 2025 check went through the same setup job end to end, four times on fresh runners. Each time:
_io.FileIOandnt.open, below the Python shim, were refused by MXC withPermissionError. The host files were unchanged.test_mxc_native_windows.pyon that runner: 13 passed, 1 skipped (no second writable volume). Two Terminal probe tests fail the same way on the merge base, so they are not from this PR:Set-Contentinside MXC; PowerShell 7 and cmd pass.0xC0000142with no output, so it gets the generic reason instead of the named one.Latency, median ms over 3 interleaved rounds, same runner (Full access = no OS sandbox):
Local, after merging the latest
main:i18n:check:strictand the node tests (65) pass.Not covered
Twice, at the end of a full UI run on macos-15, a forced Seatbelt re-check timed out after 30 s while the tab still showed Seatbelt. Two targeted runs did not reproduce it on either branch: 47 forced reads (idle, with a browser, three at once, and every 20 s for 6 minutes on the capability route) all passed in under 0.8 s. I read it as runner load, not this PR.
A real polkit dialog on a Linux desktop and a real UAC prompt (runners have passwordless sudo and run elevated).
Package paths other than apt on real hosts (dnf, pacman, zypper and apk are unit tested only), WSL, Windows on ARM64 (offered no runtime install, only a note) and MXC's BaseContainer tier.
The state after a real Windows reboot (the null device step has to be prepared again; the dialog offers it).
Screenshots
BEFORE is #12215 (
8ce5b91, the parent this stacks on), AFTER is this branch (428a6ae); two isolated installs on a Linux host whose user namespaces are restricted.Settings > Sandbox: the per-tool probe text gives way to one OS sandbox row with a short reason and the command.
The permission menu now says when the sandbox is not available:
Picking Run automatically: before, it switched straight to it; after, the setup dialog opens with the reason, the command (this host cannot ask for a password, so no Install button) and Use it anyway, and the mode stays as it was.
Recording of that pick on this branch:
The real setup on staging runners, one step per frame (the same runs as the strips above): Ubuntu 24.04 with Install sandbox, and Windows Server 2025 from a missing runtime to both tools on MXC.