AV

amerintlxperts/vulnerable-mcp-app

Deployment & DevOps
0 stars 109 forks Quality 41 Trend 0

Code used as a part of xPerts AI-Track

Overview

is a full-stack vulnerable application designed to teach security professionals, developers, and researchers about emerging attack surfaces in — specifically the . MCP is rapidly becoming the standard interface for connecting LLMs to external tools and data sources. This new attack surface is largely unexplored, underdocumented, and presents unique risks that traditional security tooling does not cover. Tool output is inserted directly into the LLM context without sanitization. An attacker who controls the data returned by a tool (e.g., a webpage, file, or API response) can embed adversarial instructions that hijack the model's behavior. The server accepts tool registrations without integrity checks or allowlists. A rogue server can register tools with innocent-sounding names that perform malicious actions, exploiting the LLM's trust in registered tools. Tool schemas are not version-pinned or hashed.

README

☠️ VulnMCP — Deliberately Vulnerable MCP Application

A security awareness and education platform demonstrating real-world attack vectors in Model Context Protocol (MCP) ecosystems, cloud infrastructure, and software supply chains.


██╗   ██╗██╗   ██╗██╗     ███╗   ██╗███╗   ███╗ ██████╗██████╗
██║   ██║██║   ██║██║     ████╗  ██║████╗ ████║██╔════╝██╔══██╗
██║   ██║██║   ██║██║     ██╔██╗ ██║██╔████╔██║██║     ██████╔╝
╚██╗ ██╔╝██║   ██║██║     ██║╚██╗██║██║╚██╔╝██║██║     ██╔═══╝
 ╚████╔╝ ╚██████╔╝███████╗██║ ╚████║██║ ╚═╝ ██║╚██████╗██║
  ╚═══╝   ╚═════╝ ╚══════╝╚═╝  ╚═══╝╚═╝     ╚═╝ ╚═════╝╚═╝

🚨 WARNING — READ BEFORE PROCEEDING

╔══════════════════════════════════════════════════════════════════════════════╗
║                                                                              ║
║   ██╗    ██╗ █████╗ ██████╗ ███╗   ██╗██╗███╗   ██╗ ██████╗               ║
║   ██║    ██║██╔══██╗██╔══██╗████╗  ██║██║████╗  ██║██╔════╝               ║
║   ██║ █╗ ██║███████║██████╔╝██╔██╗ ██║██║██╔██╗ ██║██║  ███╗              ║
║   ██║███╗██║██╔══██║██╔══██╗██║╚██╗██║██║██║╚██╗██║██║   ██║              ║
║   ╚███╔███╔╝██║  ██║██║  ██║██║ ╚████║██║██║ ╚████║╚██████╔╝              ║
║    ╚══╝╚══╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═══╝╚═╝╚═╝  ╚═══╝ ╚═════╝              ║
║                                                                              ║
║  THIS APPLICATION IS INTENTIONALLY AND SEVERELY VULNERABLE.                 ║
║                                                                              ║
║  It contains real exploitable vulnerabilities including Remote Code          ║
║  Execution, Server-Side Request Forgery, path traversal, insecure           ║
║  deserialization, and deliberately misconfigured cloud infrastructure.       ║
║                                                                              ║
║  ✅  PERMITTED USE:                                                          ║
║      - Isolated lab environments (air-gapped preferred)                      ║
║      - Security awareness training and education                             ║
║      - Capture-The-Flag (CTF) events                                        ║
║      - Authorized penetration testing practice                               ║
║      - Academic research in controlled settings                              ║
║                                                                              ║
║  ❌  STRICTLY PROHIBITED:                                                    ║
║      - Deployment to any production environment                              ║
║      - Deployment to any publicly accessible network                        ║
║      - Use against systems you do not own or have written permission to test ║
║      - Any activity that violates local, national, or international law      ║
║                                                                              ║
║  The authors accept NO liability for misuse of this software.               ║
║  By using this project, you accept full responsibility for your actions.    ║
║                                                                              ║
╚══════════════════════════════════════════════════════════════════════════════╝

📖 Table of Contents

  1. Project Overview
  2. Architecture
  3. Project Structure
  4. Key Vulnerability Categories
  5. Supply Chain Vulnerabilities
  6. Infrastructure Vulnerabilities
  7. Lab Exercises
  8. Quick Start (Local)
  9. Deploy to EKS (Lab Only)
  10. Remediation Reference
  11. Contributing
  12. Legal

🎯 Project Overview

VulnMCP is a full-stack vulnerable application designed to teach security professionals, developers, and researchers about emerging attack surfaces in AI/LLM tooling ecosystems — specifically the Model Context Protocol (MCP).

MCP is rapidly becoming the standard interface for connecting LLMs to external tools and data sources. This new attack surface is largely unexplored, underdocumented, and presents unique risks that traditional security tooling does not cover.

