MCPGuard-Lab
MCPGuard-Lab
実際の mcp==2.0.0 SDK に基づく MCP ツール呼び出しセキュリティ実験プロジェクト。外部の大規模言語モデルや API キーに依存せず、決定論的なポリシーにより、ツールホワイトリスト、パラメータ検証、ファイル境界、SSRF 対策、機密操作の確認、出力のサニタイズ、ツール説明のポイズニング検出、JSONL 監査を実現し、回帰テストで防御が後の変更で壊れないことを確認します。
使用範囲:本プロジェクトはローカル実験、許可されたテスト、防御研究のみを目的としており、未承認のターゲットに対する攻撃機能は含まれません。
実装済み機能
MCP 2.0 stdio サーバーと実際のクライアント間の往復テスト。
6つのデモツール:安全な計算、ルートディレクトリ内のファイル読み取り、ノートクエリ、公開 URL リクエスト、ツールメタデータチェック、確認後のノート書き込み。
ツールホワイトリストと JSON Schema による厳格な検証、追加パラメータを拒否。
ファイルパスの正規化、絶対パス、ディレクトリトラバーサル、ルートディレクトリからの脱出を拒否。
URL プロトコル、ユーザー情報、ポート、DNS 解決結果のチェック、ループバック、プライベートネットワーク、リンクローカルなどの非パブリックアドレスを拒否。
書き込み操作
confirmed=trueのゲート。信頼できないツール出力に明示的なラベル付け;パスワード、トークン、API キー、Bearer 資格情報を再帰的にサニタイズ。
ツール名/説明における高リスクなプロンプトインジェクションシグナルの検出。
各決定を JSONL に記録:リクエスト ID、時刻、ツール、パラメータ、許可/拒否、理由、結果。
pytest ユニット/統合テストと再現可能な攻撃回帰レポート。
Related MCP server: meok-mcp-injection-scan-mcp
アーキテクチャ
MCP Client
│ stdio / MCP 2.0
▼
MCP Server ──► GuardedGateway ──► PolicyEngine
│ ├─ allowlist + schema
│ ├─ path boundary
│ ├─ URL / SSRF
│ └─ confirmation
├─ Tool handler
├─ untrusted labeling + redaction
└─ JSONL audit中核原則は「まず決定、次に実行、出力を浄化し、全過程を記録する」。プロンプトテキストが直接追加の権限を得ることはなく、権限はコード内のホワイトリストとポリシーに基づきます。
クイックスタート(Windows)
py -3.10 -m venv .venv
.\.venv\Scripts\python.exe -m pip install -e ".[dev]"
.\.venv\Scripts\python.exe -m pytest
.\.venv\Scripts\python.exe -m mcpguard.regression直接実行することもできます:
powershell -ExecutionPolicy Bypass -File .\scripts\verify.ps1レポートは以下に生成されます:
reports/regression-report.mdreports/regression-report.jsonreports/regression-audit.jsonl
MCP クライアント設定例
最初に pip install -e . を実行し、以下の構造を現在のリポジトリの絶対パスに置き換えてください:
{
"mcpServers": {
"mcpguard-lab": {
"command": "D:/path/to/mcpguard-lab/.venv/Scripts/python.exe",
"args": ["-m", "mcpguard.server"],
"env": {
"MCPGUARD_WORKSPACE": "D:/path/to/mcpguard-lab/fixtures/workspace",
"MCPGUARD_NOTES": "D:/path/to/mcpguard-lab/fixtures/workspace/notes",
"MCPGUARD_AUDIT": "D:/path/to/mcpguard-lab/reports/audit.jsonl"
}
}
}
}実際の限界
ツール説明のポイズニング検出は高シグナルルールレイヤーであり、人間によるレビューと固定ホワイトリストの代わりにはなりません。
confirmed=trueはローカル実験における明示的な確認ゲートです;本番環境では、ホスト UI/ID システムによって発行され、モデル自身が偽造できない確認資格情報を使用すべきです。URL ツールは現在リダイレクトを無効にしており、最初のホップでチェックを通過した後に内部ネットワークにジャンプするのを防ぎます;本番版では応答サイズ、コンテンツタイプ、出口ネットワークも制限すべきです。
信頼できないコンテンツへのラベル付けは「データが命令として扱われる」リスクを低減しますが、最終的なホストエージェントは依然として信頼境界に従う必要があります。
回帰データはリポジトリ内の固定テストケースのみを表し、すべてのプロンプトインジェクションやすべての MCP リスクをブロックできるわけではありません。
目次
src/mcpguard/ 核心实现
tests/ 单元测试与真实 MCP stdio 集成测试
fixtures/ 可公开的本地测试数据
reports/ 自动生成的测试和审计证据
scripts/verify.ps1 一键验证入口参考
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Flicense-qualityFmaintenanceAn 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,334
- AlicenseAqualityCmaintenanceScans MCP servers for prompt-injection, tool-poisoning, and SSRF vulnerabilities using 30+ canonical rules across 5 severity tiers, with optional signed safety reports for procurement.5MIT
- Alicense-qualityBmaintenanceAn MCP server that provides safeguard capabilities to protect against prompt injection and unsafe tool calls.6MIT
- Flicense-qualityBmaintenanceProvides real-time RCE, SSRF, and env leak interception for AI tool calls, with MCP server mode offering diagnostic and repair suggestions.
Related MCP Connectors
Security scanner for MCP servers. Detect vulnerabilities, prompt injection, and tool poisoning.
Scans MCP servers for tool poisoning, prompt injection and supply chain risks.
An MCP server for Arcjet - the runtime security platform that ships with your AI code.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Lc517/mcpguard-lab'
If you have feedback or need assistance with the MCP directory API, please join our Discord server