unsloth/studio
danielhanchen 8814d7de3b Harden sandbox: fail closed on unvetted __code__ stores; workdir getattr sink obfuscation; honor subprocess cwd= and GNU env glued -C/-u for git writes
Close four bypasses Codex found on the round-44 branch:

- fn.__code__ = <code object>: rebinding a function's code runs it via fn()
  WITHOUT eval / exec, the __code__ twin of the FunctionType gadget. The
  assignment visitor only checked container-stored exec aliases, so
  co = codeop.compile_command('...'); f.__code__ = co; f() ran unanalyzed
  source. Flag a __code__ store whose RHS is not a vetted code object; an
  in-source function's code (g.__code__) and a compile() result (analyzed at
  the compile site) stay allowed.

- workdir-module getattr obfuscation: the import vetter caught direct
  os.system(...) but not getattr(os, 'system')('...') in an imported helper,
  so the top-level analyzer saw only the file write / import and the vetter
  passed. Refuse getattr on a sink-module receiver (os / posix / builtins /
  deserializers) -- a constant sink attribute name, and a non-constant name
  that cannot be proven benign.

- subprocess cwd= ignored for child writes: the argv scan reconstructed the
  git command but dropped cwd=, so subprocess.run(['git','init','repo'],
  cwd='/tmp') created /tmp/repo outside the workdir. Model a literal escaping
  cwd= as a synthetic `env -C <cwd>` wrapper on the reconstructed command so
  the existing git cwd backscan resolves the escape; a workdir-relative cwd
  adds no wrapper and stays allowed.

- GNU env glued -C / -u operands: env -C/tmp git init repo (and
  env -uGIT_CONFIG_COUNT git ...) glue the chdir / unset operand directly onto
  the short flag, which the separated and --long= scans missed, so the git cwd
  and hook-suppression backscan never saw the escape. Parse the glued short
  forms alongside the separated ones.

Regression coverage: TestRound45Bypasses in tests/test_sandbox_tools.py
(__code__ store of a producer / opaque code object blocked while a compile()
result and g.__code__ stay allowed; subprocess git under an escaping cwd
blocked while a workdir-relative cwd is allowed; env -C/tmp and
-uGIT_CONFIG_COUNT before git blocked while plain env git init is allowed) and
two workdir-module vetter cases in tests/test_sandbox_runtime_backstop.py
(getattr(os,'system') helper denied, benign getattr on a plain object allowed).
2026-07-10 17:51:12 +00:00
..
backend Harden sandbox: fail closed on unvetted __code__ stores; workdir getattr sink obfuscation; honor subprocess cwd= and GNU env glued -C/-u for git writes 2026-07-10 17:51:12 +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