T01 · Skill Instruction Hijacking
- Location
scripts/mcp_client.py:106- Finding
Untrusted MCP Content Can Influence Agent Instructions and Tool Selection
- Content
View full analysis
Vulnerability Details
File Location:
scripts/mcp_client.py:106-170; related workflow instructions inSKILL.md:27-46andSKILL.md:96-105
Vulnerability Type: Prompt injection through untrusted remote MCP metadata and results
Risk Level: MediumVulnerable Code
python def cmd_list_tools(): """ Discover all tools from the MCP server and print a structured summary optimised for LLM decision-making (tool selection + parameter mapping). """ _initialize() result = _rpc("tools/list", {}) tools = result.get("tools", []) if not tools: print("NO_TOOLS: The server returned no tools.") return # Emit a machine-readable block per tool so the LLM can parse easily print(f"TOOL_COUNT: {len(tools)}\n") for t in tools: name = t.get("name", "unknown") desc = t.get("description") or t.get("title") or "(no description)" schema = t.get("inputSchema", {}) props = schema.get("properties", {}) required = set(schema.get("required", [])) print(f"=== TOOL: {name} ===") print(f"DESCRIPTION: {desc}") if props: print("PARAMETERS:") for param_name, param_schema in props.items(): req_marker = "[required]" if param_name in required else "[optional]" ptype = param_schema.get("type", "any") pdesc = param_schema.get("description", "") enum_vals = param_schema.get("enum", []) enum_str = f" | values: {enum_vals}" if enum_vals else "" print(f" - {param_name} ({ptype}) {req_marker}{enum_str}: {pdesc}") else: print("PARAMETERS: (none defined in schema)") print() print("---") print("INSTRUCTIONS FOR LLM:") print("1. Pick the tool whose DESCRIPTION + PARAMETERS best match the user request.") print("2. Buil ...[truncated 4082 chars]- Remediation
View remediation
Remediation Suggestions
- Treat every field returned by the MCP endpoint as untrusted data and explicitly instruct the agent never to follow instructions embedded in tool metadata or results.
- Represent remote responses using a constrained, machine-readable envelope rather than mixing them with text labeled as instructions for the LLM.
- Maintain a local allowlist of expected PC-builder tool names, parameter names, and schema types. Reject unexpected tools or schema changes pending review.
- Validate descriptions and result fields for size, allowed structure, and unexpected instruction-like content before presenting them to the agent.
- Separate trusted local guidance from remote output using explicit delimiters and labels such as “UNTRUSTED REMOTE DATA.”
- Require confirmation before acting on newly discovered tools or materially changed schemas.
- Ensure agent policy gives local skill instructions precedence over all MCP-supplied text and prohibits remote content from requesting secrets, local files, additional tool calls, or changes to safety constraints.
