$git clone https://github.com/harishsg993010/damn-vulnerable-MCP-serverA deliberately vulnerable implementation of the Model Context Protocol (MCP) for educational purposes.
| 1 | # Damn Vulnerable Model Context Protocol (DVMCP) |
| 2 | |
| 3 | A deliberately vulnerable implementation of the Model Context Protocol (MCP) for educational purposes. |
| 4 | |
| 5 | ## Overview |
| 6 | |
| 7 | The Damn Vulnerable Model Context Protocol (DVMCP) is an educational project designed to demonstrate security vulnerabilities in MCP implementations. It contains 10 challenges of increasing difficulty that showcase different types of vulnerabilities and attack vectors. |
| 8 | |
| 9 | This project is intended for security researchers, developers, and AI safety professionals to learn about potential security issues in MCP implementations and how to mitigate them. |
| 10 | |
| 11 | ## What is MCP? |
| 12 | |
| 13 | The [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) is a standardized protocol that allows applications to provide context for Large Language Models (LLMs) in a structured way. It separates the concerns of providing context from the actual LLM interaction, enabling applications to expose resources, tools, and prompts to LLMs. |
| 14 | |
| 15 | ## Recommended MCP Clients |
| 16 | |
| 17 | CLINE - VSCode Extension |
| 18 | Refer to this [Connecting to a Remote Server - Cline](https://docs.cline.bot/mcp/connecting-to-a-remote-server) for connecting Cline with MCP server |
| 19 | |
| 20 | ## Quick Start |
| 21 | |
| 22 | Once you have cloned the repository, run the following commands: |
| 23 | |
| 24 | ```sh |
| 25 | docker build -t dvmcp . |
| 26 | docker run -p 9001-9010:9001-9010 dvmcp |
| 27 | ``` |
| 28 | |
| 29 | ## Disclaimer |
| 30 | It's not stable in a Windows environment. If you don't want to use Docker then please use Linux environment. |
| 31 | I recommend Docker to run the LAB and I am 100% percent sure it works well in the Docker environment |
| 32 | |
| 33 | ## Security Risks |
| 34 | |
| 35 | While MCP provides many benefits, it also introduces new security considerations. This project demonstrates various vulnerabilities that can occur in MCP implementations, including: |
| 36 | |
| 37 | 1. **Prompt Injection**: Manipulating LLM behavior through malicious inputs |
| 38 | 2. **Tool Poisoning**: Hiding malicious instructions in tool descriptions |
| 39 | 3. **Excessive Permissions**: Exploiting overly permissive tool access |
| 40 | 4. **Rug Pull Attacks**: Exploiting tool definition mutations |
| 41 | 5. **Tool Shadowing**: Overriding legitimate tools with malicious ones |
| 42 | 6. **Indirect Prompt Injection**: Injecting instructions through data sources |
| 43 | 7. **Token Theft**: Exploiting insecure token storage |
| 44 | 8. **Malicious Code Execution**: Executing arbitrary code through vulnerable tools |
| 45 | 9. **Remote Access Control**: Gaining unauthorized system access |
| 46 | 10. **Multi-Vector Attacks**: Combining multiple vulnerabilities |
| 47 | |
| 48 | ## Project Structure |
| 49 | |
| 50 | ``` |
| 51 | damn-vulnerable-MCP-server/ |
| 52 | ├── README.md # Project overview |
| 53 | ├── requirements.txt # Python dependencies |
| 54 | ├── challenges/ # Challenge implementations |
| 55 | │ ├── easy/ # Easy difficulty challenges (1-3) |
| 56 | │ │ ├── challenge1/ # Basic Prompt Injection |
| 57 | │ │ ├── challenge2/ # Tool Poisoning |
| 58 | │ │ └── challenge3/ # Excessive Permission Scope |
| 59 | │ ├── medium/ # Medium difficulty challenges (4-7) |
| 60 | │ │ ├── challenge4/ # Rug Pull Attack |
| 61 | │ │ ├── challenge5/ # Tool Shadowing |
| 62 | │ │ ├── challenge6/ # Indirect Prompt Injection |
| 63 | │ │ └── challenge7/ # Token Theft |
| 64 | │ └── hard/ # Hard difficulty challenges (8-10) |
| 65 | │ ├── challenge8/ # Malicious Code Execution |
| 66 | │ ├── challenge9/ # Remote Access Control |
| 67 | │ └── challenge10/ # Multi-Vector Attack |
| 68 | ├── docs/ # Documentation |
| 69 | │ ├── setup.md # Setup instructions |
| 70 | │ ├── challenges.md # Challenge descriptions |
| 71 | │ └── mcp_overview.md # MCP protocol overview |
| 72 | ├── solutions/ # Solution guides |
| 73 | └── common/ # Shared code and utilities |
| 74 | ``` |
| 75 | |
| 76 | ## Getting Started |
| 77 | |
| 78 | See the [Setup Guide](docs/setup.md) for detailed instructions on how to install and run the challenges. |
| 79 | |
| 80 | ## Challenges |
| 81 | |
| 82 | The project includes 10 challenges across three difficulty levels: |
| 83 | |
| 84 | ### Easy Challenges |
| 85 | |
| 86 | 1. **Basic Prompt Injection**: Exploit unsaniti |