Skip to content

fix(k8s): a loki url that the mcp tool k8s_logs gets from the model reaches private addresses and returns the answer #2635

Description

@dan-petty

Problem Description

The MCP tool k8s_logs publishes the option loki_url ("Loki service endpoint"). The model that calls the tool gives it. execute_loki_query in src/devops_cli/k8s/logql.py builds f"{loki_url}/loki/api/v1/query_range", and sends a GET with params= through a client at the private level (EgressLevel.PRIVATE). That level admits each address but cloud metadata, whatever ai.allow_private_network says. httpx2 replaces the query of the URL with params. So the URL http://<host>/some/path?x= becomes GET /some/path?query=..., with any path that the caller names.

The tool returns the answer: a non-200 answer text goes into KubernetesLoggingError (resp.text.strip()), and a 200 answer is parsed as Loki JSON. Thus a model can send GET requests to the private and loopback services of the host and read their error texts. The cause is the same as in #2480: a URL from the caller is used as configuration.

Reproduction Steps

  1. Leave ai.allow_private_network unset.
  2. In a test, install record_connects from tests/web_fakes.py with a canned HTTP 500 answer whose body is a marker text.
  3. Call the MCP tool k8s_logs with query='{namespace="a"}' and loki_url="http://<host in a private range>:8200/v1/sys/seal-status?x=".
  4. Read recorder.dialled, recorder.written and the tool error.

Expected vs Actual Behavior

Expected: the tool queries only the configured Loki. A URL option stays for a person at the command line, or the tool dials a URL from the caller at the public level.

Actual: on main at a3eb41f4, the client dialled the private host on port 8200, wrote GET /v1/sys/seal-status?query=%7Bnamespace%3D%22a%22%7D&limit=100&since=1h&direction=BACKWARD, and the tool error held the marker text of the answer: Loki query failed with HTTP 500: <marker>.

Other MCP tools that publish a URL option and are not checked yet: ai_prewarm (url), ai_benchmark (servers) and vault_status (vault_addr).

Environment Diagnostics

  • DevOps CLI Version: 0.15.1 (main at a3eb41f4)
  • Python Version: 3.14.10
  • OS & Architecture: Linux x86_64
  • Execution Environment: DevContainer

Logs, Traces, or Terminal Output

ToolError: Command exited with status 1:
Loki query failed with HTTP 500: <marker>
recorder.dialled -> [('<private address>', 8200)]
recorder.written -> [b'GET /v1/sys/seal-status?query=%7Bnamespace%3D%22a%22%7D&limit=100&since=1h&direction=BACKWARD HTTP/1.1\r\nHost: ...']

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.

Activity

  1. added
    source/agent
    type/security
    status/new
    value/high
    effort/medium
    on Oct 29, 2026
  2. dan-petty commented on Oct 29, 2026

    @dan-petty
    OwnerAuthor

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

    • Type: type/security. A model-supplied URL enables SSRF to private and loopback addresses and reads their responses.
    • Priority: P1-High. Confirmed SSRF in a model-callable tool with working reproduction steps.
    • Value: High. Exposes private service responses to an untrusted model caller.
    • Effort: Medium. Requires fixing the egress level or removing the URL option for k8s_logs, plus checking three other tools named in the body.
    • Related: 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, which asks for a different change. Both are MCP tools where a model-supplied URL bypasses egress controls to reach private addresses, but they target different tools and different services.
  3. added
    priority/p1-high
    on Oct 29, 2026
  4. added a commit that references this issue on Oct 29, 2026
    39fae85
  5. removed
    status/new
    on Oct 30, 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-highsource/agenttype/securityvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions