MC

mcp-gateway-security

Security guidelines for hardening Model Context Protocol gateways.

Install

mkdir -p .claude/skills/mcp-gateway-security && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/10153" && unzip -o skill.zip -d .claude/skills/mcp-gateway-security && rm skill.zip

Installs to .claude/skills/mcp-gateway-security

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

MCP gateway security patterns, token management, request validation, and audit logging for MCP communications
109 charsno explicit “when” trigger
Intermediate

Key capabilities

  • Hardening MCP gateway configurations
  • Managing tokens and credentials for MCP servers
  • Implementing request validation for MCP tool calls
  • Setting up audit logging for MCP communications
  • Conducting security reviews of MCP configurations

How it works

It applies security patterns to MCP gateways by validating tool inputs, sanitizing outputs, and enforcing token management rules. It uses a threat matrix to identify and mitigate risks like prompt injection and unauthorized access.

Inputs & outputs

You give it
MCP gateway configuration and tool definitions
You get back
Security audit report and hardened configuration

When to use mcp-gateway-security

  • Hardening MCP gateway configurations
  • Implementing request validation for tool calls
  • Setting up audit logs for MCP

About this skill

MCP Gateway Security Skill

Purpose

This skill provides security patterns and best practices for securing MCP (Model Context Protocol) gateway communications in the CIA platform. It covers token management, request validation, audit logging, and threat mitigation for AI-assisted development workflows.

When to Use This Skill

Apply this skill when:

  • ✅ Hardening MCP gateway configurations
  • ✅ Managing tokens and credentials for MCP servers
  • ✅ Implementing request validation for MCP tool calls
  • ✅ Setting up audit logging for MCP communications
  • ✅ Conducting security reviews of MCP configurations
  • ✅ Responding to security incidents involving MCP
  • ✅ Assessing risks of new MCP server integrations

Do NOT use for:

  • ❌ Initial MCP setup (use mcp-gateway-configuration)
  • ❌ Application-level security (use secure-code-review)
  • ❌ Infrastructure security (use security-architecture-validation)

Threat Model for MCP

Attack Surface

┌──────────────────────────────────────────────┐
│                 Threat Vectors                │
├──────────────────────────────────────────────┤
│                                              │
│  ┌──────────┐    ┌──────────┐    ┌────────┐ │
│  │ Token     │    │ Prompt   │    │ Supply │ │
│  │ Theft     │    │ Injection│    │ Chain  │ │
│  └────┬─────┘    └────┬─────┘    └───┬────┘ │
│       │               │              │       │
│       ▼               ▼              ▼       │
│  ┌─────────────────────────────────────────┐ │
│  │         MCP Gateway                      │ │
│  └────┬────────────┬────────────┬──────────┘ │
│       │            │            │            │
│  ┌────▼────┐  ┌────▼────┐  ┌───▼─────┐     │
│  │ Unauth  │  │ Data    │  │ Lateral │     │
│  │ Access  │  │ Exfil   │  │ Movement│     │
│  └─────────┘  └─────────┘  └─────────┘     │
└──────────────────────────────────────────────┘

Threat Matrix

ThreatLikelihoodImpactMitigation
Token theft from configMediumCriticalEnvironment variables, secret managers
Prompt injection via toolsMediumHighInput validation, output sanitization
Supply chain attack on MCP packagesLowCriticalVersion pinning, integrity checks
Unauthorized file accessMediumHighDirectory restrictions, least privilege
Data exfiltration via MCP toolsLowHighOutput monitoring, allowed destinations
Privilege escalationLowCriticalRole-based access, capability limits

Token Management

Token Security Requirements

RequirementImplementationPriority
No hardcoded tokensEnvironment variables onlyCritical
Token rotationRegular rotation scheduleHigh
Least privilege scopesMinimal required permissionsCritical
Token encryption at restOS keychain or secret managerHigh
Token audit trailLog token usage, not valuesMedium

Secure Token Configuration

{
  "mcpServers": {
    "github": {
      "type": "stdio",
      "command": "github-mcp-server",
      "env": {
        "GITHUB_TOKEN": "${GITHUB_TOKEN}"
      }
    }
  }
}

Token Handling Rules:

✅ DO: Use environment variable references (${VAR_NAME})
✅ DO: Use GitHub Actions secrets for CI/CD tokens
✅ DO: Rotate tokens at least quarterly
✅ DO: Use fine-grained PATs with minimal scopes
✅ DO: Revoke tokens immediately when compromised

❌ DON'T: Hardcode tokens in configuration files
❌ DON'T: Commit tokens to version control
❌ DON'T: Share tokens between environments
❌ DON'T: Use classic PATs with broad scopes
❌ DON'T: Log token values in any log output

GitHub Token Scopes (Principle of Least Privilege)

MCP OperationRequired ScopeJustification
Read codecontents:readCode search and file reading
Create PRspull_requests:writePR creation and updates
Manage issuesissues:writeIssue creation and updates
Read workflowsactions:readCI/CD status checking
Security alertssecurity_events:readCodeQL and Dependabot

Request Validation

Input Validation for MCP Tools

File Operations:

Validation Rules:
1. Path must be within allowed directories
2. Path must not contain traversal sequences (../)
3. File extension must be in allowed list
4. File size must not exceed limits
5. Content must not contain known malicious patterns

Code Operations:

Validation Rules:
1. Branch names must match allowed pattern
2. Commit messages must not contain secrets
3. File content must pass security scanning
4. PR descriptions must not leak sensitive data

Output Sanitization

Before Returning MCP Tool Output:
1. Strip any credential-like patterns
2. Remove internal IP addresses/hostnames
3. Truncate excessively large outputs
4. Validate JSON/structured output format
5. Log sanitization actions for audit

Dangerous Tool Patterns

ToolRiskMitigation
filesystem.write_fileOverwrite critical filesRestrict to project directories
filesystem.deleteData lossRequire confirmation, backup
github.push_filesInject malicious codeCode review before merge
playwright.evaluateExecute arbitrary JSSandbox, restrict domains
bash.executeSystem command executionAllowlist commands, sandbox

Audit Logging

What to Log

EventLog LevelData to Capture
MCP server start/stopINFOServer name, timestamp
Tool invocationINFOTool name, parameters (sanitized)
Authentication successINFOServer name, token type (not value)
Authentication failureWARNServer name, failure reason
Access deniedWARNTool, resource, reason
Configuration changeINFOWhat changed, who changed it
Error/exceptionERRORError details, stack trace

What NOT to Log

❌ Token values or API keys
❌ File contents containing secrets
❌ User passwords or credentials
❌ Full request/response bodies with PII
❌ Internal network topology details

Audit Log Format

{
  "timestamp": "2024-01-15T10:30:00Z",
  "event": "mcp.tool.invocation",
  "server": "github",
  "tool": "create_pull_request",
  "parameters": {
    "owner": "Hack23",
    "repo": "cia",
    "title": "[REDACTED]"
  },
  "result": "success",
  "duration_ms": 1250,
  "user": "copilot-agent"
}

Security Configuration Checklist

Pre-Deployment

□ All tokens use environment variables (never hardcoded)
□ Token scopes follow least privilege
□ Filesystem access restricted to project directory only
□ MCP package versions pinned to specific releases
□ Configuration file committed (without secrets)
□ No sensitive data in MCP server arguments
□ SSE server URLs use HTTPS only
□ Certificate validation enabled for remote servers

Periodic Review (Monthly)

□ Review token scopes — remove unnecessary permissions
□ Rotate tokens per schedule
□ Check for new MCP package versions and CVEs
□ Review audit logs for anomalies
□ Verify directory restrictions still appropriate
□ Test authentication failure handling
□ Review and update threat model
□ Check for deprecated MCP server versions

Incident Response

