unsloth/studio
danielhanchen 8c317ddb44 Studio sandbox: close static-classifier and runtime-guard review gaps
Harden the code-exec sandbox against bypasses raised in review, keeping the
static gate a pure classifier (it never executes the tool call):

- Shell scan: `timeout` duration/float args (5m, 0.5, 2h) no longer drop the
  following command out of command position, and `find -exec CMD ... ;` rescans
  the whole slice so a wrapped `env`/`timeout`/`sh -c` target is still caught.
- exec/eval/compile of a bytes payload that is not valid UTF-8 Python now blocks:
  those sinks honor PEP 263 coding cookies (e.g. utf-7) that the static UTF-8 view
  cannot see; plain ASCII bytes payloads stay allowed.
- Resolve aliased/indirect reaches to exec, dynamic import, sensitive modules and
  deserialization sinks: builtins.eval / __builtins__.exec, from builtins import
  exec as e, importlib aliases, sys.modules[...] (and the getattr form), os.__dict__,
  posix/nt, and pickle/marshal module-and-symbol aliases plus the *.load variants.
- Shell-sink aliasing walks the whole tree, so a function-local `s = os.system`
  alias is resolved (the stored-once guard keeps it low false-positive).
- Drop __mro__ / __code__ from the introspection-gadget dunders: on their own they
  do not reach an execution primitive and are read by ordinary ML/debug code.
- Refuse folding oversized `bytes(n)` / `bytearray(n)` so static analysis cannot OOM.

Runtime realpath backstop:
- Fail closed on a mutating dir_fd / src_dir_fd / dst_dir_fd (an fd-relative path
  cannot be confined by a string realpath) for os and shutil mutators.
- Confine Path.rename/replace/symlink_to/hardlink_to when the destination is passed
  as the `target=` keyword, not only positionally.
- Splice the guard after a leading docstring and `from __future__` imports instead
  of prepending it, so future-import programs no longer raise SyntaxError while the
  sandbox is still established before the first real statement.

Adds regression tests for each gap across the shell, const-fold, exec-recursion,
aliasing and runtime-backstop suites.
2026-07-09 14:39:12 +00:00
..
backend Studio sandbox: close static-classifier and runtime-guard review gaps 2026-07-09 14:39: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