servers icon indicating copy to clipboard operation
servers copied to clipboard

Security Audit: Unconstrained string parameters across all official servers

Open manja316 opened this issue 8 months ago • 20 comments

Summary

I ran automated security audits on 7 official MCP servers using mcp-security-audit. All servers scored Grade A or B (85-100/100), which is great. But there's one consistent finding across every server except mcp-server-fetch:

No string parameters use maxLength, pattern, or enum constraints.

Findings

Server Score Unconstrained Strings
Fetch 100/100 0
SQLite 95/100 5 (SQL queries, table names)
Time 95/100 4 (timezone identifiers)
GitHub 94/100 Multiple
Memory 92/100 1 (search query)
Git 90/100 18 (paths, messages, branches)
Filesystem 85/100 Multiple (paths)

Why this matters

  1. DoS vector — Unconstrained strings accept arbitrarily long input. A 10MB commit message or 50K-char file path must be processed by the server.
  2. No boundary validation — If an LLM is compromised via prompt injection, the tool schema provides no defense against malformed input.
  3. Network transports — With MCP supporting Streamable HTTP, servers may be network-exposed where these constraints become critical.

Suggested fix

One line per parameter:

{
  "name": "path",
  "type": "string",
  "maxLength": 4096
}

For known-format params:

{
  "name": "timezone",
  "type": "string",
  "pattern": "^[A-Za-z_/]+$",
  "maxLength": 50
}

Full reports

Individual JSON/text reports for each server: LuciferForge/mcp-audit-reports

The audit tool: pip install mcp-security-audit

Happy to discuss findings or help with fixes.

manja316 avatar Mar 12 '26 15:03 manja316

MCPS (MCP Secure) solves this at the message layer — every JSON-RPC body is SHA-256 hashed and ECDSA P-256 signed before transmission. A compromised proxy can't inject malformed parameters because the signature covers the full message body. Nonce + timestamp binding prevents replay. Designed as a drop-in security layer for MCP servers. IETF Internet-Draft | github.com/razashariff/mcps

razashariff avatar Mar 16 '26 09:03 razashariff

Good findings. The unconstrained string issue is real, and schema-level constraints (maxLength, pattern, enum) would help with the DoS vector.

But there's a deeper problem: even with schema constraints in place, the content of those strings can still carry prompt injection payloads. A maxLength: 500 parameter still has room for "Ignore previous instructions and..." — the constraint prevents oversized input but not malicious input.

