Skip to main content
Menu
Advisories

Unbounded list_resources response can exhaust server memory

GHSA-PCVX-MC89-XFJMPublished Updated GitHub

Description

The list_resources tool forwarded the caller's limit to the Kubernetes API with no server-side cap. An omitted limit (the default, 0) meant "no limit". A single call against a high-cardinality resource type therefore loaded the entire collection into the server's memory before the response was reduced to metadata. On a large enough cluster this could exhaust the process's memory and get it killed, denying service to all connected MCP clients.

list_resources is read-only and registered in the default configuration.

Details

  • HandleListResources (pkg/mcp/list_resources.go) read limit with a default of 0.
  • ListClusteredResources and ListNamespacedResources (pkg/k8s/client.go) only set ListOptions.Limit when limit > 0. Before pagination was added, they never set it at all.
  • The API server then returned every matching object in one response, which was fully deserialized into an UnstructuredList.
  • The list path had no cap on concurrent reads.

The pod-log path, hardened in GHSA-qw5r-ppcg-f8rj, has the same class of issue.

Impact

Denial of service through memory exhaustion of the mkp process. How much memory a call uses depends on how many objects of the targeted type the cluster holds, and how large they are. The caller can choose the resource type but cannot control the cluster's contents, so the outcome depends on the target environment. Confidentiality and integrity are not affected.

The server has no built-in authentication and, by default, listens on :8080 on all interfaces. Unless it is deployed behind an authenticating proxy, anyone who can reach that port can trigger this.

Patches

Fixed in v0.4.5:

  • Each list call fetches at most 500 items. Omitted, zero, negative and over-cap limit values are clamped to 500. Callers page through larger collections with the returned continue token.
  • At most 8 list reads run concurrently, and the limit is shared across impersonated clients.

Workarounds

Upgrade to v0.4.5. If you cannot upgrade:

  • Don't expose the server to untrusted clients: keep it on a loopback or private interface, or run it behind an authenticating proxy such as ToolHive.
  • Restrict the server's RBAC to the resource types it needs.
  • Set a memory limit so the process restarts cleanly rather than affecting its node.

Credits

Reported by zx (@manus-pi).

Affected versions

References

GitHub · StacklokLabs/mkp