Docs
中文 EN

Security Boundaries, Path Scope & Approval Gate

CONTENTS

Mizar enforces runtime safety across two orthogonal axes: workspace path scoping (restrictToWorkspace) and an interactive approval gate before non-read-only tools run (--approve / /approval ask).

Default Posture Is Open for Local Speed

Out of the box, Mizar sets restrictToWorkspace: false and ApprovalMode::Auto so local workflows run without friction. Always enable at least one guard when exploring untrusted repositories or running risky batches.

FIG 04 Security 2×2 Matrix (Path Scope × Approval)
Scope → ↓ Approval restrictToWorkspace: false (Default) read/write/edit/grep/find can access outside repo restrictToWorkspace: true File tools only · ⚠️ Does NOT restrict bash! ApprovalMode ::Auto (Default) All tools auto-run No confirm prompts --approve /approval ask Gates mutating tools incl. bash / write edit / codemode ⚠ Unrestricted Default DEFAULT • File tools can access paths outside workspace • bash / write / edit run without prompts • Best for: fully trusted local scaffolding ✕ Avoid this default on untrusted repos ! Partial Scope (Shell Gap) PARTIAL ✓ File tools scoped + 40-hop symlink guard ⚠ bash commands bypass restrictToWorkspace • Shell can reach outside via abs path or ../ Pair with --approve or excludeTools: ["bash"] Supervised Cross-Workspace SUPERVISED ✓ read / grep / find run silently (read-only) ✓ Writes, bash & codemode require approval • Allows supervised multi-repo workflows mizar --approve (confirm every write & cmd) ✓ Recommended Dual Lock RECOMMENDED ✓ Scoped files (symlink safe) + approvals ✓ Blocks bash escapes & accidental overwrites • Stack excludeTools: ["mcp__*__drop_*"] mizar --approve -C <repo> (+ --read-only audit) Interactive Approval Actions (--approve / ask) [1] Allow once · [2] Always allow tool · [3] Deny · [4] Deny with reason ! / !! Local Bash Exception User-typed in input; bypasses tool approval
FIG 04: Security 2×2 matrix — horizontal axis scopes built-in file tools (not bash), vertical axis gates mutating tools via interactive approval.

Axis 1: Workspace Path Scope (restrictToWorkspace)

Enabling "restrictToWorkspace": true in settings.json confines all built-in file tools (read, write, edit, grep, find in mizar-tools-coding, plus read_file / list_dir in mizar-tool-fs) to the workspace root:

  • Symlink Escape Defense (resolve_canonical_target): Canonicalizes paths down the tree — even for not-yet-created target files, by canonicalizing the nearest existing ancestor and validating remaining segments stay inside the canonical workspace root — backed by a 40-hop symlink loop guard.
  • Shell Tool Caveat: restrictToWorkspace constrains file tools ONLY and does NOT sandbox bash subprocesses. If bash remains enabled, commands can still touch paths outside the workspace via absolute paths or ../.

Axis 2: Interactive Approval Gate (--approve / /approval ask)

Implemented by ApprovalGatePlugin (mizar-client) on the tools/pre-execute waterfall:

  • Activation: Pass --approve on launch, set ui.approvalMode: "ask", or toggle interactively via /approval ask (/approval auto restores auto-run).
  • Gated Tools: Read-only tools (read, grep, find, list_dir, get_time) run without prompts. Every mutating or execution tool — write, edit, bash, codemode, and mutating MCP tools — requires approval (including nested mutating tool calls triggered inside codemode).
  • Four Approval Actions:
    1. Allow once: Approve this single invocation.
    2. Always allow tool: Whitelist this tool name for the current session.
    3. Deny: Reject execution with a permission error.
    4. Deny with reason: Reject and feed your custom constraint message back to the model so it can revise its plan.
! / !! User Shell Commands Bypass the Gate

Commands typed directly by you using ! or !! in the composer bypass ApprovalGatePlugin and tool allowlists.

Defense-in-Depth Recipes

ScenarioRecommended Flags / ConfigEffective Guarantee
Untrusted repo audit & editsmizar --approve -C /path/to/repo + restrictToWorkspace: trueFile tools locked inside repo (symlink-safe); every bash/write/edit/codemode requires consent
Read-only code reviewmizar --read-only -C /path/to/repoReduces coding tools to read / grep / find
Code edits without shell access"restrictToWorkspace": true, "excludeTools": ["bash"]Symlink-guarded file access with no OS command execution channel
Block dangerous MCP subsets"excludeTools": ["mcp__prod__*", "*_drop_*"]Matched tools become Hidden in both LLM schemas and codemode
Ephemeral zero-trace runmizar --isolated --no-persist -C /tmp/sandboxIgnores disk configs under ~/.mizar and skips JSONL persistence under ~/.mizar/sessions

Search Mizar Docs