Cortex Code CLI sandbox¶
Cortex Code CLI can run shell commands inside a sandbox to restrict filesystem access, network access, and process capabilities. Sandboxing adds a layer of isolation so the agent cannot accidentally modify files or access resources outside of your project.
Important
Support for this feature is experimental and may be subject to change.
Platform support¶
The sandbox uses the operating system’s built-in isolation features to restrict commands.
Platform |
Implementation |
Dependencies |
|---|---|---|
macOS |
|
|
Linux |
|
|
Windows |
Native restricted tokens |
None |
Installing dependencies¶
macOS:
Debian / Ubuntu:
Fedora / RHEL:
Enabling the sandbox¶
Use the /sandbox slash command in Cortex Code CLI:
You can also enable the sandbox in your settings file. Add a sandbox object to
~/.snowflake/cortex/settings.json (user-level) or .snowflake/cortex/settings.json
(project-level):
The default permission mode is "regular". To use auto-allow mode, set "mode": "autoAllow"
explicitly. See Permission modes.
Permission modes¶
The sandbox has two permission modes that control how commands are approved:
Mode |
Setting value |
Behavior |
|---|---|---|
Auto-allow |
|
Commands that can be sandboxed run automatically without prompting. Commands that cannot be sandboxed (for example, those requiring network access to non-allowed domains) fall back to the normal permission flow. |
Regular |
|
All commands prompt for approval, even when running inside the sandbox. |
Set the mode with the /sandbox command or in settings:
Filesystem restrictions¶
The sandbox controls which paths commands can read from and write to.
Default behavior¶
Working directory: Always allowed for read and write.
Skills directory (
~/.snowflake/cortex/skills): Allowed.Context directory (
~/.snowflake/cortex/.ctx): Allowed whenctxAvailableis enabled.
Protected paths (always denied for write)¶
The following paths are always protected, regardless of your configuration:
Shell configuration files:
~/.bashrc,~/.bash_profile,~/.zshrc,~/.zprofile,~/.profile,~/.bash_login,~/.bash_logoutGit hooks:
~/.git/hooks,.git/hooksSSH configuration:
~/.ssh/authorized_keys,~/.ssh/configManaged settings directories and files:
/Library/Application Support/Cortex/(macOS),/etc/cortex/(Linux)
Custom filesystem rules¶
Configure filesystem access in settings:
Setting |
Default |
Description |
|---|---|---|
|
|
Paths the sandbox can read. An empty array means all paths are allowed (except those
in |
|
|
Paths the sandbox cannot read. Takes precedence over |
|
|
Paths the sandbox can write to. |
|
|
Paths the sandbox cannot write to. Takes precedence over |
Important
Deny rules always take precedence over allow rules. If a path matches both allowWrite
and denyWrite, the path is denied.
Network restrictions¶
The sandbox can restrict which domains commands can access over the network.
Setting |
Default |
Description |
|---|---|---|
|
|
Domains the sandbox can access. An empty array means all domains are allowed
(except those in |
|
|
Domains the sandbox cannot access. Takes precedence over |
|
|
Whether sandboxed commands can bind to local ports. |
Unsandboxed command fallback¶
Some commands may not be compatible with the sandbox. The allowUnsandboxedCommands setting
controls what happens when a command cannot run inside the sandbox.
Setting |
Behavior |
|---|---|
|
The agent can request to run the command on the host. You are prompted to approve. |
|
Commands must run inside the sandbox or be listed in |
Excluded commands¶
You can specify commands that should always run on the host, outside the sandbox:
Excluded commands bypass the sandbox and follow the normal permission flow.
Settings reference¶
The complete sandbox settings object:
Setting |
Default |
Description |
|---|---|---|
|
|
Enable or disable the sandbox. |
|
|
Permission mode: |
|
|
Allow fallback to host execution when a command cannot be sandboxed. |
|
|
Commands that always run on the host, outside the sandbox. |
|
|
High-level permission allow rules. Supports patterns like |
|
|
High-level permission deny rules. Same pattern syntax as |
|
|
Network domain allowlist (empty = allow all). Supports wildcards. |
|
|
Network domain denylist. Takes precedence over allowlist. |
|
|
Allow sandboxed commands to bind to local ports. |
|
|
Read allowlist (empty = allow all except deny). |
|
|
Read denylist. Takes precedence. |
|
|
Write allowlist. |
|
|
Write denylist. Takes precedence. |
|
|
Allow sandbox access to the context directory ( |
Configuration scopes¶
Sandbox settings follow the same precedence as other Cortex Code settings:
Project-level (highest priority):
.snowflake/cortex/settings.jsonUser-level:
~/.snowflake/cortex/settings.jsonManaged/enforced: Administrators can enforce sandbox policy via the managed settings file. See Managed settings (organization policy).