Repository navigation
Description
Problem Description
The MCP tool ai_prewarm publishes the option url: "Specific Ollama node URL to target instead of all candidate nodes". The model that calls the tool gives it. _preload_single_ollama_url in src/devops_cli/ai/client/ollama.py sends POST {url}/api/generate with a JSON body. The client dials at the configured level, which admits loopback without ai.allow_private_network.
The URL can end in ?x=. Then the path of the request is the path that the caller wrote, and /api/generate is only the value of the query. So a model can send a POST request to any path of any loopback service of the host. The tool tells the model whether the answer was HTTP 200.
The cause is the same as in #2480: a URL from the caller is used as configuration.
Reproduction Steps
- Leave
ai.allow_private_networkunset. - In a test, install
record_connectsfromtests/web_fakes.pywith a canned HTTP 200 answer. - Call the MCP tool
ai_prewarmwithurl="http://127.0.0.1:8200/v1/sys/seal-status?x=". - Read
recorder.dialled,recorder.writtenand the tool reply.
Expected vs Actual Behavior
Expected: the tool prewarms only the configured Ollama servers. A URL option stays for a person at the command line.
Actual: on main at a3eb41f4, the client dialled 127.0.0.1:8200 and wrote POST /v1/sys/seal-status?x=/api/generate. The tool replied "confirmed HTTP 200".
Environment Diagnostics
- DevOps CLI Version: 0.15.1 (
mainata3eb41f4) - Python Version: 3.14.10
- OS & Architecture: Linux x86_64
- Execution Environment: DevContainer
Logs, Traces, or Terminal Output
recorder.dialled -> [('127.0.0.1', 8200)]
recorder.written -> [b'POST /v1/sys/seal-status?x=/api/generate HTTP/1.1\r\nHost: 127.0.0.1:8200\r\n...']
reply -> confirmed HTTP 200 (keep_alive=1h)
Pre-Submission Checklist
- I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
- I have checked existing issues and pull requests to ensure this is not a duplicate.
Proposed design
Problem statement
The MCP tool ai_prewarm exposes a url option to the model. A model-supplied URL with a query string causes the code to POST to an arbitrary path on a loopback service. This is a server-side request forgery flaw. The fix removes the url option from the tool so the model cannot supply a URL.
Acceptance criteria
Requirement: No url option in ai_prewarm schema
The ai_prewarm MCP tool input schema SHALL NOT contain a url option.
Scenario: Model calls ai_prewarm with a url field
- WHEN A model calls ai_prewarm and the input includes a url key
- THEN The tool rejects the call or ignores the url key and prewarms only the configured Ollama servers
Requirement: Prewarm uses only configured URLs
The ai_prewarm tool SHALL prewarm only the Ollama servers listed in the configured ai.ollama_urls.
Scenario: Prewarm with configured URLs
- WHEN A model calls ai_prewarm with no url argument and ai.ollama_urls holds two servers
- THEN The tool sends POST /api/generate to both configured servers and to no other address
Requirement: No loopback POST to arbitrary path
A model-supplied value SHALL NOT cause a POST request to a path other than /api/generate on a loopback address.
Scenario: Model supplies a URL with a query string
- WHEN A test installs record_connects and calls the ai_prewarm code path with url set to
http://127.0.0.1:8200/v1/sys/seal-status?x= - THEN The recorder shows no dial to 127.0.0.1:8200 and no written bytes contain /v1/sys/seal-status
Existing Tool Considered
No external library covers removing a parameter from the project's own MCP tool schema. The change removes one parameter from the tool input schema and updates the code path. Cost: about 300 tokens to build (remove the parameter, update the schema, update tests), about 50 tokens to keep (sync docs/MCP_TOOLS.md), about 100 tokens to fix (edge cases in tests). Total about 450 tokens, under 10 minutes elapsed.
Key questions
- What is the fix for the ai_prewarm SSRF?: Remove the url option from the ai_prewarm MCP tool input schema. The tool then prewarms only the configured Ollama servers. This mirrors the pattern already delivered in fix(ai): a url that an mcp tool gives to devops ai gateway status, routes or probe-backend reaches loopback and gets the ai api key #2480 for the gateway tools. (best practice) [sources: openspec/changes/archive/2026-10-29-2480-mcp-gateway-url-override/design.md, openspec/changes/archive/2026-10-29-2480-mcp-gateway-url-override/tasks.md]
- Chosen: Remove the url option from the tool schema. The model cannot supply a URL, so it cannot direct a POST to an arbitrary loopback path. This is the pattern fix(ai): a url that an mcp tool gives to devops ai gateway status, routes or probe-backend reaches loopback and gets the ai api key #2480 already delivered for the gateway tools.
- Rejected: Validate the URL to allow only /api/generate paths. A path allow-list is an escape: a new path or a query-string trick bypasses it. The root cause is that a model-supplied URL is used as configuration.
- Rejected: Require ai.allow_private_network for loopback. The default egress level already admits loopback. Requiring an opt-in flag does not stop a model from probing configured private services, and it changes the behavior of the CLI path.
- Should the urls parameter on preload_models be removed entirely?: No. Keep the urls parameter on the internal method. A person at the command line may target a specific node. The MCP tool simply does not pass a model-supplied URL to it. (best practice) [sources: src/devops_cli/ai/client/ollama.py:95]
- Chosen: Keep urls on the internal method, remove from the tool schema. The CLI command line still needs to target a specific node. The MCP tool does not pass a model-supplied URL.
- Rejected: Remove urls from the internal method entirely. This breaks the CLI path that lets a person target one node. The issue says the URL option stays for a person at the command line.
- Is fix(ai): a url that an mcp tool gives to devops ai gateway status, routes or probe-backend reaches loopback and gets the ai api key #2480 a dependency of this issue?: No. fix(ai): a url that an mcp tool gives to devops ai gateway status, routes or probe-backend reaches loopback and gets the ai api key #2480 is already archived and delivered. It covers the gateway tools. This issue covers ai_prewarm. They share a pattern but are independent changes. [sources: openspec/changes/archive/2026-10-29-2480-mcp-gateway-url-override/tasks.md]
- Where is the ai_prewarm MCP tool schema defined?: The tool is documented in docs/MCP_TOOLS.md at line 418. The schema definition is in the MCP server code that registers the tool. The url option is the field to remove. [sources: docs/MCP_TOOLS.md:418]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Oct 29, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
A model-supplied URL lets the tool send POST to any loopback path, which is a server-side request forgery flaw.An active SSRF path lets a model reach any internal service on the host without ai.allow_private_network.It stops a model from probing or writing to arbitrary internal services on the host.The fix removes or restricts the url option on ai_prewarm, mirroring the pattern already described in #2480.Both remove a model-supplied URL from an AI MCP tool that reaches loopback. #2480 covers gateway tools; this candidate covers ai_prewarm.fix(ai): the MCP gateway tools take no URL and guard the AI key (#2640)
chore(main): release 0.16.6 (#2679)
devops-cli-service commentedon Oct 29, 2026
Status set to Ready at 8036e7e (see proposed design in issue body).
fix(ai): the MCP benchmark tool takes no server URL (#2707)