T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/evaluation.py:117
- Finding
- Unredacted MCP Tool Results Are Transmitted to an External Model API<![CDATA[ ## Vulnerability Details **File Location**: `scripts/evaluation.py:117-140` **Vulnerability Type**: Sensitive-data disclosure to an external service **Risk Level**: High ### Vulnerable Code ```python 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 converts every MCP tool result into a string and places it directly into the conversation sent through `client.messages.create`. No field allowlist, credential detector, redaction process, output-size restriction, data-classification policy, or user confirmation is applied. MCP tools may return email addresses, messages, files, internal system records, access tokens, API responses, or other confidential information. A malicious or compromised MCP server can also deliberately place sensitive information in its tool result. Exception handling additionally forwards exception text and a complete local traceback, potentially exposing local paths, implementation details, and contextual data. Sending tool output to an external model is related to the declared evaluation functionality, but transmitting arbitrary, unfiltered output ...[truncated 1250 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Clearly disclose that questions and MCP tool results will be transmitted to Anthropic before evaluation begins. 2. Require explicit user consent for external processing, especially when evaluating production-connected MCP servers. 3. Introduce configurable redaction for: - Authorization headers and bearer tokens - API keys and passwords - Cookies and session identifiers - Private keys - Email addresses and other regulated personal information 4. Prefer an allowlist of fields required by each evaluation rather than forwarding entire tool responses. 5. Impose strict response-size and tool-call limits. 6. Do not transmit full tracebacks. Log sanitized diagnostics locally and return a generic error to the model. 7. Provide an offline or local-model mode for sensitive environments. 8. Add a policy option that blocks external transmission when tool results contain classified or credential-like values. 9. Document the external provider's retention and privacy implications. ]]>
