Skip to content

fix(mcp): read-only tools take paths that reach the server file system #3236

Closed as not planned

Description

@dan-petty

Problem

Some tools flagged read-only take a path argument that the server opens or writes. Examples: ai_ast_graph --output_path, k8s_security_stream --output, gh_pages_verify --root_dir. Over a network transport, a model chooses these paths, so it can read or write outside the work tree of the server. This is the class that SECURITY.md rule 11 covers for the transport itself.

Found by the agent that built the role-scoped MCP servers (#3219, PR #3233). That change uses explicit name tables per role, so these tools are only in a role if a person lists them.

Evidence

  • devops ai ast-graph --help, devops k8s security-stream --help, devops gh pages-verify --help list the path options.
  • src/devops_cli/ai/mcp/roles.py on the PR branch holds the role tables.

Fix

For each tool of a role table, either drop the path option from the published schema or confine it to a root that the server sets. Add a check that fails when a tool of a role table has a text parameter named like a path and no confinement.

Acceptance criteria

  1. No tool of a role table accepts a path outside a confined root.
  2. A test reads the published schema of every role tool and fails on an unconfined path parameter.

Related: #3219, #3222.

Proposed design

Problem statement

Read-only MCP tools in role tables accept path arguments from a model. A model can choose a path outside the server work tree over a network transport. This change removes each unneeded path option and confines each kept path option to a server-set root. A test audits the published schema of every role tool.

Acceptance criteria

Requirement: Confined path resolution

Every path parameter that a role-table MCP tool publishes MUST resolve through safe_resolve_subpath against a server-set root before the server opens or writes the path.

Scenario: Traversal attempt

  • WHEN A model calls a role tool with ../../etc/passwd in a path parameter.
  • THEN The tool returns a validation error and opens or writes no path outside the server root.

Requirement: Unneeded path options removed

A role-table MCP tool that cannot confine a path parameter to a server-set root MUST remove that parameter from its published schema.

Scenario: Unconfined option is absent

  • WHEN The tool has a path parameter that no server root can confine.
  • THEN The published schema has no property for that parameter, and the tool uses a server-chosen default.

Requirement: Schema audit for role tools

A test SHALL read the published schema of every tool in every role table and fail when a path-like text parameter has no confinement entry.

Scenario: Unconfined path parameter

  • WHEN A role-table tool publishes a text parameter named like a path and the confinement registry does not name it.
  • THEN The test fails with the tool name and the parameter name.

Requirement: Server root is not model input

The confinement root MUST come from server configuration and MUST NOT come from a tool argument.

Scenario: Model supplies root

  • WHEN A model supplies a root path argument to a role tool.
  • THEN The server rejects the argument or resolves it under the configured root, and it does not use the supplied value as the root.

Requirement: Example tools covered

Tests SHALL cover the path options of ai_ast_graph, k8s_security_stream, and gh_pages_verify.

Scenario: Example tools reject outside paths

  • WHEN Each example tool receives a path outside the server root.
  • THEN Each tool rejects the path and leaves the outside location unchanged.

Existing Tool Considered

No alternatives check has run. No open, maintained tool or library covers confinement of MCP tool path parameters. The plan uses the existing safe_resolve_subpath helper and _PATH_PARAM_RESTRICTIONS registry. The written cost is about 20,000 tokens to build, about 5,000 tokens per year to keep and fix, and 1-2 days elapsed; it adds no new dependency.

Key questions

  • How should a role-table tool handle a path argument from a model?: Drop the option when the server can choose the path. Otherwise confine the value with safe_resolve_subpath against a server-set root and reject traversal. (best practice) [sources: SECURITY.md, src/devops_cli/core/paths.py]
    • Rejected: Drop every path option. It removes useful read-only outputs and changes commands that need a path.
    • Chosen: Confine kept options with safe_resolve_subpath. SECURITY.md rule 11 requires this helper for a model-supplied path.
    • Rejected: Leave the path option as it is. It lets a model read or write outside the server work tree.
  • Which root confines a kept path option?: Use a server-set work tree or data directory. Never use a model-supplied root. Remove gh_pages_verify --root_dir or map it to the server root. (best practice) [sources: SECURITY.md]
    • Rejected: Model-supplied root. It gives the model control of the confinement boundary.
    • Chosen: Server-configured work tree. It keeps the boundary outside the model and matches SECURITY.md rule 11.
    • Rejected: OS temporary directory. It does not confine reads and is not stable for every tool.
  • How should the schema audit find unconfined path parameters?: Iterate every role table, read each tool's published schema, match path-like text parameter names, and require a confinement registry entry. (best practice) [sources: src/devops_cli/ai/mcp/generator.py, SECURITY.md]
    • Rejected: Hard-code the three example tools. A new role tool or path option would escape the check.
    • Chosen: Audit all role-table schemas with a shared path-name pattern. It covers every current and future role tool.
    • Rejected: Trust tool annotations only. An annotation is not enforcement and can be wrong.
  • Where should the confinement registry live?: Extend _PATH_PARAM_RESTRICTIONS in generator.py with tool and parameter entries. SECURITY.md names it as the schema gate. (best practice) [sources: SECURITY.md, src/devops_cli/ai/mcp/generator.py]
    • Rejected: New registry in roles.py. It duplicates the existing schema gate.
    • Chosen: Extend _PATH_PARAM_RESTRICTIONS. It keeps one central place for published path options.
    • Rejected: Per-tool ad hoc checks. It is easy to miss a new role tool.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#3219

Activity

  1. added
    type/bug
    scope/mcp
    status/new
    value/high
    effort/medium
    on Nov 2, 2026
  2. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/mcp. The (mcp) scope of the title gives the scope.
    • Priority: P1-High. A model over a network transport can read or write files outside the server work tree, which is a security gap.
    • Value: High. Prevents unauthorized file access and data exfiltration through MCP tool path arguments.
    • Effort: Medium. Requires editing multiple tool schemas and adding a test that scans every role table for unconfined path parameters.
    • Related: fix(mcp): pr_check_readiness is read-only in the exposure table but can resolve threads #3235, which asks for a different change. Both are MCP tool safety defects found during the role-scoped server work (#3219); #3235 fixes a mislabeled read-only flag, this candidate confines path parameters in read-only tools.
  3. added
    priority/p1-high
    status/ready
    and removed
    status/new
    on Nov 2, 2026
  4. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at ff9ad06 (see proposed design in issue body).

  5. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Staged: branch fix/3236-read-only-tools-take-paths-that, draft pull request #3248. The pull request plans the item and closes no issue.

    The task groups, with the tokens of the inputs of each step, for a budget of 40000 tokens:

    1. Add the confinement registry and the resolver: 16153 tokens
    2. Confine a kept path argument in the tool function: 18713 tokens
    3. Publish no path option that the server can choose: 21002 tokens
    4. Audit the published schema of every exposed tool: 17648 tokens
    5. Document the published options of the three tools: 15099 tokens

    The plan run made 2 model request(s), and used 113585 input tokens and 10650 output tokens. The model made no tool call.

    A model review of the plan found these points. They stop no draft, and a person judges them:

    • other at group 4 and group 1: The audit covers every tool of CONST_MCP_EXPOSURE_TABLE, but the plan registers only gh_pages_verify. Other exposed tools such as ai_read, ai_ast_parse and review_path likely have path-like text parameters. The audit would fail on them, or the plan leaves them unconfined, and no task covers them. Evidence: "Register gh_pages_verify and its root_dir there."
  6. added 5 commits that reference this issue on Nov 2, 2026
  7. added
    status/planned
    and removed
    status/ready
    on Nov 2, 2026
  8. added 3 commits that reference this issue on Nov 3, 2026
  9. dan-petty commented on Nov 4, 2026

    @dan-petty
    OwnerAuthor

    Merged PR #3467 delivers the work of this item under #3300, so no job must run the plan of this item, and this item closes as not planned. The PR merged at 2026-11-04T15:28:32Z as commit e5df741e. Issue #3300 closed with it at 15:28:34Z.

    Proof at e5df741e:

    • Criterion 1: src/devops_cli/ai/mcp/path_confinement.py holds PATH_CONFINEMENTS with ai_ast_graph.target_dir and gh_pages_verify.root_dir, and NOT_A_FILE_PATH with security_intel_network. The change to generator.py drops output_path of ai_ast_graph and output of k8s_security_stream.
    • Criterion 2: tests/ai/mcp/test_path_confinement.py audits the whole catalogue, and that catalogue holds every role tool. It also holds test_a_traversal_value_is_refused_before_a_command_runs, test_an_absolute_path_outside_the_work_tree_is_refused and test_the_confinement_root_is_not_a_tool_argument.

    The change folder needs a cleanup. openspec/changes/3236-read-only-tools-take-paths-that/ is still on main with unticked tasks, and its task 1.2 writes a module that main now holds. Remove the folder in one pull request, after this close. Do not archive it, because its spec delta adds other requirements to mcp-tool-path-confinement, which main already holds.

    One test detail of the plan did not transfer: task 3.1 asks for a synthetic tool with output_path that fails the audit. The test file holds no such case. #3480 holds this need: its first criterion is a test where the audit fails on a fixture tool with a Path option.

    #3299, #3301, #3302, #3304 and #3318 cite this plan through PR #3248, which stays readable.

  10. removed
    status/planned
    on Nov 4, 2026
  11. added 2 commits that reference this issue on Nov 7, 2026
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

    effort/mediumpriority/p1-highscope/mcptype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions