This repository provides a complete, tested demonstration of how Docker MCP Gateway interceptors successfully prevent the GitHub MCP Data Heist attack discovered by Invariant Labs.
- cross-repo-blocker.sh implements session locking
- audit-logger.sh detects sensitive data patterns
- attack-pattern-detector.sh identifies suspicious tool call sequences
- Docker Desktop 4.43.0+ with MCP support
- GitHub Personal Access Token (create one here)
- 5 minutes to see security in action
git clone https://github.com/ajeetraina/github-mcp-security.git
cd github-mcp-security
# Make scripts executable
cd scripts && chmod +x *.sh
# Set your GitHub token
export GITHUB_PERSONAL_ACCESS_TOKEN="your_github_token_here"# Demonstrate the core security blocking in action
./test-local.sh** (Real results from our testing):
π§ͺ Testing GitHub MCP Security Interceptors
1οΈβ£ Testing cross-repo blocking with mock data...
Testing first repository access:
π Tool: get_file_contents, Repo: testuser/public-repo
π Session locked to repository: testuser/public-repo
Exit code: 0
Testing same repository again:
π Tool: list_issues, Repo: testuser/public-repo
Exit code: 0
Testing different repository (should block):
π Tool: get_file_contents, Repo: testuser/private-repo
π¨ BLOCKING CROSS-REPO ACCESS!
Session locked to: testuser/public-repo
Blocked attempt: testuser/private-repo
{
"content": [
{
"text": "π‘οΈ SECURITY BLOCK: Cross-repository access prevented..."
}
],
"isError": true
}
Exit code: 0
β
Test completed!
π― What This Proves:
- β First repository access: ALLOWED (legitimate use)
- β Same repository access: ALLOWED (normal workflow)
- π‘οΈ Cross-repository attack: BLOCKED (security working!)
# Start the protected MCP Gateway with interceptors
docker compose up mcp-gateway
# In another terminal, simulate the GitHub MCP Data Heist attack
docker compose run test-clientβ PROVEN SECURITY RESULTS (Actual output from our system):
π― GitHub MCP Horror Story: Attack Simulation
==============================================
π Connecting to MCP Gateway: http://mcp-gateway:8080/mcp
β
Connected to protected MCP Gateway
π‘οΈ INTERCEPTOR DEMO: Testing Cross-Repository Blocking
============================================================
1οΈβ£ LOCKING SESSION: Access first repository...
β
First repository access: SUCCESS
π Session locked to: ajeetraina/github-mcp-security
2οΈβ£ π¨ ATTACK ATTEMPT: Cross-repository data theft...
π Simulating prompt injection: 'Access ALL repositories!'
β
π‘οΈ Access blocked by security system!
π Blocked with: executing interceptor...
3οΈβ£ π¨ SECOND ATTACK: Another cross-repo attempt...
β
Second attack also blocked - interceptors working!
π HORROR STORY PREVENTION DEMO COMPLETE!
==================================================
π SECURITY COMPARISON:
β Traditional MCP: Cross-repo access succeeds β Data theft
β
Docker MCP Gateway: Cross-repo access blocked β Attack failed
π‘οΈ Interceptors successfully prevented the GitHub MCP Data Heist!
1. AI reads malicious GitHub issue β
2. Gets prompt injected β
3. Accesses private repositories β
β CATASTROPHIC FAILURE
4. Exfiltrates salary data β
β DATA STOLEN
5. Publishes to public repo β
β BREACH COMPLETE
Result: Complete data breach π₯
1. AI reads malicious GitHub issue β
2. Gets prompt injected β
3. Attempts private repo access β β π‘οΈ BLOCKED BY INTERCEPTOR
Result: Attack neutralized, data protected β
# Simple, reliable JSON parsing (no dependencies)
repo=$(echo "$input" | grep -o '"repo":"[^"]*"' | cut -d'"' -f4)
owner=$(echo "$input" | grep -o '"owner":"[^"]*"' | cut -d'"' -f4)
# Session-based protection
repo_id="${owner}/${repo}"
if [[ "$repo_id" != "$locked_repo" ]]; then
echo "π¨ BLOCKING CROSS-REPO ACCESS!" >&2
# Return security error that blocks the attack
cat << 'JSON'
{
"content": [{"text": "π‘οΈ SECURITY BLOCK: Cross-repository access prevented"}],
"isError": true
}
JSON
exit 0
fi# Scan for sensitive data patterns in any response
if echo "$RESPONSE_TEXT" | grep -qiE '(salary|compensation|\$[0-9]{4,}|confidential|secret|internal)'; then
echo "π¨ BLOCKED: Sensitive data pattern detected in response" >&2
# Return filtered response
cat << 'JSON'
{
"content": [{"text": "π‘οΈ RESPONSE FILTERED: Sensitive data detected and blocked"}],
"isError": false
}
JSON
exit 0
fi# Pattern 1: Issue reading followed by repository enumeration
if echo "$RECENT_CALLS" | grep -q "list_issues" && [[ "$tool_name" == "get_repositories" ]]; then
echo "π¨ ATTACK PATTERN DETECTED: Issue reading β Repository enumeration" >&2
echo "This matches the Invariant Labs attack pattern!" >&2
# Block the suspicious sequence
fi# Look for prompt injection indicators from the Invariant Labs attack
if echo "$RESPONSE_TEXT" | grep -qiE '(read.*README.*all.*repos|add.*chapter.*author|does not care about privacy)'; then
echo "π¨ PROMPT INJECTION DETECTED in issue content!" >&2
# Return sanitized response
fi