unsloth/studio/backend/core
danielhanchen e80c4b4b1f Harden sandbox: wrapper-prefixed shell argv, wrapper durations, args= cwd, relative env -C, diff readers, literal kwargs
- Resolve a wrapper-prefixed shell argv before scanning: subprocess.run(['env', 'bash', '-c',
  'cat /etc/passwd']) hid the nested shell behind argv[0]=env, so only argv[0] was checked for a
  shell binary and the -c payload was never scanned. Resolve the executed command word past
  wrapper prefixes (via _blocked_in_argv) so env / timeout / nice wrapped bash -c is scanned.
- Skip a wrapper's numeric duration in the shell-string read scanner: timeout 1 bash -c
  'cat /etc/passwd' treated the operand 1 as the command word, so the nested bash -c was not
  reached. Add the same _is_wrapper_numeric_arg skip the blocklist path already uses.
- Honor args= when failing closed on a dynamic cwd: the fail-closed only inspected positional
  argv, so subprocess.run(args=['cat', 'passwd'], cwd=P) slipped. Resolve the argv from the
  public args= keyword too.
- Resolve a relative env -C against the ambient subprocess cwd: env -C . cat passwd under
  cwd=/etc chdirs to /etc, not the bare fragment, so the relative reader still reads /etc/passwd.
  Join a relative env -C / --chdir= operand onto the current child cwd instead of replacing it.
- Treat diff-style utilities as file readers: diff / sdiff / diff3 / colordiff / cmp print file
  contents, so an escaping glob (diff /etc/pass* /dev/null) exfiltrated a secret. Add them to
  the shell-read command allowlist.
- Expand a literal star-star dict unpack for the shell / cwd decisions: a shell= or cwd= smuggled
  through subprocess.run(cmd, **{'shell': True}) was invisible to the kwarg loop (kw.arg is None).
  Iterate keywords through a helper that also expands a literal dict unpack.
- Materialize a device-sink path via the base str.replace before trusting it: a str subclass
  could override replace() to return '/dev/null' while its real value escaped the workdir. Call
  the genuine str.replace on the underlying buffer so the real path is checked.

Adds TestRound29Bypasses plus a runtime device-sink str-subclass escape test.
2026-07-10 06:39:37 +00:00
..
data_recipe Studio: harden background consumer loops and streaming paths against silent UI freezes (#6653) 2026-06-26 03:31:33 -07:00
export Studio: multi-select export formats, portable FP8/INT8, GGUF LoRA, and source parity (#6767) 2026-07-03 08:25:10 -07:00
inference Harden sandbox: wrapper-prefixed shell argv, wrapper durations, args= cwd, relative env -C, diff readers, literal kwargs 2026-07-10 06:39:37 +00:00
rag Run the malware gate on the RAG embedding model before it loads (#6887) 2026-07-07 04:30:21 -07:00
training Add MLX backend support for CLI unsloth train (#6709) 2026-07-08 03:25:26 -07:00
__init__.py Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
_torchao_stub.py Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
import_guards.py Studio: self-heal unsloth namespace shadows; clearer failed-load messages (#6532) 2026-06-21 22:43:31 -07:00
tool_healing.py Studio: parse Mistral [TOOL_CALLS] and rehearsal tool-call shapes (#5704) 2026-07-06 18:52:13 -07:00