Skip to content

Engine: evaluate tool permissions on the same argument decode the tool executes #2264

Closed

Description

@peppescg

Problem

The policy evaluator and the tool runtime read a tool call's JSON arguments with different rules:

  • Shell permission matching (governance.ShellCommandFromArgs, engine/governance/evaluator.go) reads the command from specific exact key names.
  • Shell execution (parseShellArgs, engine/agent/shelltool.go) decodes the same arguments with Go's encoding/json struct decoding, which has its own rules for key matching and repeated keys.

The command used to decide a call's permission should always be exactly the command that runs. Today, for some argument shapes, the two can differ.

Expected

For every tool whose permission depends on its arguments, permission evaluation and execution derive the value from one shared decode of the arguments, so they cannot disagree. Argument objects that don't decode to a single unambiguous value are rejected before policy evaluation, rather than interpreted differently by each side.

Scope

  • Shell first. Then check the other tools whose policy matching reads arguments (file paths for Edit/Write/Read, network targets, MCP tool arguments if matched) for the same split.
  • One decode path shared by policy evaluation, approval display and execution. Alternatively, reject ambiguous argument objects in session.ParseArgs before anything reads them.
  • Tests proving, for each affected tool, that the value the policy evaluates equals the value the tool executes, across argument encodings.
  • A changelog entry for any behaviour change for clients that relied on the old reading.

Related: #2263 (approval display of system temp-scope Shell calls).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions