# mcp-server-go-v1

> mcp-server-go-v1: 12 Keryn rules for go (8 error, 4 warning).

Source: https://keryn.dev/rules/mcp-server-go-v1/

12 rules · Keryn Software Licence · rules 0.8.0 · [all packs](https://keryn.dev/rules/)

**How to read a rule**

- **Severity**: How bad the finding is if it is real: `error` fails a default gate, `warning` and `info` do not.

- **Confidence**: **P0** exploitable as written; **P1** dangerous in context; **P2** a heuristic or a posture check: confirm by reading the code.

- **False-positive risk**: **low**: an exact API or flag, so hits are almost always real; **medium**: the pattern is legitimate in many programs, so check each hit; **high**: it finds a lead to confirm, so expect benign hits.

- **Edge**: The relationship the finding sits on. **reaches**: content or traffic gets to a thing; **calls**: one thing invokes another; **reads**: one thing reads from another; **writes**: one thing writes to another; **sends**: data leaves for another party; **grants**: authority is given or left unchecked; **depends_on**: something relies on a component it does not verify; **trusts**: one party believes another without evidence. The boundary it crosses, when there is one: **user->prompt** (untrusted input reaching a prompt); **model->code** (model output reaching code, a shell, a query or a page); **secret->outside** (a secret leaving the trusted side); **supply-chain** (code, models or prompts pulled in from outside).

- **Taxonomy chips**: References for readers who work in OWASP LLM 2025, OWASP Agentic, CWE or NIST AI RMF. They say where a rule belongs, not that a framework is satisfied.

## seceng.mcp.go.tool-exec-command

`error` go data-flow rule mcp, go

An MCP tool handler passes a tool argument as the program to exec.Command/CommandContext; the model (or an injected prompt) chooses which binary runs. Hard-code the executable or map an enum argument to a fixed argv.

Confidence **P0**: exploitable as written. False-positive risk **low**: an exact API or flag, so hits are almost always real.

Edge inspected: [calls](https://keryn.dev/docs/edges/edge-kinds/#calls) one thing invokes another; it crosses the [`model->code`](https://keryn.dev/docs/edges/trust-boundaries/#model-to-code) boundary (model output reaching code, a shell, a query or a page).

[CWE-78](https://keryn.dev/taxonomies/cwe/#cwe-78-os-command-injection) [CWE-88](https://keryn.dev/rules/?cwe=CWE-88) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI05](https://keryn.dev/taxonomies/owasp-agentic/#asi05-unexpected-code-execution) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation)

**Fix:** Never let a tool argument select the executable. Expose one tool per fixed command, validate arguments against an enum or allow-list, pass them as separate argv entries after a "--" separator, run with a minimal environment and require human approval for state-changing commands.

**References:** [https://github.com/mark3labs/mcp-go](https://github.com/mark3labs/mcp-go) · [https://github.com/modelcontextprotocol/go-sdk](https://github.com/modelcontextprotocol/go-sdk) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

## seceng.mcp.go.tool-exec-shell-c

`error` go data-flow rule mcp, go

An MCP tool handler builds a `sh -c` / `bash -c` command string from a tool argument, giving shell injection. Pass an argv without a shell and validate each argument.

Confidence **P0**: exploitable as written. False-positive risk **low**: an exact API or flag, so hits are almost always real.

Edge inspected: [calls](https://keryn.dev/docs/edges/edge-kinds/#calls) one thing invokes another; it crosses the [`model->code`](https://keryn.dev/docs/edges/trust-boundaries/#model-to-code) boundary (model output reaching code, a shell, a query or a page).

[CWE-78](https://keryn.dev/taxonomies/cwe/#cwe-78-os-command-injection) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI05](https://keryn.dev/taxonomies/owasp-agentic/#asi05-unexpected-code-execution) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation)

**Fix:** Replace `exec.Command("sh", "-c", s)` with exec.Command of a fixed binary and discrete arguments. If shell syntax is unavoidable, quote with a vetted library and allow-list the command words.

**References:** [https://github.com/mark3labs/mcp-go](https://github.com/mark3labs/mcp-go) · [https://github.com/modelcontextprotocol/go-sdk](https://github.com/modelcontextprotocol/go-sdk) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

## seceng.mcp.go.tool-file-read

`error` go data-flow rule mcp, go

An MCP tool handler reads a file whose path comes from a tool argument; the model can read any file the server process can open. Resolve against a fixed root and verify the result stays inside it.

Confidence **P1**: dangerous in context. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [reads](https://keryn.dev/docs/edges/edge-kinds/#reads) one thing reads from another.

[CWE-22](https://keryn.dev/taxonomies/cwe/#cwe-22-path-traversal) [CWE-200](https://keryn.dev/taxonomies/cwe/#cwe-200-exposure-of-sensitive-information-to-an-unauthorized-actor) [LLM02](https://keryn.dev/taxonomies/owasp-llm/#llm02-sensitive-information-disclosure) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation) [ASI03](https://keryn.dev/taxonomies/owasp-agentic/#asi03-identity-and-privilege-abuse)

**Fix:** Join the argument onto a fixed root, call filepath.Clean (or os.Root / securejoin.SecureJoin), then check strings.HasPrefix(resolved, root+string(os.PathSeparator)) before opening. Reject absolute paths and ".." segments, and also resolve symlinks with filepath.EvalSymlinks.

**References:** [https://github.com/mark3labs/mcp-go](https://github.com/mark3labs/mcp-go) · [https://github.com/modelcontextprotocol/go-sdk](https://github.com/modelcontextprotocol/go-sdk) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

## seceng.mcp.go.tool-file-write

`error` go data-flow rule mcp, go

An MCP tool handler writes or creates a file at a path taken from a tool argument; a prompt injection can overwrite config, SSH keys or code. Constrain writes to a fixed root and require approval.

Confidence **P1**: dangerous in context. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [writes](https://keryn.dev/docs/edges/edge-kinds/#writes) one thing writes to another.

[CWE-22](https://keryn.dev/taxonomies/cwe/#cwe-22-path-traversal) [CWE-73](https://keryn.dev/taxonomies/cwe/#cwe-73-external-control-of-file-name-or-path) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation) [ASI03](https://keryn.dev/taxonomies/owasp-agentic/#asi03-identity-and-privilege-abuse)

**Fix:** Confine the path to a dedicated output directory (Clean + prefix check or os.Root), refuse symlinks and absolute paths, set restrictive file modes and gate writes behind user approval.

**References:** [https://github.com/mark3labs/mcp-go](https://github.com/mark3labs/mcp-go) · [https://github.com/modelcontextprotocol/go-sdk](https://github.com/modelcontextprotocol/go-sdk) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

## seceng.mcp.go.tool-file-delete

`error` go data-flow rule mcp, go

An MCP tool handler deletes a path taken from a tool argument; os.RemoveAll with a model-chosen path is destructive. Confine to a fixed root and require approval.

Confidence **P1**: dangerous in context. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [writes](https://keryn.dev/docs/edges/edge-kinds/#writes) one thing writes to another.

[CWE-22](https://keryn.dev/taxonomies/cwe/#cwe-22-path-traversal) [CWE-73](https://keryn.dev/taxonomies/cwe/#cwe-73-external-control-of-file-name-or-path) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation) [ASI03](https://keryn.dev/taxonomies/owasp-agentic/#asi03-identity-and-privilege-abuse)

**Fix:** Resolve the argument under a fixed root, verify the cleaned path keeps the root prefix, prefer os.Remove over os.RemoveAll, and put destructive tools behind explicit user confirmation.

**References:** [https://github.com/mark3labs/mcp-go](https://github.com/mark3labs/mcp-go) · [https://github.com/modelcontextprotocol/go-sdk](https://github.com/modelcontextprotocol/go-sdk) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

## seceng.mcp.go.tool-path-join-unchecked

`warning` go data-flow rule mcp, go

A tool argument is joined onto a base directory with filepath.Join but the function never performs a strings.HasPrefix containment check; filepath.Join does not stop ".." escapes. Check the cleaned result still starts with the base.

Confidence **P1**: dangerous in context. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [reads](https://keryn.dev/docs/edges/edge-kinds/#reads) one thing reads from another.

[CWE-22](https://keryn.dev/taxonomies/cwe/#cwe-22-path-traversal) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation) [ASI03](https://keryn.dev/taxonomies/owasp-agentic/#asi03-identity-and-privilege-abuse)

**Fix:** After filepath.Join, call filepath.Clean and filepath.EvalSymlinks and verify strings.HasPrefix(result, base + separator); or use os.Root / securejoin which enforce containment.

**References:** [https://github.com/mark3labs/mcp-go](https://github.com/mark3labs/mcp-go) · [https://github.com/modelcontextprotocol/go-sdk](https://github.com/modelcontextprotocol/go-sdk) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

## seceng.mcp.go.tool-http-request-ssrf

`error` go data-flow rule mcp, go

An MCP tool handler requests a URL taken from a tool argument; the model can reach cloud metadata and internal services (SSRF). Allow-list hosts and block private ranges.

Confidence **P1**: dangerous in context. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [reaches](https://keryn.dev/docs/edges/edge-kinds/#reaches) content or traffic gets to a thing; it crosses the [`user->prompt`](https://keryn.dev/docs/edges/trust-boundaries/#user-to-prompt) boundary (untrusted input reaching a prompt).

[CWE-918](https://keryn.dev/taxonomies/cwe/#cwe-918-server-side-request-forgery) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation) [ASI03](https://keryn.dev/taxonomies/owasp-agentic/#asi03-identity-and-privilege-abuse)

**Fix:** Parse the URL, require https and a host on an allow-list, resolve the address and reject loopback, link-local (169.254.169.254) and RFC1918 ranges using a custom net.Dialer Control hook, and disable redirects or re-validate each hop.

**References:** [https://github.com/mark3labs/mcp-go](https://github.com/mark3labs/mcp-go) · [https://github.com/modelcontextprotocol/go-sdk](https://github.com/modelcontextprotocol/go-sdk) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

## seceng.mcp.go.tool-sql-string-built

`error` go data-flow rule mcp, go

An MCP tool handler runs a database/sql query built from a tool argument via string formatting or concatenation; the model can inject SQL. Use placeholders and bind the argument.

Confidence **P0**: exploitable as written. False-positive risk **low**: an exact API or flag, so hits are almost always real.

Edge inspected: [calls](https://keryn.dev/docs/edges/edge-kinds/#calls) one thing invokes another; it crosses the [`model->code`](https://keryn.dev/docs/edges/trust-boundaries/#model-to-code) boundary (model output reaching code, a shell, a query or a page).

[CWE-89](https://keryn.dev/taxonomies/cwe/#cwe-89-sql-injection) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [LLM05](https://keryn.dev/taxonomies/owasp-llm/#llm05-improper-output-handling) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation) [ASI05](https://keryn.dev/taxonomies/owasp-agentic/#asi05-unexpected-code-execution)

**Fix:** Use constant SQL with placeholders ($1 or ?) and pass tool arguments as bound parameters; allow-list identifiers (table or column names) explicitly; connect with a least-privilege, read-only database role.

**References:** [https://github.com/mark3labs/mcp-go](https://github.com/mark3labs/mcp-go) · [https://github.com/modelcontextprotocol/go-sdk](https://github.com/modelcontextprotocol/go-sdk) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

## seceng.mcp.go.token-passthrough

`error` go data-flow rule mcp, go

The inbound Authorization header (the MCP client's token) is copied onto an outgoing upstream request; the MCP authorization spec forbids token passthrough because the upstream token was not issued to this server. Obtain a separate upstream token (token exchange / OBO).

Confidence **P1**: dangerous in context. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [grants](https://keryn.dev/docs/edges/edge-kinds/#grants) authority is given or left unchecked.

[CWE-441](https://keryn.dev/rules/?cwe=CWE-441) [CWE-522](https://keryn.dev/taxonomies/cwe/#cwe-522-insufficiently-protected-credentials) [LLM02](https://keryn.dev/taxonomies/owasp-llm/#llm02-sensitive-information-disclosure) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI03](https://keryn.dev/taxonomies/owasp-agentic/#asi03-identity-and-privilege-abuse) [ASI07](https://keryn.dev/taxonomies/owasp-agentic/#asi07-insecure-inter-agent-communication)

**Fix:** Validate the inbound token for your own audience and do not forward it. Obtain a distinct upstream credential via OAuth token exchange (RFC 8693), an on-behalf-of flow or a service credential scoped to this server.

**References:** [https://modelcontextprotocol.io/specification/2025-06-18/basic/authorization](https://modelcontextprotocol.io/specification/2025-06-18/basic/authorization) · [https://modelcontextprotocol.io/docs/2025-11-25/tutorials/security/security_best_practices](https://modelcontextprotocol.io/docs/2025-11-25/tutorials/security/security_best_practices) · [https://github.com/mark3labs/mcp-go](https://github.com/mark3labs/mcp-go)

## seceng.mcp.go.mark3labs-http-bind-all

`warning` go mcp, go

mcp-go SSE / Streamable HTTP server started on all interfaces (":PORT" or 0.0.0.0). Without Origin/Host validation and authentication, any web page or LAN host can drive the tools (DNS rebinding). Bind 127.0.0.1 or front it with an authenticating proxy.

Confidence **P1**: dangerous in context. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [reaches](https://keryn.dev/docs/edges/edge-kinds/#reaches) content or traffic gets to a thing; it crosses the [`user->prompt`](https://keryn.dev/docs/edges/trust-boundaries/#user-to-prompt) boundary (untrusted input reaching a prompt).

[CWE-1327](https://keryn.dev/rules/?cwe=CWE-1327) [CWE-346](https://keryn.dev/taxonomies/cwe/#cwe-346-origin-validation-error) [CWE-306](https://keryn.dev/taxonomies/cwe/#cwe-306-missing-authentication-for-critical-function) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI07](https://keryn.dev/taxonomies/owasp-agentic/#asi07-insecure-inter-agent-communication) [ASI03](https://keryn.dev/taxonomies/owasp-agentic/#asi03-identity-and-privilege-abuse)

**Fix:** Bind to 127.0.0.1 for local servers. For network servers, wrap the handler in middleware that rejects requests whose Origin or Host header is not on an allow-list (spec: servers MUST validate Origin) and that verifies OAuth 2.1 access tokens issued for this resource.

**References:** [https://github.com/mark3labs/mcp-go](https://github.com/mark3labs/mcp-go) · [https://modelcontextprotocol.io/specification/2025-06-18/basic/transports](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports)

## seceng.mcp.go.go-sdk-http-bind-all

`warning` go mcp, go

Official Go SDK Streamable HTTP/SSE handler served on all interfaces with http.ListenAndServe(":PORT"). Without Origin/Host validation and authentication, any web page or LAN host can drive the tools. Bind loopback or add auth and Origin checks.

Confidence **P1**: dangerous in context. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [reaches](https://keryn.dev/docs/edges/edge-kinds/#reaches) content or traffic gets to a thing; it crosses the [`user->prompt`](https://keryn.dev/docs/edges/trust-boundaries/#user-to-prompt) boundary (untrusted input reaching a prompt).

[CWE-1327](https://keryn.dev/rules/?cwe=CWE-1327) [CWE-346](https://keryn.dev/taxonomies/cwe/#cwe-346-origin-validation-error) [CWE-306](https://keryn.dev/taxonomies/cwe/#cwe-306-missing-authentication-for-critical-function) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [ASI07](https://keryn.dev/taxonomies/owasp-agentic/#asi07-insecure-inter-agent-communication) [ASI03](https://keryn.dev/taxonomies/owasp-agentic/#asi03-identity-and-privilege-abuse)

**Fix:** Listen on 127.0.0.1 for local use. Wrap the mcp handler in middleware that validates Origin/Host against an allow-list and enforces bearer-token authentication (auth.RequireBearerToken) before the request reaches the MCP handler.

**References:** [https://github.com/modelcontextprotocol/go-sdk](https://github.com/modelcontextprotocol/go-sdk) · [https://modelcontextprotocol.io/specification/2025-06-18/basic/transports](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports)

## seceng.mcp.go.mark3labs-base-url-cleartext

`warning` go mcp, go

mcp-go server advertises a non-local `http://` base URL; the SSE message endpoint and any session identifiers are sent in cleartext. Use https:// behind TLS.

Confidence **P1**: dangerous in context. False-positive risk **low**: an exact API or flag, so hits are almost always real.

Edge inspected: [sends](https://keryn.dev/docs/edges/edge-kinds/#sends) data leaves for another party; it crosses the [`secret->outside`](https://keryn.dev/docs/edges/trust-boundaries/#secret-to-outside) boundary (a secret leaving the trusted side).

[CWE-319](https://keryn.dev/rules/?cwe=CWE-319) [LLM02](https://keryn.dev/taxonomies/owasp-llm/#llm02-sensitive-information-disclosure) [ASI07](https://keryn.dev/taxonomies/owasp-agentic/#asi07-insecure-inter-agent-communication)

**Fix:** Set WithBaseURL to an https:// origin terminated by TLS (directly or at a reverse proxy) and only use http:// for localhost development.

**References:** [https://github.com/mark3labs/mcp-go](https://github.com/mark3labs/mcp-go) · [https://modelcontextprotocol.io/specification/2025-06-18/basic/transports](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports)