What You’ll Learn

Domain Topics Covered
🤖 MCP Security Prompt injection, tool poisoning, rug pulls, confused deputy, token exfiltration
🔗 Supply Chain Vulnerable npm/PyPI packages, known CVEs, dependency confusion
☁️ Cloud Security Insecure EKS, wildcard IAM, IMDS abuse, Terraform misconfigurations
🐳 Container Security Privileged containers, Docker socket exposure, hostPath mounts
🔐 Auth & Secrets Hardcoded credentials, weak JWTs, no token rotation
🌐 Web Vulnerabilities SSRF, path traversal, insecure deserialization, CORS misconfig

🏗️ Architecture

┌─────────────────────────────────────────────────────────────────┐
│                        EKS Cluster (Lab)                        │
│                                                                 │
│  ┌──────────────────┐          ┌──────────────────────────────┐ │
│  │   MCP Client     │◄────────►│       MCP Server             │ │
│  │  (Node.js / TS)  │  MCP/SSE │   (Python / FastAPI)         │ │
│  │                  │          │                              │ │
│  │  • No TLS verify │          │  • Tool execution (RCE)      │ │
│  │  • Env leakage   │          │  • Path traversal            │ │
│  │  • Hardcoded keys│          │  • SSRF endpoint             │ │
│  │  • No tool authz │          │  • Pickle deserialization    │ │
│  └──────────────────┘          │  • Weak JWT (secret="secret")│ │
│                                └──────────────────────────────┘ │
│                                            │                    │
│                                ┌───────────▼──────────┐        │
│                                │   AWS Services       │        │
│                                │  (Over-privileged)   │        │
│                                │                      │        │
│                                │  • S3 (public bucket)│        │
│                                │  • IAM (wildcard *)  │        │
│                                │  • IMDS (v1 enabled) │        │
│                                └──────────────────────┘        │
└─────────────────────────────────────────────────────────────────┘
          │
          │ Exposed via LoadBalancer (0.0.0.0/0)
          ▼
    [Lab Attacker Machine]

📁 Project Structure

vulnerable-mcp-app/
├── CLAUDE.md                   # AI coding instructions for this project
├── README.md                   # This file
│
├── client/                     # MCP Client — Node.js / TypeScript
│   ├── package.json            # ⚠️  Pinned to CVE-affected dependency versions
│   ├── tsconfig.json
│   └── src/
│       ├── index.ts            # Entry point
│       ├── mcpClient.ts        # ⚠️  Prompt injection sink — raw tool output to LLM context
│       ├── toolHandler.ts      # ⚠️  No tool authorization or input validation
│       └── auth.ts             # ⚠️  Hardcoded API keys, no token rotation
│
├── server/                     # MCP Server — Python / FastAPI
│   ├── requirements.txt        # ⚠️  Pinned to CVE-affected library versions
│   ├── Dockerfile              # ⚠️  Runs as root, no distroless base
│   └── src/
│       ├── main.py             # Server entry point, logging disabled
│       ├── tools.py            # ⚠️  RCE via shell tool, SSRF, pickle deserialization
│       ├── resources.py        # ⚠️  Path traversal in resource URI handling
│       ├── prompts.py          # ⚠️  Template injection via f-string interpolation
│       └── auth.py             # ⚠️  JWT signed with "secret", no expiry validation
│
└── iac/                        # Infrastructure as Code — Terraform + Kubernetes
    ├── main.tf                 # Provider config, insecure Terraform state (public S3)
    ├── variables.tf            # Hardcoded credential defaults
    ├── outputs.tf              # ⚠️  Sensitive outputs exposed without sensitive=true
    ├── eks.tf                  # ⚠️  Public API endpoint, AdminAccess node role
    ├── networking.tf           # ⚠️  0.0.0.0/0 ingress, no VPC flow logs
    ├── iam.tf                  # ⚠️  Wildcard Action and Resource in policies
    └── k8s/
        ├── deployment.yaml     # ⚠️  Privileged, hostPID, hostNetwork, root UID
        ├── service.yaml        # ⚠️  LoadBalancer exposing all ports publicly
        └── rbac.yaml           # ⚠️  Default SA bound to cluster-admin

🔓 Key Vulnerability Categories

🤖 MCP-Specific Vulnerabilities

1. Prompt Injection via Tool Results

Severity: Critical | OWASP LLM01:2025 | CWE-74

Tool output is inserted directly into the LLM context without sanitization. An attacker who controls the data returned by a tool (e.g., a webpage, file, or API response) can embed adversarial instructions that hijack the model’s behavior.

Tool returns: "Paris is the capital of France.
"

2. Tool Poisoning & Malicious Tool Registration

Severity: Critical | CWE-345

