ローカルエージェント向けの安全なサンドボックスの実装
macOS、Linux、Windowsでエージェントサンドボックスを構築し、セキュリティを向上させながら中断を減らす方法について。
キーポイント
AIコーディングエージェントの安全性と効率性を両立するサンドボックス技術の実装
人間による承認の疲労(approval fatigue)を解消し、中断を40%削減
macOS/Linux/Windowsの各OSに合わせたサンドボックス設計の技術的トレードオフ
Seatbelt(sandbox-exec)など既存技術の応用による実用的なセキュリティソリューション
影響分析・編集コメントを表示
影響分析
AIエージェントの自律性と安全性のバランスを取る技術的進展であり、開発者ツールの実用性を大幅に向上させる。特に「承認疲労」という現実的な課題に対処することで、AI支援開発の日常的な採用を促進する可能性が高い。
編集コメント
「安全に失敗できる環境」の実装はAIエージェント普及の鍵。Cursorが各OSの制約を乗り越えた実装は、業界全体のベストプラクティスになり得る。
ローカルエージェント向けセキュアなサンドボックスの実装
コーディングエージェントは、環境を調査し変更を加えるためにターミナルコマンドを実行する能力が大幅に向上している。ユーザーがこれらのコマンドを自動承認すれば、エージェントの能力は飛躍的に高まるが、その代償としてリスクも増大する。誤動作したエージェントは、データベースの削除、壊れたコードのリリース、機密情報の漏洩などを引き起こす可能性がある。
あらゆるコマンドに人の承認を求めることはこのリスクを軽減するが、その効果は往々にして一時的なものに留まる。承認が蓄積するにつれ、ユーザーは注意深く確認しなくなる。エンジニアが複数のエージェントを並行して実行し、承認プロンプト間でコンテキストスイッチを迫られる状況では、この問題はさらに悪化する。結果として「承認疲れ」が生じ、承認制度の本来の目的が損なわれてしまう。
この問題に対処するため、我々は過去3ヶ月でmacOS、Linux、Windows向けにエージェントのサンドボックス化を展開した。サンドボックス化されたエージェントは、制御された環境内では自由に動作し、外部(主にインターネットへのアクセス)に出る必要が生じた時のみ承認を要求する。これにより、中断は劇的に減少した。サンドボックス化されたエージェントは、非サンドボックス版に比べて停止回数が40%少なく、ユーザーは手動でのレビューと承認に費やす時間を数時間節約できる。
我々のサンドボックス化の取り組みは、セキュリティを向上させながら中断を排除することを目標に始まった。エージェントに効果を発揮する十分な自由度を与えつつ、リスクを生む権限は与えないようにする必要があった。
このバランスを取ることは見た目以上に難しい。多くの基本的なテストやビルドの工程でさえ、予期しない権限を必要とするターミナルコマンドが存在する。単純なサンドボックスではこれらをブロックし、エージェントのワークフローを破綻させてしまう。実用的なサンドボックスの設計は、各OSが設定するパラメータ内で、セキュリティと使いやすさの間のトレードオフを調整する作業なのである。
我々は、各プラットフォームで異なる実装を持つ統一されたサンドボックスAPIを提供する。macOS、Linux、Windowsはそれぞれ異なるサンドボックス基盤を提供しており、これが設計の根幹を決定した。
特にmacOSでは4つのサンドボックス手法(App Sandbox、コンテナ、仮想マシン、Seatbelt)を評価した。App SandboxはMac App Store向けに設計されており、エージェントが実行する可能性のあるすべてのバイナリにCursorが署名する必要が生じる。これは大幅な複雑化をもたらし、エージェントが生成または変更したバイナリがCursorの信頼を継承するという新たな悪用経路を開くことになる。コンテナはLinuxバイナリに制限され、仮想マシンは許容できない起動遅延と
原文を表示
Blog / researchCoding agents are getting much better at running terminal commands to explore the environment and make changes. Users who auto-approve these commands unlock significantly more powerful agents, but at the cost of increased risk. A mistaken agent can delete databases, ship broken code, or leak secrets.
Requiring human approval for every command mitigates that risk, but often only temporarily. As approvals accumulate, users stop inspecting them carefully. This gets worse when engineers run multiple agents in parallel and have to context-switch between approval prompts. The result is approval fatigue, which undermines the point of approvals in the first place.
Over the last three months we've addressed this by rolling out agent sandboxing on macOS, Linux, and Windows. Sandboxed agents run freely inside a controlled environment and only request approval when they need to step outside it, most often to access the internet.
This reduces interruptions dramatically. Sandboxed agents stop 40% less often than unsandboxed ones, saving users hours of manual review and approval.
We began our sandboxing work with the goal of eliminating interruptions while improving security. We wanted to provide agents with enough latitude to be effective, while denying them permissions that create risk.
Striking this balance is harder than it appears. Many terminal commands require unexpected privileges, even for basic test or build steps. A naive sandbox would block these and break the agent's workflow. Designing a usable sandbox is an exercise in navigating tradeoffs between security and usability, while working within the parameters set by each operating system.
We expose a uniform sandbox API, implemented differently on each platform. macOS, Linux, and Windows offer distinct sandboxing primitives which drove the underlying design choices.
We evaluated four sandboxing approaches on macOS: App Sandbox, containers, virtual machines, and Seatbelt. App Sandbox is designed for the Mac App Store and would require Cursor to sign every binary an agent might execute. This would have added significant complexity and opened up new abuse vectors by allowing agent-generated or modified binaries to inherit Cursor's trust. Containers would limit us to Linux binaries, and virtual machines impose unacceptable startup latency and memory overhead.
This left Seatbelt, accessed via sandbox-exec. It was introduced in 2007 and deprecated in 2016, but is still used by critical third-party applications like Chrome. It allows a command to run under a sandbox profile that constrains the behavior of an entire subprocess tree.
The profile defines permissions with fine granularity, restricting syscalls and reads or writes to specific files and directories through an idiosyncratic policy language. We generate this policy dynamically at runtime based on workspace-level and admin-level settings, along with the user's .cursorignore.
(deny file-write* (regex "^.*\/\\\.vscode($|\/.*)") ) (deny file-write* (require-all (regex "^.*\/\\\.cursor($|\/.*)") (require-not (regex "^.*\/\\\.cursor/(rules|commands|worktrees|skills|agents)($|\/.*)"))) ) (deny file-write* (regex "^.*\\\.code-workspace$")) (deny file-write* (regex "^.*\/\\\.cursorignore$")) (deny file-write* (regex "^.*\/\\\.git/config$")) (deny file-write* (regex "^.*\/\\\.git/hooks($|\/.*)") ) (deny file-write* (regex "^(/private)?/var/folders/.*-cursor(-[a-z]+)?-zsh($|\/.*)") ) #Linux
Linux is both easier and harder than macOS. The kernel exposes the required primitives via Landlock and seccomp, but userspace is responsible for composing them into a usable sandbox. While several open-source projects combine these mechanisms effectively, none support features such as .cursorignore.
We decided to use Landlock and seccomp directly. Seccomp blocks unsafe syscalls, while Landlock enforces filesystem restrictions, letting us make ignored files completely inaccessible to the sandboxed process. We map user workspaces into an overlay filesystem and overwrite ignored files with Landlocked copies that can't be read or modified.
Finding and remounting these files is the slowest part of Linux sandboxing. It would be easier to lazily filter filesystem operations the way macOS does, but Linux doesn't provide easy access to the file path in a seccomp-bpf context.
On Windows, we run our Linux sandbox inside WSL2. Building an equivalent native Windows sandbox is significantly harder because most existing sandboxing primitives are tailored to browsers and do not support general-purpose developer tools. We're working with Microsoft to ensure the necessary primitives become available.
#Teaching agents how to use the sandbox
A sandbox is only effective if agents can anticipate which commands will succeed inside the sandbox and recognize when escalation is required. Making models sandbox-aware required changes to the agent harness.
We began by updating the Shell tool de
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み