unsloth/studio/backend
danielhanchen d8f8566a3b Harden sandbox: git operand expansion, single-assign env PATH, env -C argv, git exec configs, workdir import vetter, env -S reads, make
Close eight follow-up bypasses Codex found on the round-36 git / env work:

- git operand via expansion: a git path operand from a locally-assigned absolute
  variable (OUT=/tmp/repo; git init $OUT) was treated as sandbox-local. The git
  scan now resolves a $VAR / ${VAR} operand against the command's local bindings
  (new _git_operand_escapes); an unknown external expansion is left to the literal
  check so git clone $REPO_URL is not a false positive.
- single-assignment env PATH: a non-shell subprocess with an env bound by a single
  assignment (e = {'PATH': '.'}; run(['evil'], env=e)) skipped the unsafe-PATH
  check because env was a Name, not an inline dict. Resolve the single-assignment
  env node to its literal dict before the BASH_ENV / unsafe-PATH scan.
- env -C in argv: the argv-tail git rescan sliced off a preceding env -C /tmp, so
  run(['env','-C','/tmp','git','init','repo']) hid the escaping cwd. Reconstruct
  from the FULL argv so the git cwd backscan sees the wrapper.
- git exec configs: git -c KEY=CMD / git config KEY CMD run their value in an
  unguarded child for execution-capable keys (core.fsmonitor / sshCommand / pager /
  editor / credential.helper / filter.*.clean / diff.external / ...); core.hooksPath
  / init.templateDir re-point hooks (undoing the env hook suppression). Block those
  configs (alias.*=! was already handled); benign configs (user.name) stay allowed.
- workdir module import vetter: user code may import a sibling .py it wrote, but
  that source was never statically analyzed, so a planted workdir/evilmod.py could
  run os.system('cat /etc/passwd') at import time in the guarded interpreter. A
  meta-path finder now vets a module resolved FROM the workdir and refuses it if it
  reaches a command-execution sink or eval/exec/compile; library imports and benign
  sibling modules still load. (Direct sinks only; deeper obfuscation is a residual.)
- env -S / --split-string reads: env -S 'cat /etc/passwd' / --split-string= run
  the operand as a command, but the READ scanner treated it as inert. Recurse the
  split-string payload into the sensitive-read scan (shell-string and argv forms).
- make: make runs shell recipes read from a workdir Makefile in an unguarded child,
  the same escape as the pip / pytest launchers. Deny make / gmake.

Regression coverage: TestRound37Bypasses in tests/test_sandbox_tools.py and the
benign/malicious workdir-module import tests in tests/test_sandbox_runtime_backstop.py.
2026-07-10 12:31:23 +00:00
..
assets Add DeepSeek-V4-Flash-GGUF to Studio with none/high/max reasoning (#6908) 2026-07-07 06:13:43 -07:00
auth Studio: opt-in OpenAI /v1 model auto-switch and idle keep-warm (#6392) 2026-07-01 06:42:23 -07:00
core Harden sandbox: git operand expansion, single-assign env PATH, env -C argv, git exec configs, workdir import vetter, env -S reads, make 2026-07-10 12:31:23 +00:00
hub fix(studio/hub): apply repo_id length limit per segment, not whole string (#6946) (#6953) 2026-07-08 15:38:06 +03:00
loggers Studio: trim serving-log noise and surface llama-server engine stats (#6377) 2026-06-17 05:37:57 -07:00
models Studio /v1/messages: accept thinking and unknown content blocks (#7017) 2026-07-09 12:20:02 +02:00
plugins Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
requirements Studio: exclude mlx-lm 0.31.3 (broke gemma4/qwen3_5 QK-norm load on Apple Silicon) (#6803) 2026-07-06 19:40:06 -07:00
routes Studio /v1/messages: accept thinking and unknown content blocks (#7017) 2026-07-09 12:20:02 +02:00
state Studio: shareable per-checkpoint preview links (#6486) 2026-06-24 06:31:53 -07:00
storage Sort chat recents by last activity (#6844) 2026-07-07 17:54:32 +01:00
tests Harden sandbox: git operand expansion, single-assign env PATH, env -C argv, git exec configs, workdir import vetter, env -S reads, make 2026-07-10 12:31:23 +00:00
utils Studio: add Vulkan llama.cpp support (#5819) 2026-07-09 03:39:48 -07:00
__init__.py Final cleanup 2026-03-12 18:28:04 +00:00
_platform_compat.py Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
cloudflare_tunnel.py Reap Studio child processes when the parent dies abnormally (#6425) 2026-06-18 05:51:22 -07:00
colab.py Studio Colab: opt-in shareable Cloudflare tunnel link (#6684) 2026-06-26 00:56:23 -07:00
main.py Studio: multi-select export formats, portable FP8/INT8, GGUF LoRA, and source parity (#6767) 2026-07-03 08:25:10 -07:00
run.py Studio: fix torch CUDA undefined-symbol errors from a conflicting LD_LIBRARY_PATH (#6905) 2026-07-06 23:48:23 -07:00
startup_banner.py Fix Windows Studio UTF-8 startup handling (#6614) 2026-07-01 13:47:33 +01:00