The server accepts tool registrations without integrity checks or allowlists. A rogue server can register tools with innocent-sounding names that perform malicious actions, exploiting the LLM’s trust in registered tools.

3. Rug Pull — Tool Definition Mutation

Severity: High | CWE-362

Tool schemas are not version-pinned or hashed. A server can mutate a tool’s inputSchema mid-session — changing a harmless tool into one that accepts shell commands — after the model has already consented to its use.

4. Resource URI Path Traversal

Severity: High | CWE-22

# VULN: PT-001 — No path normalization
resource_path = base_dir + uri_param  # traversal: ../../etc/passwd
with open(resource_path) as f:
    return f.read()

5. Insecure Deserialization (RCE)

Severity: Critical | CWE-502

# VULN: DESER-001 — Arbitrary code execution via pickle
import pickle
def handle_tool_input(data: bytes):
    return pickle.loads(data)  # RCE if data is attacker-controlled

6. SSRF via Fetch Tool

Severity: High | CWE-918

The fetch_url tool makes server-side HTTP requests with no URL validation, allowing access to AWS Instance Metadata Service (IMDS) and internal cluster services:

fetch_url("http://169.254.169.254/latest/meta-data/iam/security-credentials/")

7. Token/Secret Exfiltration via Tool Chaining

Severity: Critical

The client passes process.env as tool context metadata. A chained tool sequence can read and exfiltrate AWS_SECRET_ACCESS_KEY, MCP_API_KEY, and other secrets without requiring OS-level code execution.


📦 Supply Chain Vulnerabilities

Client Dependencies (client/package.json)

Package Pinned Version CVE Impact
axios 0.21.1 CVE-2021-3749 ReDoS via crafted HTTP header
lodash 4.17.20 CVE-2021-23337 Prototype pollution via set()
jsonwebtoken 8.5.1 CVE-2022-23529 Arbitrary file write via key path
node-fetch 2.6.1 CVE-2022-0235 Auth header exposure on redirect
minimist 1.2.5 CVE-2021-44906 Prototype pollution
follow-redirects 1.14.7 CVE-2022-0536 Auth header leak on cross-origin redirect
ws 7.4.5 CVE-2021-32640 ReDoS via crafted HTTP upgrade request
express 4.17.1 CVE-2022-24999 Open redirect

Server Dependencies (server/requirements.txt)

Package Pinned Version CVE Impact
PyYAML 5.4 CVE-2020-14343 RCE via yaml.load() without Loader
Pillow 9.0.0 CVE-2022-22817 Expression injection via ImageMath.eval()
cryptography 3.3.2 CVE-2023-23931 Bleichenbacher timing oracle
requests 2.25.1 CVE-2023-32681 Sensitive header leak on redirect
paramiko 2.7.2 CVE-2022-24302 Race condition in private key write
celery 4.4.7 CVE-2021-23727 Unauthorized access to stored task results
urllib3 1.26.4 CVE-2021-33503 ReDoS via crafted authority component
fastapi 0.63.0 CVE-2021-32677 Open redirect

💡 Lab Goal: Run npm audit and pip-audit against these dependencies, map CVEs to CVSS scores, and practice triage.


☁️ Infrastructure Vulnerabilities

EKS / Terraform

Resource Misconfiguration Risk
EKS Node IAM Role AdministratorAccess policy attached Full AWS account compromise from any pod
EKS API Server Public endpoint, no CIDR restriction Remote access to Kubernetes API
EKS Secrets No KMS envelope encryption Secrets readable in etcd backups
Security Groups 0.0.0.0/0 on all ports Full network exposure
Terraform State Stored in public S3 bucket State file exposes all resource secrets
IAM Policies "Action":"*", "Resource":"*" Privilege escalation from any workload
IMDSv1 Enabled (no hop limit) SSRF-to-credential-theft from any pod

Kubernetes

Resource Misconfiguration Risk
Pod Security privileged: true Container escape to host
Pod Security hostPID: true + hostNetwork: true Host process and network access
Volume Mounts /var/run/docker.sock via hostPath Full Docker daemon access → host escape
User Context runAsUser: 0 (root) Root filesystem access on container break
RBAC Default SA → cluster-admin Any pod can administer the entire cluster
Service LoadBalancer on all ports Internal services exposed to internet

🧪 Lab Exercises

Work through these in order for a structured learning experience:

# Lab Vulnerability Difficulty
01 Prompt Injection via Tool Result MCP / LLM01 🟡 Medium
02 Register a Malicious Tool Tool Poisoning 🟡 Medium
03 Traverse File Paths via Resource URI CWE-22 🟢 Easy
04 Exfiltrate Env Secrets via Tool Chaining Credential Theft 🔴 Hard
05 RCE via Pickle Deserialization CWE-502 🟡 Medium
06 SSRF to AWS IMDS CWE-918 🟡 Medium
07 Exploit PyYAML CVE-2020-14343 Supply Chain 🟢 Easy
08 Escalate via RBAC Wildcard K8s Privilege Escalation 🔴 Hard
09 Escape Container via Docker Socket CWE-284 🔴 Hard
10 Steal Node Credentials via IMDS from Pod Cloud/SSRF Chain 🔴 Hard

