Repository navigation
Studio: per-account isolation for shared installs and the desktop app - #10588
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ 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. |
|
@codex review |
|
@codex security review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 54ac9b4294
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| "(allow sysctl-read)", | ||
| "(allow mach-lookup)", | ||
| "(allow ipc-posix-shm)", | ||
| "(allow network*)", |
There was a problem hiding this comment.
Isolate managed tool processes from private networks
For a managed account on macOS this explicitly permits every network operation, while the Linux Landlock rules likewise leave handled_access_net at zero. The command checks are not a security boundary: an account can write a Python/C helper as a file and execute it after approving the tool call, allowing a remote Studio user to connect from the host to loopback, link-local metadata endpoints, or otherwise inaccessible LAN services. Managed tool processes need OS-level private-network isolation or a mediated public-only transport, as is already done for managed MCP connections.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not a defect this PR introduces. Tool processes have run in the host network namespace since before this change (tools.py records why CLONE_NEWNET is not applied), and the confinement added here is a filesystem boundary by contract. Landlock rules are per TCP port and sandbox-exec has no address ranges, so neither can express deny-private-allow-public; a filtering proxy plus a network namespace is a separate feature that applies equally to the owner sandbox on main.
…on account retirement for PR #10588
|
@codex review |
1 similar comment
|
@codex review |
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3ddbd69579
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| "/snap", | ||
| "/nix", | ||
| "/var/lib", | ||
| "/proc", |
There was a problem hiding this comment.
Hide sibling process environments from managed tools
On Linux, granting the confined process read access to all of /proc exposes /proc/<pid>/environ for dumpable same-UID sibling processes. For example, model-download workers are launched with the initiating account's HF_TOKEN in their environment, so a managed tool running concurrently can enumerate processes and recover another account's token; hardening only the Studio parent does not protect these workers. Exclude sensitive procfs entries or otherwise isolate process visibility at the OS boundary.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Landlock already denies this. /proc//environ is gated by a ptrace access check, not by the /proc read grant, and a confined tool's domain is never a superset of an unconfined worker's, so the read fails with EACCES while cmdline still succeeds. Reproduced on this host: a sibling with HF_TOKEN in its environment, read from a confined managed tool, gives Permission denied. A preexec PR_SET_DUMPABLE is also wiped by the following execve, so the proposed fix would not work.
| target = getattr(importlib.import_module(job_module), job_target) | ||
| return target(**kwargs) |
There was a problem hiding this comment.
Confine managed job workers before loading remote code
When a managed account enables trust_remote_code for a model it controls, the training/export worker eventually executes that repository's Python in this child without any filesystem confinement. The selective environment cleanup does not change the process UID, working directory, or HOME, so that code can enumerate and read the owner's workspace, other accounts' roots, saved host credentials, and any unlisted secret environment variables. Run managed job children inside the same account filesystem boundary used for tools, rather than relying only on validated configuration paths.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
A managed account cannot enable remote code on any job path: the consent gate refuses it before the scan for every non-owner context, job children are bound to the account through run_account_child, and the only auto-enables require a Hub-verified unsloth or nvidia repo. Confining the training process itself is a separate feature, since it must read the shared cache, write outputs and load CUDA libraries.
…ile a managed record exists for PR #10588
…g a deleted workspace for PR #10588
…t retirement for PR #10588
| } | ||
| // Fence first: peers see it before the tokens, so nothing of the previous account goes out | ||
| // under the new credentials while their reload is pending. | ||
| if (changed) storage.setItem(BROWSER_ACCOUNT_FENCE_KEY, marker); |
| if (changed) storage.setItem(BROWSER_ACCOUNT_FENCE_KEY, marker); | ||
| commitSession(); | ||
| if (storage.getItem(BROWSER_ACCOUNT_KEY) !== marker) | ||
| storage.setItem(BROWSER_ACCOUNT_KEY, marker); |
… managed folder browser for PR #10588
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b3dd3af6d7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| if urlsplit(url).scheme != "https": | ||
| raise ValueError("Managed accounts may only use HTTPS provider endpoints.") | ||
| public_provider_address(url) |
There was a problem hiding this comment.
Pin recipe-provider connections to the validated public address
For a managed account using an attacker-controlled hostname, DNS can return a public address during public_provider_address() and a loopback or LAN address when the Data Designer client later resolves the endpoint. Requiring HTTPS does not enforce public routing: TLS authenticates the hostname, and a private endpoint can present a valid certificate for that same attacker-controlled name; even a failed handshake still initiates a connection to the private service. Route these requests through the pinned public transport used for normal providers/MCP, or otherwise bind the actual connection to the address validated here.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 434a4ee. The recipe job subprocess now installs a resolver guard for managed accounts: socket.getaddrinfo and gethostbyname refuse any answer that is not a global address, so a name that rebinds to loopback or the LAN after the endpoint check fails at resolve time and no connection is initiated. It is process-wide in the worker only, which is the process the engine dials from, and the HTTPS plus public-address check at recipe build time stays. Covered by test_managed_recipe_worker_refuses_names_that_resolve_privately.
| for path in _existing((_DEVICE_ROOT,)): | ||
| rules.append((path, device)) |
There was a problem hiding this comment.
Restrict device access to the nodes tools actually require
On a shared Linux host, managed tools run under the same Unix identity as Studio, so granting read, write, and ioctl access beneath all of /dev exposes same-UID resources outside the account workspace. For example, a tool can open another Studio/owner terminal through a guessed /dev/pts/<n> path, and it can access known same-UID objects under /dev/shm; root or privileged deployments additionally expose any mounted block and character devices. Grant only required pseudo-devices and explicitly selected accelerator nodes rather than the entire device tree (the macOS profile contains the analogous broad grant).
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 434a4ee. The Landlock rules no longer grant /dev; they grant the pseudo-devices (null, zero, full, random, urandom, tty) and the accelerator nodes that exist (nvidia*, nvidiactl, nvidia-uvm, nvidia-caps, dri, kfd). /dev is also treated as protected when the system roots are granted child by child, so the /run/shm link cannot reintroduce /dev/shm. The macOS profile now allows the same pseudo-devices by literal path instead of the /dev subpath. A runtime test confirms a managed tool reads /dev/urandom and writes /dev/null but cannot list /dev/shm.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. 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". |
# Conflicts: # studio/backend/routes/inference.py
Summary
Studio and the desktop app can be shared by several people on one machine. The installation owner (the existing
unslothlogin) creates accounts from Settings > Accounts. Each account signs in with a one-time setup code, sets a password, and then has its own chats, projects, settings, credentials, uploads, datasets, training runs, outputs, exports, galleries, RAG store, sandboxes and temporary files. Nothing an account does is visible to, or can affect, another account.A single-account install is unchanged: same paths, same database files, same password-only login, same desktop auto-login, same keyless loopback behaviour, and no extra I/O on the hot paths. Multi-account policy switches on only when a second account exists.
How isolation works
account_id; usernames are display names only, so re-creating a username never inherits data.ContextVar; storage roots, database paths and caches resolve through it at call time. Background work carries the account explicitly, and unbound work resolves to the owner.<studio home>/accounts/<account_id>/; the owner stays at the legacy root. The model cache, binaries, the auth database and the Hugging Face cache are shared, and a managed account sees a cached model only when it is provably public or it downloaded it.Login, reset, desktop, downgrade
/api/auth/statusreportslogin_modeand never lists accounts. With one account the form is unchanged; with more, a username field appears and the setup code is the first password.unsloth studio reset-passwordkeeps its behaviour for one account and requires--usernamewith several.full_accessstays off while any managed account record exists.Sandboxes and the shared GPU
sandbox-execon macOS): read-only workspace, no link creation, and the install root, other accounts' roots, the shared Hugging Face cache and the per-user temp tree are hidden. Where no mechanism exists, code execution is refused for managed accounts; the owner can opt out withUNSLOTH_STUDIO_ALLOW_UNCONFINED_TOOLS=1.gpu_busyandRetry-After; an idle swap happens as today. Cancel is scoped to the caller and rechecked under the engine lock. Another account's resident model reports{"loaded": true, "yours": false}(the chat status keeps its list shape:{"loaded": [], "loading": [], "yours": false}).--secure, one Cloudflare quick tunnel URL serves every account with Studio's own authentication; keyless access is never admitted on the tunnel and, once a second account exists, not on loopback either.Kept as design: the installation owner can see and unload a managed account's idle resident model and can browse its private model folder by absolute path, because the owner administers the machine.
Verification
tsc, strict locale parity for the Accounts strings, build and bundle budget.tests/multi_account/test_routing_invariance.py. On a B200 with Qwen3-0.6B Q4_K_M, three paired rounds of merge base versus this branch with accounts off: server decode 1768 vs 1774 tokens/s, TTFT 68.2 vs 68.8 ms, status/models/auth/threads p95 within 4 percent, load time no slower. The owner's numbers are unchanged with one idle managed account (created or logged in and polling) and with 100 accounts and 10 idle sessions; the run-to-run spread of the server-reported decode rate on this model is about 8 percent, and every scenario sits inside it.tests/studio/playwright_multi_account.py), matching the othertests/studio/playwright_*.pychecks, so the frontend lockfile gains no new dependency.Relation to #10102 and #10250
This is a from-scratch implementation on today's main; #10102 and #10250 were used as references for coverage and no code was taken from them. It differs in keying storage on an immutable account id rather than the username, initialising schemas per database path, binding requests through a
ContextVarwith an async form, arbitrating the GPU instead of evicting other users' streams, refusing full access server-side, confining tool processes at the OS level, and fencing managed credentials from older builds. The four review P1s on #10250 are addressed here by construction, so #10250 can be closed in favour of this PR.Screenshots
Each pair is the same scene captured twice: BEFORE is the merge base, AFTER is this branch, driven against two isolated installs.
Turning on multi-user accounts
Nothing changes until the installation owner asks for it. Sign in as the owner, open Settings, and pick the new Accounts tab. Type a username, press Create account, and that first managed account is what switches the install to multi-user. The tab, and everything on it, is owner-only: a managed account never sees it.
Studio shows the new account's setup code once. Copy it and hand it to the person it belongs to. It is their first password, it works once, and it expires in 60 minutes.
The settings search finds the tab by name, so the owner does not have to know where it lives.
The account holder's first sign-in
Once a second account exists, the login form grows a Username field and says where the setup code comes from. With a single account it stays the password-only form it has always been.
Signing in with a setup code lands on a forced password change instead of the chat, so a code that was sent over chat or email never becomes a lasting credential.
Administering an account
Regenerating a setup code is the password reset path. It replaces the password, signs the account out and revokes its API keys, and the dialog says so before it happens.
Deactivating keeps the account and its data but invalidates its tokens and API keys, and the row offers Reactivate. Deleting is the destructive one: it cancels the account's jobs, closes its MCP sessions and renames its roots aside.
What a managed account cannot do
Full tool access is refused server-side whenever more than one account exists, so the chat permission menu drops the Full access option for a managed account rather than offering something the backend will reject.