Skip to content

    Type a page, a command such as keryn scan, or a rule id.

    mcp-server-jvm-dotnet-rust-v1

    View as Markdown

    26 rules · Keryn Software Licence · rules 0.8.0 · all packs

    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.

    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 one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-78 CWE-88 LLM06 ASI05 ASI02

    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://docs.spring.io/spring-ai/reference/api/tools.html · https://modelcontextprotocol.io/specification/2025-06-18/server/tools

    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 one thing reads from another.

    CWE-22 CWE-200 LLM02 LLM06 ASI02 ASI03

    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://docs.spring.io/spring-ai/reference/api/tools.html · https://modelcontextprotocol.io/specification/2025-06-18/server/tools

    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 one thing writes to another.

    CWE-22 CWE-73 LLM06 ASI02 ASI03

    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://docs.spring.io/spring-ai/reference/api/tools.html · https://modelcontextprotocol.io/specification/2025-06-18/server/tools

    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 one thing reads from another.

    CWE-22 LLM06 ASI02 ASI03

    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://docs.spring.io/spring-ai/reference/api/tools.html · https://modelcontextprotocol.io/specification/2025-06-18/server/tools

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

    Section titled “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 one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-89 LLM06 LLM05 ASI02 ASI05

    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://docs.spring.io/spring-ai/reference/api/tools.html · https://modelcontextprotocol.io/specification/2025-06-18/server/tools

    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 content or traffic gets to a thing; it crosses the user->prompt boundary (untrusted input reaching a prompt).

    CWE-918 LLM06 ASI02 ASI03

    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://docs.spring.io/spring-ai/reference/api/tools.html · https://modelcontextprotocol.io/specification/2025-06-18/server/tools

    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 one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-94 CWE-470 LLM06 LLM05 ASI05 ASI02

    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://docs.spring.io/spring-ai/reference/api/tools.html · https://modelcontextprotocol.io/specification/2025-06-18/server/tools

    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 one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-78 CWE-88 LLM06 ASI05 ASI02

    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://csharp.sdk.modelcontextprotocol.io/ · https://modelcontextprotocol.io/specification/2025-06-18/server/tools

    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 one thing reads from another.

    CWE-22 CWE-200 LLM02 LLM06 ASI02 ASI03

    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://csharp.sdk.modelcontextprotocol.io/ · https://modelcontextprotocol.io/specification/2025-06-18/server/tools

    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 one thing writes to another.

    CWE-22 CWE-73 LLM06 ASI02 ASI03

    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://csharp.sdk.modelcontextprotocol.io/ · https://modelcontextprotocol.io/specification/2025-06-18/server/tools

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

    Section titled “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 one thing reads from another.

    CWE-22 LLM06 ASI02 ASI03

    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://csharp.sdk.modelcontextprotocol.io/ · https://modelcontextprotocol.io/specification/2025-06-18/server/tools

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

    Section titled “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 one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-89 LLM06 LLM05 ASI02 ASI05

    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://csharp.sdk.modelcontextprotocol.io/ · https://modelcontextprotocol.io/specification/2025-06-18/server/tools

    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 content or traffic gets to a thing; it crosses the user->prompt boundary (untrusted input reaching a prompt).

    CWE-918 LLM06 ASI02 ASI03

    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://csharp.sdk.modelcontextprotocol.io/ · https://modelcontextprotocol.io/specification/2025-06-18/server/tools

    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 authority is given or left unchecked.

    CWE-441 CWE-522 LLM02 LLM06 ASI03 ASI07

    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/docs/2025-11-25/tutorials/security/security_best_practices · https://github.com/modelcontextprotocol/csharp-sdk

    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 one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-78 CWE-88 LLM06 ASI05 ASI02

    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://docs.rs/rmcp/latest/rmcp/ · https://modelcontextprotocol.io/specification/2025-06-18/server/tools

    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 one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-78 CWE-88 LLM06 ASI05 ASI02

    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://docs.rs/rmcp/latest/rmcp/ · https://modelcontextprotocol.io/specification/2025-06-18/server/tools

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

    Section titled “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 one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-78 CWE-88 LLM06 ASI05 ASI02

    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://docs.rs/rmcp/latest/rmcp/ · https://modelcontextprotocol.io/specification/2025-06-18/server/tools

    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 one thing reads from another.

    CWE-22 CWE-200 LLM02 LLM06 ASI02 ASI03

    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://docs.rs/rmcp/latest/rmcp/ · https://modelcontextprotocol.io/specification/2025-06-18/server/tools

    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 one thing writes to another.

    CWE-22 CWE-73 LLM06 ASI02 ASI03

    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://docs.rs/rmcp/latest/rmcp/ · https://modelcontextprotocol.io/specification/2025-06-18/server/tools

    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 one thing writes to another.

    CWE-22 CWE-73 LLM06 ASI02 ASI03

    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://docs.rs/rmcp/latest/rmcp/ · https://modelcontextprotocol.io/specification/2025-06-18/server/tools

    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 content or traffic gets to a thing; it crosses the user->prompt boundary (untrusted input reaching a prompt).

    CWE-918 LLM06 ASI02 ASI03

    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://docs.rs/rmcp/latest/rmcp/ · https://modelcontextprotocol.io/specification/2025-06-18/server/tools

    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 one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-89 LLM06 LLM05 ASI02 ASI05

    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://docs.rs/rmcp/latest/rmcp/ · https://modelcontextprotocol.io/specification/2025-06-18/server/tools

    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 one thing reads from another.

    CWE-22 LLM06 ASI02 ASI03

    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://docs.rs/rmcp/latest/rmcp/ · https://modelcontextprotocol.io/specification/2025-06-18/server/tools

    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 one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-78 CWE-88 LLM06 ASI05 ASI02

    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://modelcontextprotocol.io/specification/2025-06-18/server/tools

    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 one thing reads from another.

    CWE-22 CWE-200 LLM02 LLM06 ASI02 ASI03

    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://modelcontextprotocol.io/specification/2025-06-18/server/tools

    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 content or traffic gets to a thing; it crosses the user->prompt boundary (untrusted input reaching a prompt).

    CWE-918 LLM06 ASI02 ASI03

    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://modelcontextprotocol.io/specification/2025-06-18/server/tools