unsloth/studio/backend
danielhanchen 997c7247f2 Harden sandbox: builtins-qualified exec sinks and dotted network imports in workdir modules; keyword-only compile payload; sponge child writer
Close four bypasses Codex found on the round-42 branch:

- builtins-qualified exec sinks in an imported workdir module: the import
  vetter only rejected the BARE eval/exec/compile/__import__ names, so a
  workdir helper doing `import builtins; builtins.eval("...")` ran arbitrary
  code at import unscanned. Recognize the execution builtins reached as an
  attribute of the builtins module (or an alias), for both the direct call
  and the assign-only reference (e = builtins.eval; e(...)). Requiring a
  builtins root keeps a benign .compile()/.eval() on another object
  (model.compile, df.eval) from being misread as a sink.

- keyword-only compile() payload: compile() accepts its source as the
  source= keyword, and a standalone compile() with no positional arg
  reached the payload-recovery early return (no node.args -> NO_PAYLOAD),
  so its code object was executed via the fn.__code__ = c; fn() gadget
  entirely unscanned. Recover the source= keyword before returning
  NO_PAYLOAD (eval / exec take no keyword arguments in CPython, so an empty
  node.args there is genuinely payload-less). A benign keyword-only compile
  is analyzed, not blanket-blocked.

- dotted stdlib network imports in a workdir module: the vetter left the
  urllib / http tops out so urllib.parse stays benign, but that also let a
  helper `import urllib.request` (or http.client) open outbound connections
  the static network policy never saw. Refuse the network submodules by
  their full dotted name (urllib.request, urllib.robotparser, http.client,
  xmlrpc.client), covering the import, `import ... as`, `from urllib.request
  import ...`, and `from urllib import request` forms, while urllib.parse and
  the bare tops remain importable.

- sponge child writer: sponge (moreutils) soaks up stdin and writes it to a
  file argument (printf x | sponge /tmp/probe), an unguarded-child write
  outside the workdir. Add it to the child-writer denylist next to tee /
  patch / mktemp.

Regression coverage: TestRound43Bypasses in tests/test_sandbox_tools.py
(keyword-only compile via the __code__ / FunctionType / exec(compile())
gadgets, sponge child writer, plus a benign keyword-only compile that stays
allowed) and three workdir-module vetter cases in
tests/test_sandbox_runtime_backstop.py (builtins.eval sink denied,
urllib.request denied, urllib.parse still allowed).
2026-07-10 16:41:10 +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: builtins-qualified exec sinks and dotted network imports in workdir modules; keyword-only compile payload; sponge child writer 2026-07-10 16:41:10 +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: builtins-qualified exec sinks and dotted network imports in workdir modules; keyword-only compile payload; sponge child writer 2026-07-10 16:41:10 +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