AI 開発

AI Agent はなぜ Sandbox で動かす必要があるか?2026 NVIDIA OpenShell ランタイム境界と MCP tools/call 外向き制御

約 15 分

モデルは JSON を埋めるだけである。危険なのは誰が実行し、誰がディスクとソケットに触るか。2026 年の NVIDIA OpenShell は openshell-sandbox の下で Agent を動かす。作成時に landlock とファイルポリシーを固定し、TOFU バイナリ許可リスト付きプロキシで外向きし、L7 で protocol: mcp と legacy json-rpc を分けて enforce する。本篇はランタイム sandbox であり、チャット権限や Sentry の繰り返しではない。

読む前の早見

部品 OpenShell 事実(文書 / PR) JSON で見るもの
openshell-sandbox Agent プロセスのライフサイクルを監督。status は問い合わせ可能 sandbox_id、state、supervisor
L7 外向きプロキシ 2026 ポリシーはアプリ層で MCP methods / tools/call と json-rpc method を一致 connections[].protocol、enforcement
TOFU バイナリ 登録されたバイナリだけが外向き接続を開ける proxy.binary_allowlist、matched_rule
Landlock / FS filesystem_policy と landlock はサンドボックス作成時。ネットワーク規則のようにホットリロードしない landlock.applied_at_create
json-rpc バッチ バッチ内一条の deny でバッチ全体 deny(MCP と同じ) 二跳目 legacy method が拒否

事実は 2026-11-06 まで:OpenShell ポリシー文書、openshell-sandbox CLI、2026 L7 MCP/json-rpc enforcement の PR とリリースノート。注文 A-1042 と sb_agent_demo_7f3a は架空。status JSON は Diff 用の示意であり、未公開 wire dump ではない。

JSON はカーネルでも外向きの門でもない。だから sandbox が要る

Coding Agent のループは同じである。モデルが tool_use を出し、runtime が実行する。sandbox がなければ、誤ったツール名が任意のプロセス、パス、URLになりうる。OpenShell はモデルの外に三層置く:

  • プロセスとファイル:openshell-sandbox が worker を起動。Landlock と filesystem_policy が作成時に木を固定する。
  • 外向き HTTP:プロキシは endpoint の protocol で JSON-RPC を解析する。MCP の tools/call と legacy の reports.search は別規則表。
  • 宿主は引数を検証:プロキシは既定で arguments を一致させない。A-1042 の形は Schema の仕事。

ツール名 allow/deny と Sentry ハードウェア:OpenShell ツール名と Sentry。本篇は runtime のみ。セッション allow/ask/deny は harness 名簿:Coding Agent の権限モデル。MCP 線形:Coding Agent の MCP 呼び出し。ループと state:Agent Harness と JSON State。

openshell-sandbox はプロセスを監督する。チャット権限ではない

openshell-sandbox CLI(supervisor 名は status JSON に出る)は worker を隔離に入れる。 cgroup/名前空間、Landlock、同一 sandbox に付いた外向きプロキシ。モデル側 tool_use は harness で承認される。tools/call を送るのは箱内の Python や runner バイナリ。TOFU が登録するのはどのバイナリがどの tool server へ届くかであり、モデル token の内容ではない。network_policies はホットリロード可。ファイルと Landlock は不可。ディスク権限を変えるなら sandbox を作り直す。2026 文書は L7 enforcement を強調する。MCP 端点では method と params.name。legacy json-rpc ではトップレベル method(例 reports.search)。私設網、ループバック、リンクローカル、クラウドメタデータは既定の外向き allow に入らない。

tool_use から外向きまで:四つの JSON

1. モデル tool_use(harness 内)。 名前と input は strict/Schema を通す。sandbox はまだ関与しない:

{
  "type": "tool_use",
  "id": "toolu_order_01",
  "name": "lookup_order",
  "input": {
    "order_id": "A-1042"
  }
}

2. 架空 sandbox status。 tool server 接続、protocol、直近 egress 決定—ポリシーと Diff 用:

{
  "sandbox_id": "sb_agent_demo_7f3a",
  "state": "running",
  "supervisor": "openshell-sandbox",
  "created_at": "2026-11-06T08:12:04Z",
  "landlock": { "applied_at_create": true, "filesystem_policy": "orders_ro_v1" },
  "proxy": {
    "mode": "tofu",
    "binary_allowlist": ["/usr/bin/python3", "/opt/agent/runner"],
    "connections": [
      {
        "tool_server": "orders-mcp",
        "host": "orders.example.com",
        "port": 443,
        "path": "/mcp",
        "protocol": "mcp",
        "enforcement": "enforce",
        "status": "connected"
      },
      {
        "tool_server": "reports-legacy",
        "host": "reports.internal.example.com",
        "port": 8443,
        "path": "/rpc",
        "protocol": "json-rpc",
        "enforcement": "enforce",
        "status": "connected"
      }
    ]
  },
  "last_egress_decision": {
    "allowed": true,
    "method": "tools/call",
    "tool": "lookup_order",
    "matched_rule": "orders-mcp.tools/call.lookup_order"
  }
}

3. sandbox プロセスからの MCP tools/call。 プロキシは L7 でこの body を読む。モデルの散文ではない:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "lookup_order",
    "arguments": { "order_id": "A-1042" }
  }
}