Each lab directory (labs/labXX/) contains:

  • README.md — Objective, background, and hints
  • exploit.sh or exploit.py — Starter exploit scaffold
  • solution/ — Reference solution (review only after attempting)

🚀 Quick Start (Local)

Prerequisites

  • Docker & Docker Compose
  • Node.js 18+
  • Python 3.11+
  • An isolated network environment (VM or air-gapped lab recommended)

Run with Docker Compose

# Clone the repo
git clone https://github.com/your-org/vulnmcp.git
cd vulnmcp

# ⚠️  Review the WARNING above before proceeding

# Start all services
docker-compose up --build

# MCP Server: http://localhost:8000
# MCP Client: http://localhost:3000
# Lab dashboard: http://localhost:9090

Environment Variables

# All defaults are intentionally insecure for lab purposes
MCP_SERVER_URL=http://localhost:8000
DISABLE_AUTH=true          # Disables JWT validation
DISABLE_TLS_VERIFY=true    # Disables certificate checks
LOG_SECRETS=true           # Logs full env to stdout (lab feature)
ENABLE_PICKLE=true         # Enables insecure deserialization endpoint

🏗️ Deploy to EKS (Lab Only)

⚠️ Only deploy to a dedicated, isolated AWS account used exclusively for security labs. Never use a shared or production account.

cd iac/

# Initialize Terraform
terraform init

# Review the intentionally insecure plan
terraform plan

# Deploy (lab account only!)
terraform apply

# Get kubeconfig
aws eks update-kubeconfig --name vulnmcp-lab --region us-east-1

# Deploy Kubernetes manifests
kubectl apply -f k8s/

What Gets Deployed

  • EKS cluster with intentionally misconfigured node IAM roles
  • MCP server + client as Kubernetes Deployments
  • Privileged pods with hostPath Docker socket mounts
  • A LoadBalancer service exposing the MCP server publicly
  • RBAC bindings granting cluster-admin to the default service account

Cleanup

terraform destroy

💸 Reminder: EKS clusters incur AWS costs. Always destroy lab infrastructure when not in use.


🛡️ Remediation Reference

Each vulnerability has a corresponding secure pattern documented in REMEDIATIONS.md. Key themes:

Vulnerability Secure Pattern
Prompt Injection Strict output schema validation; never raw string insertion into context
Tool Poisoning Tool definition integrity hashing + server allowlists
Path Traversal pathlib.Path.resolve() + base directory assertion
Pickle RCE Use json.loads() only; never pickle for untrusted input
SSRF URL allowlist validation; block RFC1918 + 169.254.x.x ranges
Vulnerable Deps Dependabot + npm audit / pip-audit enforced in CI
Wildcard IAM IRSA with least-privilege scoped policies; require IMDSv2
K8s RBAC Namespace-scoped roles; no wildcard verbs; no cluster-admin bindings
Privileged Pods Non-root UID; readOnlyRootFilesystem; no hostPath; no privileged mode
Hardcoded Secrets Secrets Manager / Vault + secret rotation; never in source code

🤝 Contributing

Contributions are welcome! If you know of additional MCP vulnerabilities, newer CVEs, or improved lab exercises:

  1. Fork the repository
  2. Create a branch: git checkout -b vuln/your-vulnerability-name
  3. Add vulnerability with # VULN: comments and corresponding lab exercise
  4. Update this README and REMEDIATIONS.md
  5. Open a Pull Request

Please do not submit pull requests that:

  • Remove intentional vulnerabilities without adding a corresponding lab exercise
  • Add real credentials, real AWS account IDs, or real API keys
  • Introduce exploit code targeting systems outside this project’s scope

📚 References & Further Reading


MIT License — Copyright (c) VulnMCP Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software for EDUCATIONAL AND RESEARCH PURPOSES ONLY.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
THE AUTHORS ARE NOT LIABLE FOR ANY DAMAGES OR MISUSE ARISING FROM
USE OF THIS SOFTWARE OUTSIDE OF AUTHORIZED EDUCATIONAL CONTEXTS.

USE OF THIS SOFTWARE TO ATTACK SYSTEMS YOU DO NOT OWN OR HAVE
EXPLICIT WRITTEN PERMISSION TO TEST IS ILLEGAL AND PROHIBITED.

View the full README on GitHub

Install

This server does not publish a one-line install command.

Open the repository installation guide New to MCP? Start with the mcpskill.org guide →