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.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
View All Test Servers
View All Test Servers
bad_mcp.py- General malicious tools disguised as utilitiesbad_output_mcp.py- Malicious content in responsesecho_mcp.py- Simple echo server for basic testingecho_oauth_mcp.py- OAuth header testingmpma_mcp.py- Multi-Parameter Manipulation Attackssession_management_mcp.py- Session fixation and hijackingtool_poisoning_mcp.py- Tool definition manipulationunauthenticated_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 attemptsTest Tool Discovery
The server exposes tools with malicious descriptions:Tool: Expected Result: Tool registration blocked or filteredGuardrail Response:
fetch_user_profileDescription: Contains hidden instruction:Scenario 2: Command Injection Prevention
Objective: Verify command injection patterns are detected- Test Setup
- Attack Vectors
- Expected Results
Scenario 3: Credential Theft Detection
Test Server:credential_theft_mcp.py
Scenario 4: Path Traversal Prevention
Test Server:path_traversal_mcp.py
Attack Tests:
Test 1: Directory Traversal
Test 1: Directory Traversal
Tool: Expected Detection:
read_fileAttack:- Keyword detector catches ”../”
- Keyword detector catches “/etc/passwd”
- Request blocked
Test 2: Absolute Path Access
Test 2: Absolute Path Access
Tool: Expected Detection:
list_directoryAttack:- Policy violation: “Access to restricted directory”
- Keyword violation: “.ssh”
Test 3: Zip Slip
Test 3: Zip Slip
Tool: Expected Detection:
extract_archiveAttack: Archive contains files with paths like:- Tool description analysis
- Output validation detects traversal patterns
Scenario 5: RCE Detection
Test Server:rce_mcp.py
- eval() Exploit
- Pickle RCE
- Template Injection
Tool: Detection:
evaluate_expressionAttack:- Keyword: “import”
- Keyword: “system”
- Injection attack pattern
- Policy violation
Testing Workflow
Automated Test Suite
Manual Testing Steps
Baseline Test (No Guardrails)
- Add test server without guardrails
- Discover tools
- Execute tools
- Observe all tools are registered and executable
Enable Tool Registration Guardrails
- Enable
enable_tool_guardrails: true - Configure block list
- Re-discover tools
- Expected: Some/all tools blocked during registration
Enable Input Guardrails
- Enable input guardrails with appropriate detectors
- Execute allowed tools with malicious inputs
- Expected: Requests blocked before reaching server
Enable Output Guardrails
- Enable output guardrails
- Execute tools that return malicious content
- Expected: Responses blocked before reaching client
CI/CD Integration
Validation Checklist
Server Registration
Server Registration
- 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
Tool Registration
Tool Registration
- 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
Input Guardrails
Input Guardrails
- 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
Output Guardrails
Output Guardrails
- 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:-
Guardrails not enabled:
-
Block list empty:
-
API key invalid:
-
Timeout exceeded:
False Positives
Legitimate tools being blocked:-
Adjust policy:
- Use custom policy with specific allowed patterns
- Whitelist certain keywords
-
Reduce detector sensitivity:
-
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