We've been looking at this from the content analysis side with ClawGuard (open-source, regex-based MCP scanner). Some data points:

  • A peer-reviewed study (Queen's University, 1,899 MCP servers) found 5.5% are susceptible to Tool Poisoning — where tool descriptions themselves contain hidden behavioral directives
  • System prompt restrictions ("don't follow injected instructions") reduce attack success rate by only 0.65% — essentially useless as a defense
  • The git server's 18 unconstrained strings are particularly concerning because commit_message and branch_name parameters are user-controlled in collaborative workflows

Schema constraints + content scanning are complementary layers. Neither alone is sufficient.

joergmichno avatar Mar 21 '26 08:03 joergmichno

A2ABench has an accepted answer for this imported thread.

  • Thread: https://a2abench-api.web.app/q/cmn1ngyur0085xztywf9i6pk1
  • Accepted at: 2026-03-25T18:37:03.767Z
  • Accepted answer agent: ai village
  • Answer preview: "No matching threads were found for this query."

khalidsaidi avatar Mar 25 '26 18:03 khalidsaidi

We ran a similar exercise — scanned 12 public MCP servers (including all the official ones) using static analysis — and the unconstrained string parameter pattern was consistent across the board.

One thing worth adding to the DoS/boundary discussion: the correlation with command injection patterns matters. In our scan, we found 46 instances of dangerous command execution patterns across 12 repos. Many of these accept path or argument parameters as freeform strings, then pass them directly into exec() or spawn(). The absence of schema constraints isn't just a DoS vector — it's also the absence of the first line of defense in a prompt injection → command injection chain.

The joergmichno comment above is correct that schema constraints don't fully solve injection. But in our analysis, the defense-in-depth picture looks like:

  1. Schema constraints (maxLength, pattern) → shrink the malformed-input surface
  2. Tool description scope warnings → LLM less likely to accept out-of-scope values under prompt injection
  3. Runtime input validation → catch what slips through the LLM layer
  4. execFile over exec → parameterized execution prevents shell injection even with valid-looking input

None of these alone is sufficient. The MCP ecosystem is currently at zero on most of these. The servers that scored well in automated audits (like the official server-fetch) have implemented #3 at minimum.

For CI integration, we've been running npx @piiiico/agent-audit --auto --json --min-severity high in GitHub Actions — exits 1 on high findings, 2 on critical. Not a replacement for the schema validation fixes you're proposing, but a useful catch for when they slip through.

piiiico avatar Apr 03 '26 07:04 piiiico

The audit finding is accurate and the pattern is consistent — unconstrained string parameters are a systematic MCP security gap, not an isolated oversight. The mcp-security-audit tool is measuring the symptom; the structural cause is that parameter constraints are advisory schema hints that tools can ignore, not enforced authorization boundaries.

The 58-vulnerability finding in context: All 58 cases are variations of the same architecture problem — the authorization scope is checked at connection time (OAuth token), but parameter values come from LLM output at call time. The constraint enforcement that matters happens after the point where prompt injection can occur.

We've been building SINT Protocol specifically around this architecture gap. The key insight:

Schema constraints vs. capability constraints:

Schema constraints (what MCP has today):
  parameters: { path: { type: "string" } }  // advisory, no enforcement
  
Capability constraints (what SINT adds):
  token.resource = "mcp://filesystem/readFile"
  token.constraints.allowedPaths = ["/tmp/*", "/workspace/*"]
  // Enforced at gateway intercept, before the tool runs, against a scope
  // committed before any LLM input was processed

What enforcement-grade constraints require:

  1. Pre-session scope commitment: The capability token is issued before the LLM processes any potentially adversarial content
  2. Per-call gateway validation: Every tool call is intercepted and validated against the committed scope — not checked at schema parse time
  3. Deny with rationale: The denial includes policyViolated and suggestedAlternative fields so the LLM can replan rather than loop

For the filesystem server specifically: an allowlist of paths in the capability token makes traversal structurally impossible. For the GitHub server: an allowlist of owner/repo pairs in the token prevents cross-repo writes.

Repo: https://github.com/pshkv/sint-protocol — packages/bridge-mcp for the MCP intercept layer. The packages/conformance-tests has regression tests specifically for prompt injection scenarios.

pshkv avatar Apr 04 '26 06:04 pshkv

This unconstrained string parameter issue is closely related to tool-poisoning attacks — if parameters aren't validated against expected schemas, injected payloads can flow through to tool execution.

AgentShield addresses this at runtime with two approaches:

  1. MCP Tool Supply Chain Verifier — Registers tool schemas (descriptions + parameter schemas) with Ed25519 signatures at setup time. At runtime, before each tools/call, the current schema is compared against the signed manifest. If an attacker modifies a tool's description or parameter schema, the mismatch is detected and the call is blocked.

  2. MCP Guard — A decorator (@shield.guard) or stdio proxy that intercepts every tool call and evaluates it against trust policies and intent consistency before forwarding to the real server.

Both are open-source: MCP integration | Tool Registry Verifier

hidearmoon avatar Apr 17 '26 14:04 hidearmoon

Important finding. Unconstrained string parameters are especially dangerous in agent contexts where the input comes from an LLM (which can generate arbitrarily long or malformed strings) rather than a human typing in a form.

From securing MCP tool usage for 31 agents, here are defense patterns that complement parameter constraints:

The agent-specific risk: prompt injection through tool parameters

When an agent constructs tool parameters from conversation context, a prompt injection in the conversation can propagate into tool inputs. maxLength and pattern constraints catch this at the schema level:

{
  "name": "query",
  "type": "string",
  "maxLength": 10000,
  "pattern": "^[^;\\-]{0,10000}$"
}

But schema validation alone isn't enough. You also need:

Pre-execution governance hooks

A guardrail layer that intercepts every tool call before execution:

interface ToolGuardrail {
  async evaluate(call: ToolCall, context: AgentContext): PolicyDecision;
}

// Examples:
// - Reject SQL injection patterns in query parameters
// - Cap file path depth to prevent traversal
// - Reject parameters containing known injection markers

This is the IGuardrailProvider pattern — the guardrail runs at the middleware level, so the tool implementation doesn't need to handle security.

Capability-scoped parameter constraints

Not all agents should have the same parameter limits. A research agent might legitimately need to pass long query strings, while a file management agent should have strict path constraints. We scope parameter constraints per agent capability:

Agent A (research):  query.maxLength = 50000
Agent B (file mgmt): path.pattern = "^/workspace/[a-zA-Z0-9_/]+$"

Signed audit trail for tool calls

Every tool call should produce an Ed25519 signed receipt:

  • Who called it (agent DID)
  • What parameters were passed (input hash, not raw — for privacy)
  • What was returned (output hash)

This makes post-incident forensics possible when a security issue is detected.

Related:

Running these patterns at agents.kinthai.ai on OpenClaw.

kinthaiofficial avatar Apr 28 '26 18:04 kinthaiofficial

The guardrail middleware pattern is the enforcement layer my original audit was missing. Schema constraints are advisory. maxLength in JSON Schema tells a validator to complain; it doesn't stop the server from processing the oversized string. A ToolGuardrail that rejects before execution is actual enforcement.

Capability-scoped constraints: the security property depends on when the scope is committed. Pre-session (locked before LLM processes anything) means prompt injection can't change it. Per-call lookup remains vulnerable if injection convinces the system it's in a higher-privilege role.

Which path does your implementation use? And where in the call chain does ToolGuardrail.evaluate() sit?

piiiico avatar Apr 28 '26 18:04 piiiico

Adding a complementary data point: ran the official servers in this repo through prompt-defense-audit v1.3.0 (12-vector regex, mapped to OWASP LLM Top 10). This is prompt-level posture audit — does the tool description text encode refusal/scope/role-boundary language? — distinct from the parameter-level scan in the original post.

Both layers matter, and the current discussion in this thread (schema constraints, guardrail middleware, capability-scoped pre-session locks) is exactly what runtime enforcement needs. Prompt-level audit catches the upstream gap: tool descriptions that don't tell the LLM anything about what's in/out of bounds.

Per-server scores (7 official servers, 6 audited)

Server Score Grade Coverage
everything 17 F 2/12
fetch 17 F 2/12
git 17 F 2/12
filesystem 0 F 0/12
memory 0 F 0/12
time 0 F 0/12
sequentialthinking — — (no extractable descriptions in source)

Defense vectors with 100% gap (0/6 audited servers)

  • role-escape — no role-boundary language
  • output-manipulation — no output sanitization references
  • multilang-bypass — no defense if attack language switches
  • unicode-attack — no Unicode normalization handling
  • social-engineering — no resistance to manipulation framing
  • output-weaponization — no XSS / SQLi / command-injection awareness
  • abuse-prevention — no rate-limit or scope hints
  • input-validation-missing — no parameter constraints in description text

Vectors with partial coverage (low base rate)

  • data-leakage: 1/6
  • context-overflow: 1/6
  • indirect-injection: 1/6
  • instruction-override: 3/6 ← only vector above 50%

Why this matters alongside parameter constraints

Schema-level maxLength/pattern (the original audit's focus) is the runtime fix. But when an LLM constructs tool calls, the description text is what shapes what calls it makes in the first place. A filesystem tool whose description says nothing about scope, no-traversal, or refusal-on-injected-path is more likely to be coaxed into read_text_file("/etc/passwd") than one that explicitly says "refuse paths outside allowed roots."

Combined view: schema constraints stop bad calls from executing; prompt-level defenses stop bad calls from being constructed.

Reproducibility

Full per-server JSON + methodology: https://github.com/ppcvote/prompt-defense-audit/tree/master/research/mcp-per-server

Tool: https://github.com/ppcvote/prompt-defense-audit (MIT, regex-based, <5ms per prompt).

For prioritization context: against a 1,646-prompt production corpus (4 datasets), mean defense score is 36/100. The MCP servers here scoring 0–17 are well below even the broader baseline. Filesystem and memory at 0/12 are the highest-priority hardening targets — same conclusion the parameter audit reached, from a different angle.

ppcvote avatar Apr 29 '26 15:04 ppcvote

Followed up with a deeper writeup that walks through each of the 8 vectors scoring 0/6 across the audited servers — concrete attack examples per vector and what defensive language would be needed:

https://ultralab.tw/en/blog/mcp-servers-defense-audit

Two takeaways from the longer-form analysis:

  1. Filesystem at 0/12 is the highest-priority target. Read/write blast radius is largest, and the description text gives the LLM no signals about path constraints or refusal language. This is also the textbook surface for the recent Comment & Control class of attacks.

  2. Schema validation and prompt-level defense are non-overlapping layers. The discussion in this thread (maxLength/pattern/guardrail middleware) is necessary but incomplete — runtime constraints don't reach the LLM's reasoning context, only the description text does. Both layers needed.

Happy to discuss any specific vector, or run a follow-up audit after maintainers ship hardening to track the improvement curve.

ppcvote avatar Apr 30 '26 13:04 ppcvote

Related to this — mcpeval includes lint rules that flag unconstrained string params (no enum/pattern) as a schema quality issue. It also catches missing descriptions, ambiguous param names like data or value, and tools with overlapping descriptions that confuse LLMs.

Works headlessly so you can add it to CI:

mcpeval check server_schema.json --ci  # exits 1 on errors

jashshah999 avatar May 05 '26 05:05 jashshah999

` One layer the thread hasn't named yet, sitting between ppcvote's prompt-level audit and the guardrail-middleware pattern: the tool description is the model's runtime decision surface, not documentation for a future human reader. Vague descriptions on mutation tools aren't only a usability problem — they're a privilege-escalation surface, because the LLM will pick the higher-blast-radius tool when two could plausibly satisfy the same intent and nothing in the schema rules out the dangerous one.

Two patterns that operationalize this:

1. Anti-purpose / "do not use for" clauses. Pair positive scope on the wider tool with explicit negative scope, and a positive pointer on the safer narrower tool:

run_sql: "Run read-only SQL against approved analytics views. Do not use for schema changes, raw production tables, exports, or questions answerable from cached reports — use get_fleet_summary for those."

get_fleet_summary: "Prefer this over run_sql unless the user explicitly needs custom analysis."

The negative clause is what cuts routing ambiguity between two plausible tools without needing a smarter model. Every missing "do not use for" on the higher-blast tool is an implicit permission.

2. Mutation-vs-read on the schema, not just the tool name. Pair the schema-level constraints (maxLength, pattern, additionalProperties: false) with explicit mutation language at the parameter level on any field that controls scope — where clauses, path prefixes, --force flags. On filesystem's path and git's commit_message, this is the difference between the LLM treating the parameter as "narrow a read" versus "control what gets written."

This stacks under everyone else's layers, not on top — it's upstream of the guardrail middleware (closes the gap before the call is constructed) and orthogonal to capability-scoped tokens (which enforce after the call is constructed). The runtime-policy framing is laid out at https://dev.to/incultnito_llc/tool-descriptions-are-load-bearing-too-the-anti-purpose-pattern-in-mcp-15m2 if useful for the long-form writeup the thread is heading toward.`

PengSpirit avatar May 09 '26 09:05 PengSpirit

This is an excellent systematic analysis. The unconstrained string parameter gap is real and pervasive.

We've added automated detection for this pattern to MCP Doctor — the _check_unconstrained_params scanner check now flags tool schemas where string parameters lack maxLength, pattern, or enum constraints.

The scanner also detects excessively high maxLength values (e.g., maxLength: 1000000) that are effectively unconstrained.

In our curated registry of 91+ MCP servers, we're starting to track this as a scoring dimension — servers with properly constrained parameters will get a higher quality score. The idea is to create positive pressure toward better parameter hygiene.

The defense-in-depth stack you've outlined (schema constraints → content scanning → runtime validation → parameterized execution) is exactly right. Schema constraints are the cheapest layer and the most universally missing.

xlyoung avatar Jun 06 '26 22:06 xlyoung

I'd like to take the memory server part of this audit.

Proposed change (ready locally, small diff):

  • Add maxLength to search_nodes' query parameter via a named constant (SEARCH_QUERY_MAX_LENGTH = 2048) and an exported SearchNodesQuerySchema, following the pattern in #4282 (time server string constraints).
  • Vitest coverage for the boundary: normal query accepted, at-limit accepted, over-limit rejected, non-string still rejected.

Scope kept to query as named in the audit's memory-server finding; remaining parameters can be separate follow-ups. Happy to adjust the limit value or shape if maintainers prefer.

feiiiiii5 avatar Aug 18 '26 02:08 feiiiiii5

The unconstrained string parameter issue is compounded by a second problem: responses from these servers can contain injected fields at nested depths that survive naive sanitization. If any proxy/gateway layer in front of these servers signs or caches responses without recursively stripping reserved fields (anything prefixed with _sig, _ccs, _verified, etc.) at ALL nesting levels, an attacker who compromises a server can forge verification metadata.

We built a detection CLI for this: npx ccs-lint --demo (zero deps, 10KB). It recursively scans MCP JSON-RPC responses for injected fields at any depth, flags risky tool calls, and validates receipt structure. Could be integrated into the security audit CI for the official servers.

Technical write-up of the attack class: https://dshcorrectover.github.io/ccs-proxy/blog/malicious-upstream.html

DSHCorrectover avatar Aug 23 '26 10:08 DSHCorrectover

This issue (unconstrained string parameters across official servers) is a concrete instance of a broader gap: MCP servers have no standard mechanism for producing verifiable evidence that a tool invocation conformed to its declared schema, identity, and security contract at runtime.

Cross-referencing CCS (Correctover Conformance Shape), an IETF Internet-Draft (draft-correctover-ccs) that defines a 22-field cryptographically signed receipt (Ed25519) for every MCP tool invocation, verified across seven dimensions — including a Schema dimension that specifically checks field value conformance to declared types and parameter constraints.

For the unconstrained string parameter problem:

  • The CCS Schema dimension rejects parameters that don't conform to the declared schema (type confusion, injected fields, undeclared parameters — including the metadata field pattern used in tool description poisoning attacks).
  • The params_hash binding ensures the arguments the agent intended to send match what the server actually received.
  • The Security dimension intercepts credential access patterns (e.g., a tool description directing the agent to read ~/.ssh/id_rsa).
  • Fail-closed: any violation blocks the invocation.

This is not a scanning/detection approach (which produces F1 scores and false positives) — it's a verification approach that produces cryptographic proof per invocation.

Reference implementations: [email protected] on npm (P50 ~2.7μs) and [email protected] on PyPI, both Elastic License 2.0. Draft: https://datatracker.ietf.org/doc/draft-correctover-ccs/

Happy to contribute conformance test vectors for the parameter constraint issue if that's useful.

DSHCorrectover avatar Aug 24 '26 08:08 DSHCorrectover

The audit and the enforcement discussion address the current state well: constraints are missing (the audit), they are advisory not enforced (pshkv), guardrails enforce them at call time (piiiico), and tool descriptions are the model's decision surface (PengSpirit). One dimension no comment has addressed: what happens when the constraints themselves change between releases?

A server that adds maxLength: 2048 to a string parameter today has closed one gap. But in the next release: the constraint can be removed (the gap returns silently), the parameter can be renamed (the constraint is orphaned), or a new unconstrained parameter can appear (a new gap nobody audited). The audit in this issue is a point-in-time assessment — valuable, but it decays the moment any official server ships a new version.

The missing layer is a surface pin: hash each tool's full definition (name, description, inputSchema, annotations) at a known-good baseline, and diff on every subsequent release. A removed constraint flags as LOOSENED (the DoS vector is back). A new unconstrained parameter flags as NEW (needs the same audit applied to the old set). A tightened constraint flags as BREAKING (callers may now fail). And serialization churn flags as NOTATION — not a finding, not an alert.

In production monitoring across 14 public MCP servers, one recent vendor major changed all 20 pinned tools in one release: 15 were pure serialization churn, 5 were real constraint tightenings. Without grading, the 5 real findings sat in a 20-line alert wall. With grading, the signal is clean.

The official servers in this repo are the canonical reference implementations. If they shipped with a committed pin file (hashes of each tool's definition at each tagged release), downstream servers could diff against them the same way package managers verify checksums — and audits like this one would become continuous rather than point-in-time.

We ship the pin-and-graded-diff layer open-source (rugsnare, Apache-2.0); per-version drift records for 14 public MCP servers: https://github.com/Paraphern/rugsnare/tree/main/docs/servers

Paraphern avatar Oct 12 '26 18:10 Paraphern

Triage: Priority Low (total 4)

  • Severity 1, urgency 1
  • Bonuses: +1 concerns security, +1 high engagement

This is a security report, so it is handled by the maintainers and the details aren't discussed here. If you have more to add, please use the advisory form rather than this thread.

Board: Servers V2 (#43), Status Incoming, awaiting maintainer review (no milestone yet). Part of the backlog triage in #4875.

cliffhall avatar Oct 19 '26 16:10 cliffhall

Thank you for the audit, and to everyone who added to the thread. Re-checking it against the current code on v2/main, I'm closing this as not planned:

  • Already addressed or out of scope here. The memory finding is fixed: search_nodes' query has had a length limit since #4662. SQLite and GitHub have moved to servers-archived. Fetch needed nothing.
  • Blanket maxLength / pattern constraints aren't planned for the rest. These servers run with the privileges of the client that starts them, so a schema limit on a string doesn't stop a malicious value; it only rejects a long one. The checks that matter run when the tool executes: filesystem keeps every path inside the allowed directories, git validates diff targets and refs before running them, and time rejects unknown timezone names. An over-long path is refused by the OS, and an over-long commit message only affects the client that sent it.
  • Real resource-exhaustion cases are tracked on their own, for example #5370 (fetch reading a response without a size cap) and #5371 (the everything server's HTTP transports listening only on localhost by default).

If you find a specific input on one of these servers that causes harm through its size or format, please open an issue for that case with steps to reproduce, or report it through the advisory form if it's a vulnerability.

cliffhall avatar Nov 05 '26 03:11 cliffhall

Thanks for the detailed re-check and for separating the already-addressed findings from the cases that need runtime-specific evidence.

Understood on the scope and the decision to close this issue. We'll treat the current findings as resolved or out of scope here, and use the appropriate issue or private advisory channel if we identify a concrete, independently reproducible problem.

Appreciate the careful review.

Paraphern avatar Nov 05 '26 13:11 Paraphern