unsloth/studio
danielhanchen 6f54040042 Harden sandbox: env -C command-subs / nested-shell / argv cwd, env --unset git hooks, workdir meta_path, git apply --unsafe-paths, patch; scope literal-path reads to readers
Close eight findings Codex raised on the round-40 branch (7 P1 + 1 P2 FP):

- env -C command-substitution operand: env -C $(printf /etc) cat passwd (and the
  backtick form) tokenizes the operand into separator tokens, so the per-command
  chdir-dynamic state was reset before the trailing reader. Keep the env -C dynamic
  flag across command-substitution punctuation ( ( ) ` ), and mark it when the operand
  itself starts with a substitution token.
- dynamic env -C into a nested shell: env -C ${X:-/etc} bash -c 'cat passwd' marked the
  cwd dynamic but the nested-shell recursion passed only the original cwd_dynamic,
  dropping it. Propagate the current env -C cwd and its dynamic flag into the payload
  scan.
- argv env -C before a bash -c payload: subprocess.run(['env','-C','/etc','bash','-c',
  'cat passwd']) scanned the payload before applying the argv env -C, treating passwd as
  workdir-local. Fold the argv env -C (via _argv_env_chdir) into the payload's cwd, or
  fail closed on a dynamic DIR.
- env --unset (separated) / bare - drop git hook suppression: the git backscan handled
  -i / --ignore-environment / -u NAME / --unset=NAME but not --unset NAME (separated)
  or a bare - (GNU env: implies -i). Add both so the injected GIT_CONFIG_COUNT hook
  suppression cannot be stripped before a git child.
- workdir module import-vetter mutation: a workdir module of just
  `import sys; sys.meta_path.pop(0)` passed the vetter (pop is not an exec attr), then a
  second workdir module imported unscanned with the vetter removed. Refuse a workdir
  module that touches the import machinery (sys.meta_path / path_hooks /
  path_importer_cache).
- git apply --unsafe-paths: a patch applied with --unsafe-paths can write targets
  outside the working tree (a +++ ../../tmp/x hunk) in the unguarded git child. Deny the
  unsafe mode; a plain git apply p.patch (in-tree targets) stays allowed.
- patch child writer: patch is an unguarded native writer (patch -o /tmp/x, or a ../../
  target in the diff), so add it to the child-writer denylist alongside touch / cp / tar.
- P2 FP -- literal sensitive-path scan over-blocked non-readers: the unconditional token
  scan flagged any command that merely mentioned a sensitive path (echo /etc/passwd,
  printf %s /etc/passwd). Make the scan command-word aware and exempt an explicit
  non-reader allowlist (echo / printf / : / true / false / test / [); every other command
  word -- readers AND unknown commands -- still fails closed.

Regression coverage: TestRound41Bypasses in tests/test_sandbox_tools.py (the seven
static items plus an unknown-command-still-blocks control and a benign-allowed set incl.
echo/printf/test with a sensitive path) and a workdir-module meta_path mutation test in
tests/test_sandbox_runtime_backstop.py.
2026-07-10 15:28:30 +00:00
..
backend Harden sandbox: env -C command-subs / nested-shell / argv cwd, env --unset git hooks, workdir meta_path, git apply --unsafe-paths, patch; scope literal-path reads to readers 2026-07-10 15:28:30 +00:00
frontend Stabilize floating monitor drag (#6984) 2026-07-09 00:16:05 -07:00
src-tauri Speed up Studio startup path (#6899) 2026-07-07 18:08:07 -07:00
__init__.py Final cleanup 2026-03-12 18:28:04 +00:00
install_llama_prebuilt.py Studio: add Vulkan llama.cpp support (#5819) 2026-07-09 03:39:48 -07:00
install_node_prebuilt.py Pin isolated Node.js installer to committed sha256 digests (#6625) 2026-06-24 05:47:58 -07:00
install_python_stack.py Studio: fix flash-attn and torchao install on Blackwell (sm_100+) GPUs (Closes #6961) (#6970) 2026-07-08 06:38:10 -07:00
LICENSE.AGPL-3.0 Add AGPL-3.0 license to studio folder 2026-03-09 19:36:25 +00:00
node_prebuilt_pins.json Pin isolated Node.js installer to committed sha256 digests (#6625) 2026-06-24 05:47:58 -07:00
package-lock.json ci: advisory lockfile supply-chain audit (no install-script changes) (#5604) 2026-05-19 05:56:56 -07:00
package.json ci: advisory lockfile supply-chain audit (no install-script changes) (#5604) 2026-05-19 05:56:56 -07:00
setup.bat Final cleanup 2026-03-12 18:28:04 +00:00
setup.ps1 Fix Windows installer torch index override (#6972) 2026-07-09 03:46:47 -07:00
setup.sh Studio: source CPU llama.cpp prebuilts from unslothai/llama.cpp (#6311) 2026-07-08 05:34:59 -07:00
Unsloth_Studio_Colab.ipynb Studio Colab: opt-in shareable Cloudflare tunnel link (#6684) 2026-06-26 00:56:23 -07:00