> For the complete documentation index, see [llms.txt](https://unsloth.ai/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://unsloth.ai/docs/jp/shii/studio/unsloth-niokerusandobokkusu.md).

# Unsloth におけるサンドボックス化

Unsloth は Linux では bubblewrap、macOS では Seatbelt、Windows では MXC を使用します。

UnslothにはOSレベルのサンドボックス化が追加されました。これにより、Pythonとシェルのコマンドを隔離されたワークスペース内で実行できます。Unslothには2つのモードがあります - **「低」** と **「高」サンドボックスセキュリティ** - 低はUnslothのソフトウェアサンドボックス手法を採用しており、これらのコマンドに対して高度な文字列、AST、正規表現チェックを行います（危険な rm -rf、機密トークンの持ち出しなどを無効化します）。高は真のOSレベルのサンドボックス化で、すべてのプラットフォームで利用できます。

| オペレーティングシステム                                | サンドボックスソフトウェア       | 1回の呼び出しごとのレイテンシ |
| ------------------------------------------- | ------------------- | --------------- |
| <i class="fa-windows">:windows:</i> Windows | **MXC** （Windows公式） | 164ms           |
| <i class="fa-linux">:linux:</i> Linux       | Bubblewrap / Bwrap  | 50ms            |
| <i class="fa-apple">:apple:</i> Mac         | Seatbelt（Mac内部）     | 110ms           |

OSレベルのサンドボックス化を有効にするには:

* **Windows - MXCはプリインストールされています** （Windows 11 24H2以降）。 **高** を選択し、必要に応じてセットアップ手順に従ってください。
* **Linux** - Bwrapはインストールが必要です。"高"を選択すると、こちらでインストールします
* **Mac - Seatbeltはプリインストールされています**ので、UnslothはSeatbeltを自動的に有効にします

OSサンドボックス化が低か高かを確認するには、権限ボタンをクリックしてください:

<div align="left"><figure><img src="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FBdWF0MbLoJLwTeFVhX7j%2FScreenshot%202026-10-08%20at%207.00.50%E2%80%AFAM.png?alt=media&amp;token=a592513a-9f45-4e0b-80d4-b8a6456e37ac" alt="" width="563"><figcaption></figcaption></figure></div>

「詳細を見る」をクリックすると、サンドボックス設定ページに移動し、ソフトウェアサンドボックス化が有効かどうか、またbwrapやMXCのインストール方法も確認できます:

<div align="left"><figure><img src="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FfDEvjiXwBf1Fmftsp28q%2FScreenshot%202026-10-08%20at%206.56.34%E2%80%AFAM.png?alt=media&amp;token=b2c99b4c-67ea-4c50-bb98-4a710e0eafee" alt="" width="563"><figcaption></figcaption></figure></div>

3つのOSすべてで、OSレベルのサンドボックス化がどのように有効化されるか確認できます:

{% columns %}
{% column %}
Windows:

<figure><img src="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FLnxxpIwGpSjut6R6kLn8%2FScreenshot%202026-10-08%20at%206.53.26%E2%80%AFAM.png?alt=media&amp;token=85be4503-5279-4716-a1d0-1efbb8126129" alt=""><figcaption></figcaption></figure>
{% endcolumn %}

{% column %}
Mac:

<img src="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FRNZyuJL7xkrXJwYxofto%2FScreenshot%202026-10-08%20at%206.51.19%E2%80%AFAM.png?alt=media&amp;token=04ee3ff8-209c-41f6-bed2-8c64173ea77f" alt="" width="375">
{% endcolumn %}

{% column %}
Linux:

<figure><img src="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FesfsF7INvYB1MpIQF3cn%2FScreenshot%202026-10-08%20at%206.53.20%E2%80%AFAM.png?alt=media&amp;token=33f9f7cd-df4e-4e74-89c4-0c482c64e3c5" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column width="50%" %}
ワークスペース外へのアクセスをブロックするサンドボックスの動作を確認できます:

