# mcp-server-jvm-dotnet-rust-v1

> mcp-server-jvm-dotnet-rust-v1: 26 Keryn rules for java, csharp, rust, kotlin (22 error, 4 warning).

Source: https://keryn.dev/rules/mcp-server-jvm-dotnet-rust-v1/

26 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.java.tool-process-exec

`error` java data-flow rule mcp, java, spring-ai

A Spring AI @Tool / MCP SDK tool handler passes a String argument to ProcessBuilder or Runtime.exec; the model can run arbitrary commands. Use fixed argv and validate each value.

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:** Do not build the executable or shell line from a tool argument. Expose fixed commands, validate arguments against an allow-list or enum, pass them as discrete argv entries (never through a shell), drop privileges and require user approval for state-changing commands.

**References:** [https://github.com/modelcontextprotocol/java-sdk](https://github.com/modelcontextprotocol/java-sdk) · [https://docs.spring.io/spring-ai/reference/api/tools.html](https://docs.spring.io/spring-ai/reference/api/tools.html) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

## seceng.mcp.java.tool-files-read

`error` java data-flow rule mcp, java, spring-ai

A tool handler reads a file through java.nio.file.Files / FileInputStream using a path built from a tool argument; the model can read any file the JVM can. Canonicalise and check the root prefix.

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:** Resolve the argument against a fixed root, normalise it to a canonical/real path and verify the result still starts with the root before opening. Reject absolute paths and ".." segments, and do not follow symlinks out of the root.

**References:** [https://github.com/modelcontextprotocol/java-sdk](https://github.com/modelcontextprotocol/java-sdk) · [https://docs.spring.io/spring-ai/reference/api/tools.html](https://docs.spring.io/spring-ai/reference/api/tools.html) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

## seceng.mcp.java.tool-files-write

`error` java data-flow rule mcp, java, spring-ai

A tool handler writes, copies or deletes files at a path from a tool argument; prompt injection can overwrite or remove arbitrary files. 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:** Confine writes and deletes to a dedicated directory by canonicalising the path and checking the root prefix; refuse absolute paths and symlinks, and put destructive tools behind explicit user approval (tool annotations destructiveHint).

**References:** [https://github.com/modelcontextprotocol/java-sdk](https://github.com/modelcontextprotocol/java-sdk) · [https://docs.spring.io/spring-ai/reference/api/tools.html](https://docs.spring.io/spring-ai/reference/api/tools.html) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

## seceng.mcp.java.tool-new-file-unchecked

`warning` java data-flow rule mcp, java, spring-ai

A tool argument is turned into a java.io.File without a canonical-path containment check (getCanonicalPath/toRealPath + startsWith); "../" escapes the intended directory.

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 joining the argument onto the base, canonicalise the result and verify it starts with the canonical base directory; reject the request otherwise.

**References:** [https://github.com/modelcontextprotocol/java-sdk](https://github.com/modelcontextprotocol/java-sdk) · [https://docs.spring.io/spring-ai/reference/api/tools.html](https://docs.spring.io/spring-ai/reference/api/tools.html) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

## seceng.mcp.java.tool-jdbc-statement-concat

`error` java data-flow rule mcp, java, spring-ai

A tool handler passes a tool argument into a JDBC Statement / JdbcTemplate SQL string; concatenation lets the model inject SQL. Use PreparedStatement placeholders.

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 text with bound parameters (?, $1, @p) and pass tool arguments only as parameter values; allow-list identifiers; connect with a least-privilege, preferably read-only, database account.

**References:** [https://github.com/modelcontextprotocol/java-sdk](https://github.com/modelcontextprotocol/java-sdk) · [https://docs.spring.io/spring-ai/reference/api/tools.html](https://docs.spring.io/spring-ai/reference/api/tools.html) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

## seceng.mcp.java.tool-url-fetch

`error` java data-flow rule mcp, java, spring-ai

A tool handler builds a URL / URI / REST call from a tool argument; the model can reach internal services and cloud metadata. Allow-list hosts and block private addresses.

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 block loopback, link-local (169.254.169.254) and private ranges, and disable or re-validate redirects.

**References:** [https://github.com/modelcontextprotocol/java-sdk](https://github.com/modelcontextprotocol/java-sdk) · [https://docs.spring.io/spring-ai/reference/api/tools.html](https://docs.spring.io/spring-ai/reference/api/tools.html) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

## seceng.mcp.java.tool-eval-or-class-load

`error` java data-flow rule mcp, java, spring-ai

A tool handler evaluates a tool argument as script, SpEL or loads a class by name; the model gets code execution in the JVM. Dispatch through a fixed table instead.

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

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-94](https://keryn.dev/taxonomies/cwe/#cwe-94-code-injection) [CWE-470](https://keryn.dev/rules/?cwe=CWE-470) [LLM06](https://keryn.dev/taxonomies/owasp-llm/#llm06-excessive-agency) [LLM05](https://keryn.dev/taxonomies/owasp-llm/#llm05-improper-output-handling) [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 evaluate model-supplied strings as code or load classes by name from tool arguments. Dispatch through an allow-listed table of fixed operations.

**References:** [https://github.com/modelcontextprotocol/java-sdk](https://github.com/modelcontextprotocol/java-sdk) · [https://docs.spring.io/spring-ai/reference/api/tools.html](https://docs.spring.io/spring-ai/reference/api/tools.html) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

## seceng.mcp.csharp.tool-process-start

`error` csharp data-flow rule mcp, csharp, dotnet

An [McpServerTool] method passes one of its parameters to Process.Start / ProcessStartInfo; the model can run arbitrary programs or inject arguments. Use a fixed executable and ArgumentList entries.

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:** Do not build the executable or shell line from a tool argument. Expose fixed commands, validate arguments against an allow-list or enum, pass them as discrete argv entries (never through a shell), drop privileges and require user approval for state-changing commands.

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

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

`error` csharp data-flow rule mcp, csharp, dotnet

An [McpServerTool] method reads a file whose path is a tool parameter; the model can read any file the process can. Resolve against a fixed root with Path.GetFullPath and verify StartsWith(root).

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:** Resolve the argument against a fixed root, normalise it to a canonical/real path and verify the result still starts with the root before opening. Reject absolute paths and ".." segments, and do not follow symlinks out of the root.

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

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

`error` csharp data-flow rule mcp, csharp, dotnet

An [McpServerTool] method writes, moves or deletes files at a path from a tool parameter; prompt injection can overwrite or remove arbitrary files. 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:** Confine writes and deletes to a dedicated directory by canonicalising the path and checking the root prefix; refuse absolute paths and symlinks, and put destructive tools behind explicit user approval (tool annotations destructiveHint).

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

## seceng.mcp.csharp.tool-path-combine-unchecked

`warning` csharp data-flow rule mcp, csharp, dotnet

A tool parameter is combined with a base directory via Path.Combine without a GetFullPath + StartsWith containment check; Path.Combine discards the base for absolute inputs and allows "..".

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 joining the argument onto the base, canonicalise the result and verify it starts with the canonical base directory; reject the request otherwise.

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

## seceng.mcp.csharp.tool-sql-command-interpolated

`error` csharp data-flow rule mcp, csharp, dotnet

An [McpServerTool] method builds SQL by interpolating or concatenating a tool parameter into a command text; the model can inject SQL. Use parameters (@p) via SqlParameter.

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 text with bound parameters (?, $1, @p) and pass tool arguments only as parameter values; allow-list identifiers; connect with a least-privilege, preferably read-only, database account.

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

## seceng.mcp.csharp.tool-http-client-url

`error` csharp data-flow rule mcp, csharp, dotnet

An [McpServerTool] method sends an HttpClient request to a URL taken from a tool parameter; the model can reach internal services and cloud metadata. 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 block loopback, link-local (169.254.169.254) and private ranges, and disable or re-validate redirects.

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

## seceng.mcp.csharp.token-passthrough

`error` csharp data-flow rule mcp, csharp, dotnet

The inbound Authorization header (the MCP client token) is forwarded on an outgoing HttpClient request; the MCP authorization spec forbids token passthrough. Acquire a separate upstream token (OBO / token exchange).

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:** Do not forward the inbound MCP access token to upstream APIs (spec: token passthrough is forbidden). Validate the token for this server only and obtain a separate upstream credential via token exchange or a server-held credential.

**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/modelcontextprotocol/csharp-sdk](https://github.com/modelcontextprotocol/csharp-sdk)

## seceng.mcp.rust.tool-command-new

`error` rust data-flow rule mcp, rust, rmcp

An rmcp #[tool] handler passes a parameter to Command::new as the program; the model picks the binary. Use a fixed program and validated arguments.

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:** Do not build the executable or shell line from a tool argument. Expose fixed commands, validate arguments against an allow-list or enum, pass them as discrete argv entries (never through a shell), drop privileges and require user approval for state-changing commands.

**References:** [https://github.com/modelcontextprotocol/rust-sdk](https://github.com/modelcontextprotocol/rust-sdk) · [https://docs.rs/rmcp/latest/rmcp/](https://docs.rs/rmcp/latest/rmcp/) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

## seceng.mcp.rust.tool-shell-c

`error` rust data-flow rule mcp, rust, rmcp

An rmcp #[tool] handler builds a `sh -c` / `bash -c` line from a parameter, giving shell injection. Run a fixed program with discrete arguments instead.

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:** Do not build the executable or shell line from a tool argument. Expose fixed commands, validate arguments against an allow-list or enum, pass them as discrete argv entries (never through a shell), drop privileges and require user approval for state-changing commands.

**References:** [https://github.com/modelcontextprotocol/rust-sdk](https://github.com/modelcontextprotocol/rust-sdk) · [https://docs.rs/rmcp/latest/rmcp/](https://docs.rs/rmcp/latest/rmcp/) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

## seceng.mcp.rust.tool-command-arg-injection

`warning` rust data-flow rule mcp, rust, rmcp

An rmcp #[tool] handler appends a parameter to a child process argv with .arg/.args; options such as "-o" or "--exec" can be smuggled in. Validate against an allow-list or insert "--" before user data.

Confidence **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.

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:** Do not build the executable or shell line from a tool argument. Expose fixed commands, validate arguments against an allow-list or enum, pass them as discrete argv entries (never through a shell), drop privileges and require user approval for state-changing commands.

**References:** [https://github.com/modelcontextprotocol/rust-sdk](https://github.com/modelcontextprotocol/rust-sdk) · [https://docs.rs/rmcp/latest/rmcp/](https://docs.rs/rmcp/latest/rmcp/) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

## seceng.mcp.rust.tool-fs-read

`error` rust data-flow rule mcp, rust, rmcp

An rmcp #[tool] handler reads a file whose path is a parameter; the model can read any file the process can. Canonicalize and verify the path stays under a fixed root.

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:** Resolve the argument against a fixed root, normalise it to a canonical/real path and verify the result still starts with the root before opening. Reject absolute paths and ".." segments, and do not follow symlinks out of the root.

**References:** [https://github.com/modelcontextprotocol/rust-sdk](https://github.com/modelcontextprotocol/rust-sdk) · [https://docs.rs/rmcp/latest/rmcp/](https://docs.rs/rmcp/latest/rmcp/) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

## seceng.mcp.rust.tool-fs-write

`error` rust data-flow rule mcp, rust, rmcp

An rmcp #[tool] handler writes or creates a file at a path from a parameter; prompt injection can overwrite arbitrary files. 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:** Confine writes and deletes to a dedicated directory by canonicalising the path and checking the root prefix; refuse absolute paths and symlinks, and put destructive tools behind explicit user approval (tool annotations destructiveHint).

**References:** [https://github.com/modelcontextprotocol/rust-sdk](https://github.com/modelcontextprotocol/rust-sdk) · [https://docs.rs/rmcp/latest/rmcp/](https://docs.rs/rmcp/latest/rmcp/) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

## seceng.mcp.rust.tool-fs-remove

`error` rust data-flow rule mcp, rust, rmcp

An rmcp #[tool] handler deletes a path from a parameter (remove\_file / remove\_dir\_all). Confine to a fixed root and require user confirmation.

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 containment on the canonical path, prefer single-file removal over recursive deletion, and require user confirmation for destructive tools.

**References:** [https://github.com/modelcontextprotocol/rust-sdk](https://github.com/modelcontextprotocol/rust-sdk) · [https://docs.rs/rmcp/latest/rmcp/](https://docs.rs/rmcp/latest/rmcp/) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

## seceng.mcp.rust.tool-reqwest-url

`error` rust data-flow rule mcp, rust, rmcp

An rmcp #[tool] handler requests a URL taken from a parameter with reqwest/ureq; the model can reach internal services and cloud metadata. 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 block loopback, link-local (169.254.169.254) and private ranges, and disable or re-validate redirects.

**References:** [https://github.com/modelcontextprotocol/rust-sdk](https://github.com/modelcontextprotocol/rust-sdk) · [https://docs.rs/rmcp/latest/rmcp/](https://docs.rs/rmcp/latest/rmcp/) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

## seceng.mcp.rust.tool-sqlx-query-format

`error` rust data-flow rule mcp, rust, rmcp

An rmcp #[tool] handler passes a format!-built string to sqlx::query / query\_as; the parameter becomes part of the SQL text. Use `$1` placeholders and .bind().

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 text with bound parameters (?, $1, @p) and pass tool arguments only as parameter values; allow-list identifiers; connect with a least-privilege, preferably read-only, database account.

**References:** [https://github.com/modelcontextprotocol/rust-sdk](https://github.com/modelcontextprotocol/rust-sdk) · [https://docs.rs/rmcp/latest/rmcp/](https://docs.rs/rmcp/latest/rmcp/) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

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

`warning` rust data-flow rule mcp, rust, rmcp

A parameter is joined onto a base path with .join() but no canonicalize + starts\_with containment check is visible; absolute inputs replace the base and ".." escapes 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) [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 joining the argument onto the base, canonicalise the result and verify it starts with the canonical base directory; reject the request otherwise.

**References:** [https://github.com/modelcontextprotocol/rust-sdk](https://github.com/modelcontextprotocol/rust-sdk) · [https://docs.rs/rmcp/latest/rmcp/](https://docs.rs/rmcp/latest/rmcp/) · [https://modelcontextprotocol.io/specification/2025-06-18/server/tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools)

## seceng.mcp.kotlin.tool-process-builder

`error` kotlin data-flow rule mcp, kotlin

A Kotlin MCP SDK addTool handler passes a tool argument to ProcessBuilder / Runtime.exec; the model can run arbitrary commands. Use a fixed argv and validate each value.

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:** Do not build the executable or shell line from a tool argument. Expose fixed commands, validate arguments against an allow-list or enum, pass them as discrete argv entries (never through a shell), drop privileges and require user approval for state-changing commands.

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

## seceng.mcp.kotlin.tool-file-access

`error` kotlin data-flow rule mcp, kotlin

A Kotlin MCP SDK addTool handler opens a File / Path built from a tool argument; the model can read or overwrite arbitrary files. Canonicalise and check the root prefix.

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:** Resolve the argument against a fixed root, normalise it to a canonical/real path and verify the result still starts with the root before opening. Reject absolute paths and ".." segments, and do not follow symlinks out of the root.

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

## seceng.mcp.kotlin.tool-url-fetch

`error` kotlin data-flow rule mcp, kotlin

A Kotlin MCP SDK addTool handler opens a URL / URI from a tool argument; the model can reach internal services and cloud metadata. 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 block loopback, link-local (169.254.169.254) and private ranges, and disable or re-validate redirects.

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