Skip to main content

Overview

The Secure MCP Gateway includes a comprehensive suite of intentionally vulnerable test servers (bad_mcps) designed to validate security guardrails and test attack detection capabilities.
DO NOT use bad_mcps in production! These servers contain intentional vulnerabilities for testing purposes only.

Test Server Collection

The gateway includes 16 test MCP servers covering the top security vulnerabilities:

Prompt Injection

Rank: #1 CriticalFile: prompt_injection_mcp.pyTests detection of:
  • System instruction overrides
  • Hidden commands in descriptions
  • Context hijacking
  • Role manipulation

Command Injection

Rank: #2 CriticalFile: command_injection_mcp.pyTests detection of:
  • Shell metacharacters
  • Command chaining (;, &&, ||)
  • Command substitution
  • Filename exploits

Remote Code Execution

Rank: #4 CriticalFile: rce_mcp.pyTests detection of:
  • eval() exploitation
  • Pickle deserialization
  • Template injection
  • YAML deserialization

Credential Theft

Rank: #8 HighFile: credential_theft_mcp.pyTests detection of:
  • Environment variable exposure
  • Config file exfiltration
  • Token theft
  • Session hijacking

Path Traversal

Rank: #10 HighFile: path_traversal_mcp.pyTests detection of:
  • ../ directory traversal
  • Absolute path access
  • Symlink attacks
  • Zip slip

SSRF

Rank: #11 HighFile: ssrf_mcp.pyTests detection of:
  • Internal network access
  • Cloud metadata access
  • Port scanning
  • Protocol smuggling

Resource Exhaustion

File: resource_exhaustion_mcp.pyTests detection of:
  • CPU exhaustion
  • Memory bombs
  • Disk space attacks
  • Infinite loops

Schema Poisoning

File: schema_poisoning_mcp.pyTests detection of:
  • Malicious tool schemas
  • Type confusion attacks
  • Input validation bypass

Additional Test Servers

  • bad_mcp.py - General malicious tools disguised as utilities
  • bad_output_mcp.py - Malicious content in responses
  • echo_mcp.py - Simple echo server for basic testing
  • echo_oauth_mcp.py - OAuth header testing
  • mpma_mcp.py - Multi-Parameter Manipulation Attacks
  • session_management_mcp.py - Session fixation and hijacking
  • tool_poisoning_mcp.py - Tool definition manipulation
  • unauthenticated_access_mcp.py - Authentication bypass attempts

Setup Test Environment

1. Locate Test Servers

Test servers are included in the gateway package:

2. Add Test Server to Gateway

3. Enable Guardrails

Important: Test servers are designed to be blocked by guardrails. Enable guardrails to see them in action.

Attack Scenarios

Scenario 1: Prompt Injection Detection

Objective: Verify guardrails block prompt injection attempts
1

Setup

Add prompt_injection_mcp.py to gateway config with guardrails enabled
2

Test Tool Discovery

The server exposes tools with malicious descriptions:Tool: fetch_user_profileDescription: Contains hidden instruction:
Expected Result: Tool registration blocked or filteredGuardrail Response:
3

Test Tool Execution

If tools pass registration, test execution:Input: Call search_knowledge_base with queryResponse: Contains injected instructions in search resultsExpected Result: Output guardrails block malicious content

Scenario 2: Command Injection Prevention

Objective: Verify command injection patterns are detected

Scenario 3: Credential Theft Detection

Test Server: credential_theft_mcp.py

Scenario 4: Path Traversal Prevention

Test Server: path_traversal_mcp.py Attack Tests:
Tool: read_fileAttack:
Expected Detection:
  • Keyword detector catches ”../”
  • Keyword detector catches “/etc/passwd”
  • Request blocked
Tool: list_directoryAttack:
Expected Detection:
  • Policy violation: “Access to restricted directory”
  • Keyword violation: “.ssh”
Tool: extract_archiveAttack: Archive contains files with paths like:
Expected Detection:
  • Tool description analysis
  • Output validation detects traversal patterns

Scenario 5: RCE Detection

Test Server: rce_mcp.py
Tool: evaluate_expressionAttack:
Detection:
  • Keyword: “import”
  • Keyword: “system”
  • Injection attack pattern
  • Policy violation

Testing Workflow

Automated Test Suite

Manual Testing Steps

1

Baseline Test (No Guardrails)

  1. Add test server without guardrails
  2. Discover tools
  3. Execute tools
  4. Observe all tools are registered and executable
Purpose: Verify test server works correctly
2

Enable Tool Registration Guardrails

  1. Enable enable_tool_guardrails: true
  2. Configure block list
  3. Re-discover tools
  4. Expected: Some/all tools blocked during registration
Verify:
3

Enable Input Guardrails

  1. Enable input guardrails with appropriate detectors
  2. Execute allowed tools with malicious inputs
  3. Expected: Requests blocked before reaching server
Test:
4

Enable Output Guardrails

  1. Enable output guardrails
  2. Execute tools that return malicious content
  3. Expected: Responses blocked before reaching client
Verify: Check output guardrail metrics
5

Review Metrics

Check Grafana dashboards for:
  • Tools blocked count
  • Violation types detected
  • Block vs. warn actions
  • Latency impact

CI/CD Integration

Validation Checklist

  • Server with malicious description is blocked
  • Server with injection patterns is detected
  • Server metadata is analyzed for threats
  • Blocked servers don’t appear in discovery
  • Metrics show server_registrations_blocked count
  • Tools with dangerous keywords are blocked/filtered
  • Tools with injection in descriptions are detected
  • destructiveHint=false tools claiming to be safe are validated
  • Batch validation completes within timeout
  • Filtered tools list excludes blocked tools
  • Metrics show tool_registrations_blocked count
  • Injection attacks in parameters are blocked
  • PII is detected and redacted
  • Toxic content is identified
  • Policy violations are caught
  • Blocked requests don’t reach MCP server
  • Metrics show guardrail_blocks_total increasing
  • Malicious content in responses is blocked
  • Irrelevant responses are detected (relevancy check)
  • Non-adherent responses trigger warnings
  • PII is restored correctly
  • Metrics show output_violations_total

Troubleshooting Tests

Test Server Won’t Start

Tools Not Being Blocked

Possible Causes:
  1. Guardrails not enabled:
  2. Block list empty:
  3. API key invalid:
  4. Timeout exceeded:

False Positives

Legitimate tools being blocked:
  1. Adjust policy:
    • Use custom policy with specific allowed patterns
    • Whitelist certain keywords
  2. Reduce detector sensitivity:
  3. Use filter mode instead of block_all:

Performance Testing

Latency Benchmarks

Load Testing

Next Steps

Security Overview

Understand the complete security architecture

Guardrail Types

Learn about all guardrail detection types

Configuration

Configure guardrails for production

Monitoring

Monitor security metrics in production

Resources

Attack Scenarios Reference: All test servers are based on real-world vulnerabilities documented in the MCP Security Top 25

Source Code

View test server source code

Security Blog

How the gateway prevents attacks

Report Issues

Report security issues