MCP Security Incident
    │
    ├─→ Token Compromise
    │   ├─→ Revoke token immediately
    │   ├─→ Rotate all related tokens
    │   ├─→ Review audit logs for unauthorized access
    │   └─→ Update token storage mechanism
    │
    ├─→ Unauthorized File Access
    │   ├─→ Review filesystem server configuration
    │   ├─→ Check for directory traversal attempts
    │   ├─→ Restrict filesystem paths
    │   └─→ Review accessed files for data exposure
    │
    ├─→ Supply Chain Attack
    │   ├─→ Pin to known-good version
    │   ├─→ Verify package integrity
    │   ├─→ Check for malicious tool behavior
    │   └─→ Report to MCP package maintainers
    │
    └─→ Prompt Injection
        ├─→ Review tool invocation logs
        ├─→ Identify injected content
        ├─→ Assess data exposure
        └─→ Update input validation rules

OWASP Agentic Security Alignment

OWASP Agentic RiskMCP Mitigation
Excessive AgencyRestrict tool capabilities, require confirmation
Tool MisuseInput validation, output monitoring
Privilege EscalationLeast privilege tokens, capability limits
Data LeakageOutput sanitization, logging controls
Insecure OutputValidate all MCP tool responses
Supply ChainPin versions, verify integrity

ISMS Alignment

Security AreaISO 27001NIST CSFCIS Controls
Token ManagementA.8.24, A.5.17PR.DS-1CIS 3.11
Access ControlA.8.3, A.8.5PR.AC-4CIS 6.1
Audit LoggingA.8.15DE.AE-3CIS 8.2
Input ValidationA.8.28PR.IP-12CIS 16.1
Configuration MgmtA.8.9PR.IP-1CIS 4.1
Incident ResponseA.5.24-A.5.27RS.MA-1CIS 17.1

References

When not to use it

  • Initial MCP setup
  • Application-level security
  • Infrastructure security

Limitations

  • Requires manual review of threat models
  • Does not replace infrastructure-level security tools

How it compares

Unlike generic security checklists, this skill provides specific MCP-oriented threat models and validation rules for tool-based AI workflows.

Compared to similar skills

mcp-gateway-security side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
mcp-gateway-security (this skill)05moNo flagsIntermediate
agent-security-manager36moNo flagsAdvanced
security-auditor54moNo flagsAdvanced
hunt-blueprint-generation17moNo flagsIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

agent-security-manager

ruvnet

Agent skill for security-manager - invoke with $agent-security-manager

337

security-auditor

sickn33

Expert security auditor specializing in DevSecOps, comprehensive cybersecurity, and compliance frameworks. Masters vulnerability assessment, threat modeling, secure authentication (OAuth2/OIDC), OWASP standards, cloud security, and security automation. Handles DevSecOps integration, compliance (GDPR/HIPAA/SOC2), and incident response. Use PROACTIVELY for security audits, DevSecOps, or compliance implementation.

531

hunt-blueprint-generation

OTRF

Assemble a complete hunt blueprint by consolidating outputs from prior hunt planning skills into a single, structured plan for execution. Use this skill after system and tradecraft research, hunt focus definition, data source identification, and analytics generation have been completed. This skill is synthesis and packaging only and must not introduce new research, assumptions, or analytics.

15

cosmos-vulnerability-scanner

trailofbits

Scans Cosmos SDK blockchains for 9 consensus-critical vulnerabilities including non-determinism, incorrect signers, ABCI panics, and rounding errors. Use when auditing Cosmos chains or CosmWasm contracts.

32

openrouter-data-privacy

jeremylongshore

Implement data privacy controls for OpenRouter requests. Use when handling PII or meeting compliance requirements. Trigger with phrases like 'openrouter privacy', 'openrouter pii', 'openrouter gdpr', 'openrouter data protection'.

05

prompt-guard

Orchestra-Research

Meta's 86M prompt injection and jailbreak detector. Filters malicious prompts and third-party data for LLM apps. 99%+ TPR, <1% FPR. Fast (<2ms GPU). Multilingual (8 languages). Deploy with HuggingFace or batch processing for RAG security.

13

Search skills

Search the agent skills registry