### サンドボックス化のレイテンシ

ソフトウェアおよびハードウェアのOSレベルサンドボックス化をかなり最適化しましたが、OSレベルのサンドボックス化には確実にレイテンシの追加があります。以下の表をご覧ください:
{% endcolumn %}

{% column width="50%" %}
![](https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FcyBycXfercRlu0iEttel%2Fnew%20sandbox.png?alt=media\&token=d9064a88-e5c8-4e1d-a261-e93f20739ea6)
{% endcolumn %}
{% endcolumns %}

| オペレーティングシステム                                | サンドボックスソフトウェア       | 低サンドボックス | 高サンドボックス |
| ------------------------------------------- | ------------------- | -------- | -------- |
| <i class="fa-windows">:windows:</i> Windows | **MXC** （Windows公式） | 8ms      | 164ms    |
| <i class="fa-linux">:linux:</i> Linux       | Bubblewrap / Bwrap  | 3ms      | 50ms     |
| <i class="fa-apple">:apple:</i> Mac         | Seatbelt（Mac内部）     | 10ms     | 110ms    |

{% columns %}
{% column %}

### サンドボックスを無効化 / 権限をバイパス / フルアクセス

サンドボックス化（ソフトウェアの低レベルとOSレベルの高レベルの両方）を無効にするには、"フルアクセス"を押すだけです。これでUnslothは制約なしでコンピュータ全体にアクセスできるようになります。
{% endcolumn %}

{% column %}

<figure><img src="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2F6YpMXm0gOsM7lPaygu4T%2FScreenshot%202026-10-08%20at%206.45.21%E2%80%AFAM.png?alt=media&amp;token=b7f308f5-ac0b-4852-9eeb-961e6cc575ef" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

### ソフトウェアサンドボックス化のアプローチ

Unslothのソフトウェアサンドボックス化は、正規表現、文字列チェックなどの集合で構成されています。追加で約 **1〜2msの追加レイテンシ** を各ツール呼び出しごとに加え、以下をブロックします:

* 削除およびディスク系ツール: `rm, dd, mkfs, fdisk, mount, umount`
* 権限と特権: chmod, `chown, sudo, su, doas, pkexec, passwd`
* ネットワーク: `curl, wget, nc, ncat, netcat, socat, ssh, scp, sftp, rsync`
* プロセスと電源: `kill, killall, pkill, shutdown, reboot, halt, poweroff`
* 別のスクリプトの内容を見えないまま実行すること: `eval, source`
* Windowsのみ: `rmdir, takeown, icacls, runas, powershell, pwsh`

Pythonコードを、実行前に読み取ってから:

* シェルのエスケープ: `os.system`と `subprked` コマンド、またはリテラルではないコマンド（たとえば su 経由の pip install）
* ネットワーク呼び出し: `requests, urllib`、生のソケット接続
* 次のような一部の機密性の高いシステム読み取り: `/etc/passwd`
* シグナルやタイムアウトを改ざんし、それらを回避しようとするもの。

両方のモードで全呼び出しに適用:

* 秘密の環境変数は削除されます。
* Studio独自の認証情報ファイルは拒否されます
* プロセス数、ファイルサイズ（100 MB）、メモリ（8 GB）、CPU時間（600秒）に制限があるため、fork bombはプロセス上限に達し、さらに呼び出しのタイムアウトも発生します

#### Windows MXCパートナーシップ

Windowsチームの皆さま、UnslothでMXCがうまく動くようにする取り組みでUnslothと協力していただきありがとうございます！ [こちらをご覧ください](https://blogs.windows.com/windowsexperience/2026/10/07/building-windows-for-hybrid-intelligence/) ローンチブログ記事

#### Unslothでサンドボックス化を使うには

Unslothを最新に更新するだけでサンドボックス化が使えます！


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://unsloth.ai/docs/jp/shii/studio/unsloth-niokerusandobokkusu.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
