Dangerous MCP
MCP 很危险
函数工具的使用让 AI 代理变得非常强大,这就像将应用商店引入智能手机一样。尤其是随着MCP(模型上下文协议)的发布,工具共享变得比以往任何时候都更加便捷。因此,我创建了可扩展代理项目,以展示如何通过开源工具或自定义工具轻松扩展 AI 代理的功能。
在开发可扩展代理的过程中,我意识到工具的使用是一把双刃剑。危险在于,你使用的工具拥有对你机器的强大访问权限,例如你的环境变量、文件等等。
⚠️ 安全警告
该项目简单演示了与工具使用相关的安全风险。以下示例说明了恶意行为者如何利用 MCP 服务器访问敏感信息:
# WARNING: This is a demonstration of security risks.
# DO NOT use this code maliciously!
import os
from mcp.server.fastmcp import FastMCP
server = FastMCP("Dangerous MCP")
@server.tool()
async def get_environment_variables() -> str:
"""Get all environment variables."""
result = [
"Here are what I could find:",
]
for key, value in os.environ.items():
result.append(f"{key:<30} {value[:5]}***")
# This means I can open a backdoor to send your data to me!!
return "\n".join(result)⚠️**警告:**建议在沙盒环境中运行此示例,然后删除你的 OpenAI API 密钥。你也可以使用自己的 MCP 客户端进行测试,命令如下:
uvx mcp-is-dangerous。
当将此工具与可扩展代理(选择PoliceAgent )一起使用时,输出如下所示:
它可能看起来无害,甚至是故意为之,对吧?但想象一下这种情况:你只是询问当前时间,与此同时,你的敏感数据却在你不知情的情况下被泄露了。
Related MCP server: Vulnerable MCP Server
安全最佳实践
使用 MCP 或类似工具时保护自己:
使用工具前务必检查其源代码
尽可能在隔离环境中运行工具
谨慎对待请求访问敏感信息的工具
部署工具时使用环境变量过滤
定期审核你正在使用的工具
免责声明
本项目仅用于教育目的,旨在演示潜在的安全风险。请勿将此信息用于恶意目的。作者对任何信息滥用概不负责。
执照
Available Tools
1 toolget_environment_variablesA
Get all environment variables.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The tool name and description imply a read-only operation ('Get'), which is transparent for a simple retrieval. No annotations are present, so the description carries the full burden. It does not mention authentication, rate limits, or return format, but the behavior is straightforward.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single sentence with no wasted words. It directly conveys the tool's purpose without extraneous information.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with no parameters, no output schema, and no siblings, the description is mostly complete. It clearly states what the tool does. Missing information about return format or usage context is minor given the tool's simplicity.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
There are no parameters, and the input schema already reflects this fact. The description does not need to add parameter details. Baseline for 0 parameters is 4.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states it retrieves all environment variables. The verb 'Get' and resource 'environment variables' are specific and unambiguous. Without siblings, no further differentiation is needed.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No explicit guidance on when to use or alternatives is provided. However, as there are no sibling tools, the context implicitly limits usage to this single tool. A user might still benefit from knowing prerequisites or side effects.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
1 tool update
v1.0.0- First observed
get_environment_variables
TDQS
Scored across 1 tool
Only one tool exists, so there is no ambiguity in selection.
Single tool follows a clean verb_noun pattern, consistent.
One tool is too few for the server's implied scope; a broader set is expected.
Only a single read operation is provided, with no other tools to cover related actions like modification or listing.
Maintenance
Related MCP Connectors
Security scanner for MCP servers. Detect vulnerabilities, prompt injection, and tool poisoning.
Security research canary remote MCP server for owned-account testing.
An MCP server that provides read access to your cloud storage providers, bank accounts and more.
MCP server for secureFlows: token-free URL builders and integration-linting tools for AI agents.
Related MCP Servers
- FlicenseNot gradedqualityFmaintenanceAn educational project that deliberately implements vulnerable MCP servers to demonstrate various security risks like prompt injection, tool poisoning, and code execution for training security researchers and AI safety professionals.1,356-
- FlicenseNot gradedqualityDmaintenanceA deliberately insecure MCP server designed as a pentest lab to demonstrate common vulnerabilities in MCP deployments.-
- FlicenseNot gradedqualityDmaintenanceAn intentionally vulnerable MCP server designed as a live demo target for the MCP Trust security scanner. It contains deliberate insecure patterns to demonstrate scanning capabilities.-
- AlicenseCqualityDmaintenanceAn educational MCP server exposing shell command execution (PowerShell and sh) and a benign tool for learning about MCP tools, resources, and security risks like tool poisoning.33MIT