Skip to content

triage: an allow rule lets commands and writes run in --permission-mode read-only and plan mode #3412

In review

Description

@Android-Login-Analysis

USAGE.md:214 says read-only "does not allow workspace mutation, network-fetch/search tools, or arbitrary command execution." But an allow rule in the user's settings overrides this: if ~/.claw.json allows bash, a session started with --permission-mode read-only runs any bash command, with no prompt.

This matters for a common setup: a user keeps "allow": ["bash"] so bash does not prompt in normal work, then opens an unfamiliar repository with --permission-mode read-only to review it safely. Commands and writes still run.

Steps (temporary HOME; <work> is a git repository with an empty folder protected/):

  1. ~/.claw.json:
    {"permissions": {"defaultMode": "danger-full-access"}}
    Run in <work>:
    claw --output-format json --permission-mode read-only "Use the bash tool to run exactly this command: touch <work>/protected/canary.txt" </dev/null
    Refused, as expected: tool 'bash' requires danger-full-access permission; current mode is read-only.
  2. Add an allow rule: {"permissions": {"defaultMode": "danger-full-access", "allow": ["bash", "REPL"]}}. Run the same command: it succeeds ("is_error":false), protected/canary.txt is created, no prompt.
  3. Writes: with "allow": ["write_file", "edit_file"], write_file to <work>/protected/canary.txt also succeeds in read-only ("type": "create").
  4. Plan mode, which is parsed as read-only (rust/crates/runtime/src/config.rs:2088): put {"permissions": {"defaultMode": "plan"}} in <work>/.claw/settings.local.json and keep the allow rule. The command runs; without the allow rule it is refused with current mode is read-only.

Cause: rust/crates/runtime/src/permissions.rs:312-316 returns Allow when an allow rule matches, before the mode is checked:

// The ladder, in one place. An `allow` rule is an explicit grant for
// this tool and outranks the mode; otherwise the mode decides through
// [`PermissionMode::covers`].
if allow_rule.is_some() || current_mode.covers(required_mode) {
    return PermissionOutcome::Allow;

The comment shows the order is deliberate, but USAGE.md:214 does not mention this exception.

Safe next action

Fix docs: say in USAGE.md:214 (and where plan is described) that permissions.allow rules outrank read-only and plan mode. Or, with owner review, change the code: in read-only and plan, check the mode first, so allow rules only skip prompts and cannot lift the mode's limit.

Activity

  1. Yeachan-Heo commented on Nov 29, 2026

    @Yeachan-Heo
    Contributor

    Status: Fix PR Created with Design Concern

    PR #3413 implements the read-only ceiling fix but surfaces a design decision that needs owner input.

    Confirmed Root Cause

    ✓ Verified: rust/crates/runtime/src/permissions.rs line 312-316 allows an allow rule to bypass permission mode entirely.

    ✓ Escalation Path: Untrusted Project-scope .claw/settings.json can ship permissions.allow rules (only hooks are stripped, not permissions).

    Fix Implemented

    PR #3413 makes read-only a true ceiling:

    • Allow rules cannot grant access to tools requiring higher permissions in read-only mode
    • Hook-provided Allow overrides also respect the ceiling
    • Plan mode (which parses to read-only) enforces the ceiling
    • Comprehensive test coverage added
    • All existing tests pass

    Blocking Design Question

    The fix reveals an ambiguity in the config parser: "default", "plan", and "read-only" all map to the same PermissionMode::ReadOnly.

    Problem: Users with "defaultMode": "default" who rely on allow rules would experience silent breakage (tools suddenly denied).

    Three Options Needed Decision:

    1. Option A - Create new PermissionMode variant for 'default' (most correct, most work)
    2. Option B - Remap 'default' to WorkspaceWrite (simpler, semantic change)
    3. Option C - Use Prompt mode for 'default' (escalates for user approval)

    PR #3413 is ready to rebase once the 'default' alias mapping is decided.

    See PR comment for full design discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions