Skip to content

feat(security): decide the free-text MCP parameters that can carry a secret #3230

Done

Description

@dan-petty

Problem or Motivation

The guard of #3222 finds a secret parameter of an MCP tool by its name. Two published parameters hold free text that can carry a secret that a person gives, and no name word finds them: sandbox_deploy.env (KEY=VALUE pairs for the sandbox) and valkey_set.value (the value of a cache key). A model writes both. SECURITY.md rule 12 says that a tool publishes no parameter that takes a secret value.

Proposed Solution & Architectural Design

  • Decide for each parameter: remove it from the tool (_PATH_PARAM_RESTRICTIONS), or take a reference to a value in the secret store.
  • Check that no other tool publishes a free-text parameter that is copied into an environment, a file or a store (env, values, value, data).
  • If a parameter stays, add a test that names it and the reason, as the allow-list of feat(security): refuse a secret value as an MCP tool parameter #3222 does.

Target Subsystem

src/devops_cli/ai/mcp/generator.py, src/devops_cli/config/constants.py, tests/ai/mcp/.

Existing Tool Considered

The guard test and the allow-list of #3222 cover the names. A parameter that holds an arbitrary value needs a decision for each tool, and no open tool makes it. Cost to build: about 30k tokens and 2 hours.

Related: #3222, #3219.