4. 同一バッチの legacy json-rpc。 reports.search が rules に無ければバッチ全体 deny:

[
  {
    "jsonrpc": "2.0",
    "id": "batch-1",
    "method": "tools/call",
    "params": {
      "name": "lookup_order",
      "arguments": { "order_id": "A-1042" }
    }
  },
  {
    "jsonrpc": "2.0",
    "id": "batch-2",
    "method": "reports.search",
    "params": {
      "query": "refund A-1042",
      "limit": 10
    }
  }
]

Sandbox、harness、ツール名ポリシー、Schema—分担を混ぜない

すべて「安全」と呼ばれる。対象が違う。混ぜると外向きが漏れるか、誤ったセッションツールを止める:

門 見る JSON / 振る舞い 典型ミス
Harness allow/ask/deny セッションで Bash、Read、MCP クライアントを走らせるか IDE で Shell を止めたつもりで runner が未登録 orders host へ
OpenShell runtime sandbox 箱内バイナリ、Landlock、プロキシが見る外向き body Allow を一度押したが未登録バイナリが外向き
OpenShell ツール名ポリシー MCP tools/call の params.name ツール名 allow/deny は OpenShell と Sentry 記事—deny_rules は本篇で繰り返さない
宿主 Schema tool_use.input と arguments ツール名は許可だが order_id が DB へ

権限ファイルはセッション:Coding Agent の権限モデル。引数の門は Schema:AI が JSON Schema を要る理由。ツール名と Sentry:OpenShell ツール名と Sentry。

監査可能 sandbox に Agent を入れる五ステップ

network policy を広げる前に、架空注文 A-1042 を staging で通す:

  1. 三つの JSON 面を分けて保存。 messages の tool_use、宿主 state、OpenShell policy/sandbox status—一 blob にしない。
  2. 作成時に filesystem + Landlock。 新ディレクトリが要るなら作り直す。ホットリロードを期待しない。
  3. TOFU バイナリと tool server を登録。 各 endpoint に protocol、host、port、path、enforcement: enforce。
  4. MCP と legacy を端点分離。 同一 host:port で protocol: mcp と json-rpc 表を混ぜない。
  5. バッチは最悪跳で受け入れる。 lookup と reports.search を同一 batch で deny 試行しない。

五つが Diff 可能な JSON に落ちれば、harness、プロキシ、Schema を分けられる。

外向き失敗時は四对象を広げる

sandbox status の last_egress_decision から始め、policy と実 outbound body を照合する。

  • tool_use、status、外向きを 整形;arguments の A-1042 は Schema 検証。
  • JSONPath 抽出 で $.params.name、$.method、$.connections[*].protocol。
  • ホットリロード前後の policy を JSON Diff。prompt より connections と deny_rules。
  • openshell logs --tail --source sandbox で拒否 binary、host、path。
  • ログと status の token は マスキング。JSONSort はブラウザローカル。

四つが揃えば、binary 未登録、protocol 誤り、legacy method 未 allow のどれかが分かる。

よくある誤り

  • allow/ask/deny を sandbox とみなす。 それは harness のセッション門。MCP 外向きは OpenShell runtime が要る。
  • モデル tool_use だけ監査し sandbox egress body を見ない。 runner が JSON-RPC を書き換え再送しうる。
  • network_policies のホットリロードで Landlock も変わると思う。 ファイルポリシーは作成時固定。ディスク変更は作り直し。
  • MCP と legacy json-rpc で規則表を共有。 2026 L7 は protocol で分岐。混在 endpoint は silent mismatch。
  • TOFU バイナリを無視。 interpreter パスを変え allowlist を更新しないとプロキシで止まる。
  • 本篇で OpenShell と Sentry 記事の Sentry 深読みを代替する。 帯域外ハードウェアは runtime JSON だけでは説明できない。

FAQ

OpenShell なしで harness 権限だけで足りるか?

足りない。権限ファイルは IDE ツールの門。sandbox はプロセスが読むパスと、どのバイナリがどの host へ JSON-RPC を送れるかを門にする。両方要る。

sandbox は tools/call の order_id を検証するか?

既定ではしない。L7 MCP は method とツール名。引数の形は宿主 Schema—OpenShell は tool-argument matching 未対応と書く。

legacy json-rpc と MCP の違いは?

endpoint の protocol。MCP は tools/call + params.name。legacy は reports.search のようなトップ method。規則は分けて書く。

JSON-RPC バッチで一条拒否されると?

MCP と同じ。一条 deny でバッチ全体 deny。lookup と未許可 search を束ねない。

Docker で Agent を動かすのと同じか?

コンテナは包装。OpenShell は Landlock、バイナリ単位 L7 egress、openshell-sandbox ライフサイクル/status を足す。コンテナ単体は MCP tools/call を解析しない。

結論

Agent は sandbox で動かす必要がある。tool JSON は意図だけを述べ、カーネル、ディスク、外向きではない。OpenShell は openshell-sandbox、Landlock、TOFU、L7 MCP/json-rpc プロキシで実行を Diff 可能な境界に閉じる。

規則を広げる前に tool_use、sandbox status、outbound tools/call、policy を揃える。セッション権限、ツール名、Schema は各記事で読む。一つの allow リストに混ぜない。

あわせて読む

更新履歴: 初版