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).
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.
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:
restrictToWorkspaceconstrains file tools ONLY and does NOT sandboxbashsubprocesses. Ifbashremains 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
--approveon launch, setui.approvalMode: "ask", or toggle interactively via/approval ask(/approval autorestores 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 insidecodemode). - Four Approval Actions:
- Allow once: Approve this single invocation.
- Always allow tool: Whitelist this tool name for the current session.
- Deny: Reject execution with a permission error.
- Deny with reason: Reject and feed your custom constraint message back to the model so it can revise its plan.
Commands typed directly by you using ! or !! in the composer bypass ApprovalGatePlugin and tool allowlists.
Defense-in-Depth Recipes
| Scenario | Recommended Flags / Config | Effective Guarantee |
|---|---|---|
| Untrusted repo audit & edits | mizar --approve -C /path/to/repo + restrictToWorkspace: true | File tools locked inside repo (symlink-safe); every bash/write/edit/codemode requires consent |
| Read-only code review | mizar --read-only -C /path/to/repo | Reduces 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 run | mizar --isolated --no-persist -C /tmp/sandbox | Ignores disk configs under ~/.mizar and skips JSONL persistence under ~/.mizar/sessions |