Skip to content

M31A uses layered controls to keep agent activity contained: workspace trust, approval modes and policies (see Approval modes), and optional process sandboxing.

Workspace trust ​

A folder must be trusted before file and shell tools act freely. On first run, M31A prompts for trust. Control it with:

  • --skip-trust — trust for the current session only,
  • /permissions trust — trust interactively,
  • security.folderTrust.enabled — global toggle (default true),
  • M31A_TRUST_WORKSPACE=true — non-interactive/CI override.

macOS Seatbelt ​

On macOS, M31A uses sandbox-exec with a profile selected by SEATBELT_PROFILE:

Profile groupReadsWrites
permissive-*BroadProject folder
restrictive-*RestrictedProject folder
strict-*Working directoryWorking directory

Each group has -open (outbound network allowed) and -proxied (network through a proxy) variants, plus closed aliases. Built-in definitions live in packages/cli/src/utils/sandboxBuiltinProfiles.ts with corresponding .sb files. Set a custom profile by creating .m31a/sandbox-macos-<profile>.sb and setting SEATBELT_PROFILE=<profile>.

Container sandboxing ​

On macOS and Linux, enable a container sandbox with:

bash
export M31A_SANDBOX=true       # auto-detect docker or podman
export M31A_SANDBOX=docker     # force Docker
export M31A_SANDBOX=podman     # force Podman

M31A_SANDBOX also accepts a command name. sandboxConfig.ts recognizes docker, podman, sandbox-exec, runsc, lxc, and windows-native. macOS auto-detects Seatbelt; Docker and Podman require explicit opt-in.

Build the image once with npm run build:all. The image is ghcr.io/eshanized/m31a-sandbox:0.2.0. The project directory and system temp directory are mounted read-write, and created files are mapped to your host user/group. The container is started and removed automatically.

Additional customization:

VariablePurpose
SANDBOX_MOUNTSExtra mounts.
SANDBOX_PORTSExposed ports.
SANDBOX_ENVExtra environment variables.
M31A_SANDBOX_IMAGEOverride the sandbox image.
BUILD_SANDBOX=1Rebuild a custom sandbox.

Create .m31a/sandbox.Dockerfile and/or .m31a/sandbox.bashrc in the project settings directory for a fully custom sandbox.

Proxied networking ​

Set M31A_SANDBOX_PROXY_COMMAND to a command that starts a proxy listening on :::8877. M31A starts and stops the proxy alongside the sandbox. This works with container sandboxes and the *-proxied Seatbelt profiles.

Tool-level sandboxing ​

security.toolSandboxing isolates individual tools instead of the entire CLI process. tools.sandbox, tools.sandboxAllowedPaths, and tools.sandboxNetworkAccess configure the legacy process-level mechanism. security.enableConseca enables an experimental context-aware security checker.

Recommendations ​

  • Keep default approval mode in untrusted repositories.
  • Prefer container sandboxing when running shell commands from unfamiliar code.
  • Use plan mode for read-only analysis.
  • Never place API keys in .m31a/settings.json files that you commit.

Next steps ​

See Approval modes and Environment variables.

Built with VitePress. Powered by NVIDIA NIM.