T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/evaluation.py:116
- Finding
- Unredacted MCP Tool Results and Exception Tracebacks Are Sent to Anthropic<![CDATA[ ## Vulnerability Details **File Location**: `scripts/evaluation.py:116-144` **Vulnerability Type**: External transmission of potentially sensitive tool output **Risk Level**: Medium ### Vulnerable Code ```python tool_start_ts = time.time() try: tool_result = await connection.call_tool(tool_name, tool_input) tool_response = json.dumps(tool_result) if isinstance(tool_result, (dict, list)) else str(tool_result) except Exception as e: tool_response = f"Error executing tool {tool_name}: {str(e)}\n" tool_response += traceback.format_exc() tool_duration = time.time() - tool_start_ts if tool_name not in tool_metrics: tool_metrics[tool_name] = {"count": 0, "durations": []} tool_metrics[tool_name]["count"] += 1 tool_metrics[tool_name]["durations"].append(tool_duration) messages.append({ "role": "user", "content": [{ "type": "tool_result", "tool_use_id": tool_use.id, "content": tool_response, }] }) response = await asyncio.to_thread( client.messages.create, model=model, max_tokens=4096, system=EVALUATION_PROMPT, messages=messages, tools=tools, ) ``` ### Technical Analysis The evaluation harness serializes complete MCP tool results and places them into the conversation sent to the Anthropic API. There is no sensitive-data classification, secret redaction, output-size restriction, or per-result confirmation before transmission. An evaluated MCP server may return private repository content, customer information, internal documents, access tokens, API keys, or other confidential records. If a tool raises an exception, the harness additionally transmits `str(e)` and a complete Python traceback. Exception messages and tracebacks may contain local file paths, req ...[truncated 1875 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Clearly disclose before execution that evaluation questions, tool schemas, tool inputs, tool outputs, and model responses are sent to Anthropic. 2. Require explicit opt-in before transmitting MCP tool results to an external model provider. 3. Redact authorization headers, API keys, bearer tokens, cookies, passwords, private keys, and other common secret formats. 4. Do not send full tracebacks to the model. Log sanitized diagnostics locally and return a generic tool error to the conversation. 5. Apply strict response-size and token limits before adding tool output to `messages`. 6. Add configurable field allowlists or data-classification policies for tools that may return private data. 7. Update the system prompt to state that tool results are untrusted data and that instructions contained inside tool output must not be followed. 8. Provide a local or offline model option for evaluations involving confidential data. 9. Restrict evaluation runs to verified read-only tools rather than relying solely on MCP annotation hints. ]]>
