Skip to content

[Feature]Terminal command and Python script execution within session specific Docker Container #4692

Closed

Description

@Ackerka

Motivations:

  1. Although terminal and python tools of Unsloth Studio are really powerful they also present a significant vulnerability, a serious security risk if Unsloth Studio is not containerized. This is because LLMs through Unsloth Studio have practically the same privileges as the user who started the Unsloth Studio. This means that a misunderstood request can lead to data loss or a malicious attack through the WEB interface can steal critical information from the host computer, infect or damage its software configuration and run arbitrary code.
  2. Unfortunately Docker does not fully support GPU acceleration on Apple Silicon, so the containeralization of the whole Unsloth Studio does not provide an efficient solution for MacOS users on Apple Silicon.

Request/proposal:
Let risky tool usage (like Python code or terminal command execution) happen in a session specific container.
This way not only the host system becomes safe from accidential or malicious attacks through Unsloth Studio but each chat session gets isolated, so they have their own "computer" similarly to the solution that Manus is using.
As an extra to the significantly increased security delivered with this solution Unsloth Studio with its compute intensive AI tasks keeps running natively on Apple Silicon, so it can fully utilise the resources of the host.

I understand if Unsloth Studio does not want to depend on third party tools like Docker or Podman for tool usage, so it is acceptable if the proposed feature can be turned on/off during Unsloth Studio setup/configuration but it should not be possible from the chat interface.

I have made an almost fully GLM 4.7 vibe coded proof of concept implementation that seems to work fine on a Mac Studio M3 Ultra with Docker. It is currently a temporary solution for me but it is not complete enough: cannot be switched off for example, which might be beneficial in some scenarios for NVIDIA based systems where the whole Unsloth Studio can be efficiently containerized.
Concerning the PoC implementation I only had to modify the studio/backend/core/inference/tools.py file and add a new script (studio/backend/core/inference/docker_sandbox.py) for handling the containers. I have attached these two cruicial files to the feature request as proof of concept example implementation.
By the way I have also removed some bash command restrictions like chmod, rm and sudo from tools.py as they can only harm the container and the shared/mounted session specific workspace under the studio_sandbox folder from now on. (Not to mention that although this protection/limitation was nice to have it was rather weak as a better model could bypass it through python code execution with ease.)
Some other files were also created by GLM 4.7 for docker image creation and documentation. I can share them as well on demand.

docker_sandbox.py

tools.py

Please, let me know your opinion and feel free to use the shared code as you want.

Activity

  1. added
    feature request
    on Mar 29, 2026
  2. added
    help wanted
    on Mar 30, 2026
  3. rolandtannous commented on Mar 30, 2026

    @rolandtannous
    Contributor

    Unsloth Studio runs python code inside an uv venv.
    So it has the same vulnerability surface as any other python framework, not more.
    In any case, note that we're working both on a podman container for Mac and there is a standalone app coming soon.

  4. danielhanchen commented on Oct 13, 2026

    @danielhanchen
    Member

    Fixed! Sorry on the delay. Unsloth Studio now supports this: it runs the Python and Terminal tools inside an OS level sandbox, natively without Docker: Seatbelt on macOS and bubblewrap on Linux (Windows 11 has an opt-in preview), so each chat's code is confined to its own folder and cannot read or change your home directory or other chats' files. You can check or adjust it under Settings > Sandbox; on Ubuntu 23.10+ the sandbox needs a one time setup step that Studio offers there.
    To update: Unsloth Desktop will have an update banner. For Studio, use unsloth studio update. For Docker, use docker exec <container> unsloth-studio-update. Reopen if it still happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

feature requeston roadmap

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions