unsloth/studio
danielhanchen 736e8a6477 Harden sandbox: extend workdir-module import vetter (ctypes, dynamic import, closure/frame gadgets, indirect import-machinery, subscripted builtins); block openssl file output
Close six bypasses Codex found on the round-45 branch. Five harden the workdir-module
import vetter (the only scan of a helper .py the user wrote before import); the sixth
adds an openssl output-file scan.

- ctypes / native modules: the vetter only treated subprocess / pty as execution
  modules, so a helper doing import ctypes reached UNGUARDED native libc
  (ctypes.CDLL(None).open/write) bypassing the patched Python open / os.open. Refuse
  ctypes / _ctypes / cffi and the source-executing runpy / code / codeop.

- dynamic import: a helper bypassed the literal import subprocess check with
  importlib.import_module('subprocess'). Refuse import_module / reload whose target
  is a denied module (constant or module name); a dynamic import_module target fails
  closed.

- closure / frame gadgets: __closure__ / cell_contents / f_locals / __globals__ /
  __subclasses__ (etc.) recover a runtime guard wrapper's original unguarded callable
  or walk to os / builtins. Refuse the top-level _GADGET_DUNDERS set inside a workdir
  helper too.

- indirect import-machinery access: the vetter caught only the literal
  sys.meta_path attribute, so vars(sys)['meta_path'][:] = [...] (or
  getattr(sys, 'meta_path')) removed the vetter and imported an unscanned sibling.
  Refuse getattr / vars namespace-dict access on sys / os / builtins / importlib /
  deserializer modules (constant sink name, or a non-constant name that cannot be
  proven benign).

- subscripted builtins: imported helpers run with __builtins__ as a dict, so
  __builtins__['ev'+'al'](...) reached eval past the attribute checks. Refuse a
  subscript into __builtins__ / a builtins alias whose (statically foldable) key is
  an execution builtin, and fail closed on a non-constant key.

- openssl output files: openssl rand -out /tmp/p 4 (and -writerand / -keyout /
  -CAout / ...) writes a host file in an unguarded child. Block an openssl output-file
  flag whose value escapes the workdir; a workdir-local -out and the no-output forms
  (openssl rand -hex, openssl dgst) stay allowed. openssl joins the argv tail-scan set
  so the subprocess.run(['openssl', ...]) form is covered too.

Regression coverage: TestRound46Bypasses in tests/test_sandbox_tools.py (openssl
escaping output blocked in the shell-string and argv forms; -hex / dgst / workdir-local
-out allowed) and six workdir-module vetter cases in
tests/test_sandbox_runtime_backstop.py (ctypes, dynamic import, __closure__, indirect
vars(sys) meta_path, subscripted __builtins__['eval'] denied; importlib.import_module of
json still allowed).
2026-07-10 18:20:30 +00:00
..
backend Harden sandbox: extend workdir-module import vetter (ctypes, dynamic import, closure/frame gadgets, indirect import-machinery, subscripted builtins); block openssl file output 2026-07-10 18:20: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