MCPTox 模型上下文协议安全测试平台

MCPTox 是一个用于评估模型上下文协议(MCP)安全性的综合测试平台,支持语义投毒、上下文感染、隐私中间件绕过及智能体间注入等多种攻击场景的模拟与分析。

  • by luoji12103
  • Python
  • 本地部署
  • 2 星标
  • 更新于
在 GitHub 查看 luoji12103/MCP-Tox

使用说明

MCPTox: Model Context Protocol Security Testbed

This repository contains the source code and experimental framework for the paper "The Capability Paradox: Why Advanced Agents Are More Vulnerable to Protocol-Level Attacks" (CVPR 2025).

Overview

MCPTox is a comprehensive testbed designed to evaluate the security of the Model Context Protocol (MCP). It simulates various attack surfaces including:

  • RQ1: Semantic Poisoning (Mobile Agent scenarios)
  • RQ2: Contextual Infection (Code Agent scenarios)
  • RQ3: Privacy Middleware Bypass (Privacy leakage analysis)
  • RQ4: Agent-to-Agent Injection (Cascading trust failures)

Project Structure

opencode/
├── config/
│   └── experiment_config.yaml    # Configuration for models and scenarios
├── src/
│   ├── simulation.py             # Main entry point
│   ├── rq1_mobile_agent.py       # RQ1 implementation
│   ├── rq2_code_agent.py         # RQ2 implementation
│   ├── rq3_privacy_middleware.py # RQ3 implementation
│   ├── rq4_a2a_injection.py      # RQ4 implementation
│   ├── tools.py                  # Mock MCP tools
│   └── visualization.py          # Plotting utilities
├── requirements.txt              # Python dependencies
└── README.md                     # This file

Installation

  1. Ensure you have Python 3.9+ installed.
  2. Install dependencies:
    pip install -r requirements.txt
    

Usage

To run the full suite of experiments:

python -m src.simulation

Optional Flags

  • Run specific experiments:
    python -m src.simulation --rq1  # Run only RQ1
    python -m src.simulation --rq2  # Run only RQ2
    python -m src.simulation --rq3  # Run only RQ3
    python -m src.simulation --rq4  # Run only RQ4
    
  • Skip visualization generation:
    python -m src.simulation --no-viz
    

Configuration

Modify config/experiment_config.yaml to adjust:

  • Model parameters (temperature, max_tokens)
  • Number of trials per experiment
  • Attack payloads and scenarios

License

MIT License. See LICENSE file for details.