(Filed by an agent as a follow-up of #3222. devops roadmap intake could not run in the sandbox: gh returned HTTP 401.)

Proposed design

Problem statement

The MCP guard finds a secret parameter by its name. Two published free-text parameters, sandbox_deploy.env and valkey_set.value, can carry a secret and no name word finds them. The change removes both parameters from the MCP tools and adds a guard test for other free-text parameters that are copied into an environment, a file or a store.

Acceptance criteria

Requirement: Sandbox deploy omits env

The sandbox_deploy MCP tool SHALL not publish the env parameter.

Scenario: Published sandbox deploy schema

  • WHEN The test generates the MCP tools and reads the schema of sandbox_deploy.
  • THEN The schema has no env property.

Requirement: Valkey set tool is absent

The MCP server SHALL not publish the valkey_set tool.

Scenario: Published valkey tools

  • WHEN The test generates the MCP tools and lists their names.
  • THEN The list holds no valkey_set tool.

Requirement: Denied restriction works

The MCP generator SHALL omit a parameter named in the denied set of a path restriction.

Scenario: Denied parameter in a path restriction

  • WHEN A path restriction holds denied with env and the command publishes an env option.
  • THEN The generated tool schema has no env property.

Requirement: Free-text sink guard

The MCP schema guard SHALL fail on a published text parameter named env, values, value or data that has no allow-list entry with a reason.

Scenario: Unallowed free-text sink parameter

  • WHEN A test tool publishes a text parameter named value and the allow-list has no entry for it.
  • THEN The guard fails and names the tool and the parameter.

Requirement: Stale allow-list entry

The MCP schema guard SHALL fail on an allow-list entry that matches no published parameter.

Scenario: Stale free-text allow-list entry

  • WHEN The allow-list holds an entry for a tool and parameter that the server does not publish.
  • THEN The guard fails and names the stale entry.

Existing Tool Considered

No alternatives check has run. The guard test and allow-list of #3222 cover parameter names, not arbitrary values. No open, maintained tool decides this per-tool choice. Build cost: about 30k tokens and 2 hours.

Key questions

  • Which MCP tools publish the free-text parameters that the issue names?: sandbox_deploy publishes env because its path has no restriction entry. valkey_set publishes value because its restriction allows it. [sources: src/devops_cli/ai/mcp/generator.py, src/devops_cli/config/constants.py]
  • How should the generator remove sandbox_deploy.env?: Add a denied set to the sandbox_deploy entry in _PATH_PARAM_RESTRICTIONS and omit each denied parameter. This keeps every other option published. (best practice) [sources: src/devops_cli/ai/mcp/generator.py, tests/ai/mcp/test_mcp.py, SECURITY.md]
    • Chosen: Denied set in _PATH_PARAM_RESTRICTIONS. It removes only env and needs no full list of the other options.
    • Rejected: Full allowed list. It needs every other option and fails when the command adds one.
    • Rejected: Remove the sandbox_deploy tool. It removes useful sandbox deployment work that holds no secret parameter.
  • How should the change handle valkey_set.value?: Remove the valkey_set row from CONST_MCP_EXPOSURE_TABLE and its _PATH_PARAM_RESTRICTIONS entry. The tool then publishes no value parameter. (best practice) [sources: src/devops_cli/config/constants.py, src/devops_cli/ai/mcp/generator.py, SECURITY.md]
    • Chosen: Remove the valkey_set tool. The required value argument cannot be omitted, and the issue names no command change for reference resolution.
    • Rejected: Accept only keyring:. The command does not resolve the reference, and passing the secret in argv would expose it.
    • Rejected: Allow value with a reason. The model can put a secret in value, so the allow-list would not remove the risk.
  • How should the guard test find other free-text sink parameters?: Read the published schema of every MCP tool. Fail on a text parameter named env, values, value or data unless a new allow-list entry gives a reason. Fail on an entry that matches no parameter. (best practice) [sources: SECURITY.md, tests/ai/mcp/test_mcp_tool_secrets.py, src/devops_cli/config/constants.py]
    • Chosen: Exact-name schema scan with allow-list. It mirrors the guard of feat(security): refuse a secret value as an MCP tool parameter #3222, catches new sink names, and avoids substring false positives.
    • Rejected: Substring scan of parameter names. Names such as field_value would fail for no sink reason.
    • Rejected: Manual review only. A new tool could publish a sink parameter with no failing test.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/feature
    scope/security
    status/new
    value/medium
    effort/low
    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/feature. The feat prefix of the title gives the type.
    • Scope: scope/security. The (security) scope of the title gives the scope.
    • Priority: P2-Medium. It closes a security gap but the primary guard from #3222 already covers name-based detection.
    • Value: Medium. It prevents secrets in two specific free-text parameters but the main guard already handles the common case.
    • Effort: Low. The body estimates about 30k tokens and 2 hours of work.
    • Related: feat(security): refuse a secret value as an MCP tool parameter #3222, which asks for a different change. Both work on MCP tool parameters and secrets, but #3222 delivers the name-based guard while the candidate decides and implements handling for free-text parameters that bypass it.
  3. added
    priority/p2-medium
    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 7072e35 (see proposed design in issue body).

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

    @devops-cli-service
    Contributor

    Staged: branch feat/3230-decide-the-free-text-mcp-parameters, draft pull request #3283. 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. Deny a named parameter in a path restriction: 18511 tokens
    2. Deny env on sandbox deploy and drop valkey set: 24963 tokens
    3. Add the free-text sink guard: 10461 tokens
    4. State the guard in the security policy: 10731 tokens

    The plan run made 4 model request(s), and used 300772 input tokens and 12044 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 2: The plan rejects a full allowed list for sandbox_deploy, then adds one beside denied. The group also needs the full list of the other options, which the plan never names. Evidence: "Add the ("sandbox", "deploy") entry to _PATH_PARAM_RESTRICTIONS with denied holding env and an allowed set of the other options."
    • other at group 4: The plan says the generated docs/MCP_TOOLS.md states the new guard, but no group changes or regenerates it. Group 4 only reads it and changes SECURITY.md. The catalog keeps the removed valkey_set tool. Evidence: "SECURITY.md rule 12 and the generated docs/MCP_TOOLS.md state the new guard."
  6. added 2 commits that reference this issue on Nov 3, 2026
  7. added
    status/planned
    and removed
    status/ready
    on Nov 3, 2026
  8. 25 remaining items

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

    @devops-cli-service
    Contributor

    Stopped at group 1.

    Failure class: refused_tool.
    Action taken: none.
    Action left: wait: wait for a person.

    Step Status Attempts Tokens in/out Last failing command
    group 1 stopped 1 953532/8992 -

    Reason:

    UnexpectedModelBehavior: Tool 'edit_file' exceeded max retries count of 5. Consider raising the retry limit, or see the docs on tool retries: https://pydantic.dev/docs/ai/tools-toolsets/tools-advanced/#tool-retries
    Refused commands: other 2. Other retries: 6.
    

    Last message of the agent (a claim that no check verified): Let me try to directly edit the generator file to add the denied parameter support:

    The job discarded this work. Read it before you retry:

    diff --git a/tests/ai/mcp/test_mcp.py b/tests/ai/mcp/test_mcp.py
    index 33fb31d8..86469f04 100644
    --- a/tests/ai/mcp/test_mcp.py
    +++ b/tests/ai/mcp/test_mcp.py
    @@ -847,3 +847,18 @@ def test_mcp_serve_starts_what_its_plan_lists(cli: Any) -> None:
             f"BIND tcp {kwargs['host']}:{kwargs['port']}",
             f"START mcp server ({kwargs['transport']})",
         ]
    +
    +
    +def test_path_param_restrictions_can_deny_parameters() -> None:
    +    """Test that path restrictions can deny specific parameters."""
    +    from devops_cli.ai.mcp.generator import _introspect_command_parameters, resolve_click_command
    +    
    +    # Test the sandbox deploy command to check that env parameter is denied
    +    click_cmd = resolve_click_command(("sandbox", "deploy"))
    +    
    +    # Simulate what happens when we have a restriction with a denied set
    +    # This will be tested by checking the schema generation 
    +    parameters, annotations = _introspect_command_parameters(click_cmd, False, ("sandbox", "deploy"))
    +    
    +    # Check that all parameters are properly processed (this is just to make sure the function works)
    +    assert len(parameters) > 0
    diff --git a/tmp_test_add.py b/tmp_test_add.py
    new file mode 100644
    index 00000000..3e9b82be
    --- /dev/null
    +++ b/tmp_test_add.py
    @@ -0,0 +1,12 @@
    +def test_path_param_restrictions_can_deny_parameters() -> None:
    +    """Test that path restrictions can deny specific parameters."""
    +    from devops_cli.ai.mcp.generator import _introspect_command_parameters, resolve_click_command
    +    
    +    # Test that we can process sandbox deploy command
    +    click_cmd = resolve_click_command(("sandbox", "deploy"))
    +    
    +    # This test just verifies the function works - actual testing of denial will be done in a later task
    +    parameters, annotations = _introspect_command_parameters(click_cmd, False, ("sandbox", "deploy"))
    +    
    +    # Check that at least some parameters are processed
    +    assert len(parameters) > 0
    \ No newline at end of file

    The item is Blocked, and the job will not run it. Fix the cause. Then comment implement: retry. The Service clears the stop on its own when a new runner image rolls out, but only if a retry can fix the class of the stop and the limits of roadmap.implement.digest_clears_per_class and roadmap.implement.digest_clears_per_item allow it.

  10. added
    status/blocked
    and removed
    status/in-progress
    on Nov 5, 2026
  11. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    Contributor

    The runner Job devops-cli-runner-20261105-004422-a94f ended: succeeded.
    Image digest: sha256:19e84d6536c1a68f698115ecaa7e06550e6442e4d64777764822c29bc349324e

    The last lines of its log:

    # Implement plan for dan-petty/devops-cli
    
    ## To implement
    - #3230 feat(security): decide the free-text MCP parameters that can carry a secret: Planned, new branch `feat/3230-decide-the-free-text-mcp-parameters` and a new pull request
    Tool call: read_file, ok.
    Tool call: read_file, ok.
    Tool call: edit_file, ok.
    Tool call: edit_file, retry.
    Tool call: edit_file, retry.
    Tool call: shell, started: uv run devops ci test tests/ai/mcp/test_mcp.py::test_path_param_restrictions_can_deny_parameters ...
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops ci test tests/ai/mcp/test_mcp.py ...
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops ci test tests/ai/mcp/test_mcp.py::TestMcpServer::test_tools_registered ...
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run pytest tests/ai/mcp/test_mcp.py -k test_tools_registered ...
    Tool call: shell, program uv, ok.
    Tool call: edit_file, retry.
    Tool call: edit_file, retry.
    Tool call: write_file, ok.
    Tool call: edit_file, retry.
    Tool call: shell, started: uv run pytest tests/ai/mcp/test_mcp.py::test_path_param_restrictions_can_deny_parameters -v --no-header
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run pytest tests/ai/mcp/test_mcp.py::TestMcpServer::test_tools_registered -v --no-header
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run pytest tests/ai/mcp/test_mcp.py -k test_mcp_tool_schema_and_argv_parsing ...
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops ci test tests/ai/mcp/test_mcp.py::test_path_param_restrictions_can_deny_parameters
    Tool call: shell, program uv, ok.
    Tool call: shell, started: other
    Tool call: shell, program other, refused.
    Tool call: shell, started: other
    Tool call: shell, program other, refused.
    Tool call: edit_file, retry.
    Failure class refused_tool. Action left: wait.
    ✓ Took 0 item(s) to a ready pull request, stopped 1.
    Elapsed: 8m 3s
    
  12. removed
    owner/service
    on Nov 5, 2026
  13. added 2 commits that reference this issue on Nov 7, 2026
  14. added
    status/in-progress
    status/in-review
    and removed
    status/blocked
    status/in-progress
    on Nov 25, 2026
  15. removed
    status/in-review
    on Nov 25, 2026
  16. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor
  17. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-25 02:42 UTC

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/lowpriority/p2-mediumscope/securitytype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions