[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6GVFBAH04T8023PG9P00TN2":3,"skill-same:01M6GVFBAH04T8023PG9P00TN2":89},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":42,"linkOnly":43,"markdownContent":44,"markdownBody":45,"frontMatter":46,"refName":52,"commitSha":53,"skillDirectory":54,"forksCount":55,"repositoryHtmlUrl":56,"repositoryHomepageUrl":6,"ownerHtmlUrl":57,"ownerBlogUrl":58,"ownerDescription":59,"updatedAt":60,"install":61,"resources":74},"01M6GVFBAH04T8023PG9P00TN2","security-pass",null,"Review an MCP server for common security gaps: LLM-facing surfaces as injection vector (tools, resources, prompts, descriptions), scope blast radius, destructive ops without consent, upstream auth shape, input sinks (URL \u002F path \u002F roots \u002F shell \u002F schema strictness \u002F ReDoS), tenant isolation, leakage through errors and telemetry, unbounded resources, and HTTP-mode deployment surface. Use before a release, after a batch of handler changes, or when the user asks for a security review, audit, or hardening pass. Produces grouped findings and a numbered options list.","jiayaoqijia\u002Fcryptoskill","jiayaoqijia","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1453879?v=4","01M6GMYTX7Q7S504VC6E756ENR","YQ","01M6GMYV1QKJ1CC75MTTGT9PR0",81,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fcyanheads-security-pass\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fcyanheads-security-pass\u002FSKILL.md",[],[20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41],"security","security pass","common","when","tenant","mode","errors","URL","resources","scope","common security","options","MCP","server","audit","batch","vector","release","security review","auth","mcp server","review","2026-11-10 10:12:30",false,"---\nname: security-pass\ndescription: >\n  Review an MCP server for common security gaps: LLM-facing surfaces as injection vector (tools, resources, prompts, descriptions), scope blast radius, destructive ops without consent, upstream auth shape, input sinks (URL \u002F path \u002F roots \u002F shell \u002F schema strictness \u002F ReDoS), tenant isolation, leakage through errors and telemetry, unbounded resources, and HTTP-mode deployment surface. Use before a release, after a batch of handler changes, or when the user asks for a security review, audit, or hardening pass. Produces grouped findings and a numbered options list.\nmetadata:\n  author: cyanheads\n  version: \"1.13\"\n  audience: external\n  type: audit\n---\n\n## Context\n\nAn MCP server is a new attack surface with unique properties — tool output feeds back into the LLM's context, scopes gate what the model can do on the user's behalf, and per-request state must stay tenant-scoped. This skill walks a server through eight axes shaped around what the server builder actually controls. Framework-level concerns (transport, JSON-RPC parsing, auto-correlation, error classification) are out of scope — `mcp-ts-core` handles those.\n\n**Read the code. Don't trust patterns from memory.**\n\n## When to Use\n\n- Before a release\n- After adding or modifying a batch of handlers or services\n- Periodically (quarterly-ish)\n- User asks for a \"security review\", \"audit\", \"hardening pass\", or similar\n\n## Inputs\n\nGather before starting. Ask if unclear:\n\n1. **Scope** — whole server, specific module, or recent diff?\n2. **Known concerns** — anything the user already suspects?\n3. **Deployment context** — multi-tenant? public network? auth mode? (stdio \u002F local-http \u002F public-http behave differently)\n4. **Severity floor** — report all findings, or skip medium\u002Flow?\n\n## Steps\n\n### 1. Build the map\n\nSurface what you're auditing before diving in. Paths below assume the `mcp-ts-core` layout — adjust to your repo.\n\n```bash\nfind src\u002Fmcp-server\u002Ftools\u002Fdefinitions -name \"*.tool.ts\" | sort\nfind src\u002Fmcp-server\u002Fresources\u002Fdefinitions -name \"*.resource.ts\" 2>\u002Fdev\u002Fnull | sort\nfind src\u002Fmcp-server\u002Fprompts\u002Fdefinitions -name \"*.prompt.ts\" 2>\u002Fdev\u002Fnull | sort\nfind src\u002Fservices -maxdepth 1 -mindepth 1 -type d | sort\n```\n\nNote: tool \u002F resource \u002F prompt counts, auth mode, storage provider, upstream APIs, which tools have `destructiveHint`, which handlers request a consent round via `ctx.requestInput`, which services hold module-scope state, whether the server reads `roots`.\n\n**If transport is streamable HTTP or SSE**, also capture:\n\n- Bind address (`127.0.0.1` for local, or `0.0.0.0` \u002F public interface?)\n- Origin allowlist (DNS rebinding mitigation) — configured, or wildcard \u002F missing?\n- Session ID source (framework CSPRNG, or builder-supplied?) and binding to auth identity\n- Any unauthenticated routes (`\u002Fhealthz`, `\u002Fsse`, metadata endpoints) — do they leak tool lists or tenant hints?\n- MCP Authorization spec: if implemented, PKCE enforced, token audience (`aud`) checked, resource indicators used\n\n**If `CANVAS_PROVIDER_TYPE=duckdb` is set**, also capture:\n\n- Auth mode — canvas in `MCP_AUTH_MODE=none` collapses the composite `(tenantId, canvasId)` scope to `('default', canvasId)`, where the ID is the only differentiator\n- `CANVAS_MAX_CANVASES_PER_TENANT`, `CANVAS_TTL_MS`, `CANVAS_ABSOLUTE_CAP_MS`, `CANVAS_EXPORT_PATH` values\n- Whether external rate limiting (CDN, reverse proxy, WAF) fronts the deployment — required to keep the ~10¹⁸ canvasId keyspace operationally infeasible to brute-force\n\nUse `TaskCreate` — one task per axis. Mark complete as you go.\n\n**Run `fuzzTool` in parallel.** `@cyanheads\u002Fmcp-ts-core\u002Ftesting\u002Ffuzz` catches crashes, memory leaks, and prototype pollution automatically on each tool — start it now so results are ready when you reach Axis 5.\n\n### 2. Walk the eight axes\n\n#### Axis 1 — LLM-facing surfaces as injection vector\n\nAnything the server sends to the client that reaches the LLM's context is a potential injection surface: tool output, resource content, prompt text, and the metadata the LLM reads to decide what to call. Relayed upstream content (tickets, scraped text, emails, DB rows) can carry adversarial instructions even when your code is honest.\n\n**Look in:**\n\n- Every `*.tool.ts` — `output` schema + `format()`\n- Every `*.resource.ts` — content returned from `resources\u002Fread`\n- Every `*.prompt.ts` — templated message content\n- Every definition file — `description`, `title`, `annotations`, and `inputSchema` field descriptions (templated from untrusted data?)\n\n**Check:**\n\n- Handlers that return raw upstream text \u002F DB rows without structural framing?\n- Does `format()` wrap untrusted content in delimiters (blockquote, fenced code, `\u003Cdata>` tags)?\n- Output schema distinguishes \"data\" fields from free-form text?\n- Resource content (`resources\u002Fread`) framed the same way tool output is?\n- Prompt templates interpolate untrusted data without escaping — treating tenant-controlled strings as trusted instructions?\n- Tool \u002F resource \u002F prompt **descriptions** templated from runtime data? Static strings are safer; templated descriptions enable \"tool poisoning\" (adversarial metadata steering the LLM toward a dangerous tool).\n- Descriptions mutated mid-session? Rug-pull surface: client approved the v1 description, server now advertises v2 behavior.\n\n**Smell:** `return { body: await fetch(url).then(r => r.text()) }` rendered directly in `format()`. Or: `description: \\`Look up ${tenant.customLabel}\\`` where `customLabel` is tenant-supplied.\n\n#### Axis 2 — Scope granularity\n\nEvery `auth: [...]` entry is a blast-radius dial.\n\n**Look in:** every `*.tool.ts` — `auth:` array.\n\n```bash\ngrep -rn \"auth: \\[\" src\u002Fmcp-server\u002Ftools\u002Fdefinitions\u002F\n```\n\n**Check:**\n\n- Tools with `['admin']`, `['*']`, or `[]`?\n- A single scope covering two capabilities that should be separated (read vs write)?\n- Read-only tools never require write scopes?\n- `MCP_AUTH_DISABLE_SCOPE_CHECKS=true` set in production? When on, both `withRequiredScopes` and `checkScopes` early-return — every authenticated user gets every tool, and runtime tenant patterns like `team:${input.teamId}:write` no longer guard. Acceptable only when paired with a real server-side ACL (path filter, allowlist, upstream API enforcement).\n\n**Smell:** every tool shares the same scope string. Or: `MCP_AUTH_DISABLE_SCOPE_CHECKS=true` set without a documented compensating ACL — confirm the deployment relies on a meaningful access control layer below the framework before approving.\n\n#### Axis 3 — Destructive ops without a consent round\n\n`ctx.requestInput` moves consent off the LLM and onto the user: the handler returns an `input_required` result and only runs the side effect once it is re-entered and redeems the record it stored when it asked. An accepted response on `ctx.inputs` alone proves nothing — a client can send one on a call nothing prompted for. Destructive tools without that round trust the LLM not to be tricked.\n\n**Look in:** handlers with `destructiveHint: true` or side-effecting verbs in names (`delete_*`, `send_*`, `pay_*`, `publish_*`, `drop_*`).\n\n```bash\ngrep -rn \"destructiveHint\" src\u002Fmcp-server\u002Ftools\u002Fdefinitions\u002F\ngrep -rnE \"ctx\\.requestInput|ctx\\.inputs\" src\u002Fmcp-server\u002Ftools\u002Fdefinitions\u002F\n```\n\n**Check:**\n\n- Each destructive handler reads `ctx.inputs` for the confirmation and returns `ctx.requestInput(...)` before the side effect?\n- The confirmation **response** is validated — `ctx.inputs.accepted(key, Schema)` with a schema, not the bare overload. The SDK never re-validates a response against the schema its request advertised, and the payload is LLM-mediated: \"user confirmed\" does not mean \"user authored these exact fields.\"\n- A **declined or cancelled** response is terminal — checked via `ctx.inputs.view(key)` and thrown on, never re-asked (a re-ask loops until the round budget runs out) and never treated as consent.\n- Consent is scoped to the specific target (e.g., record ID rendered in the message), not a generic \"proceed?\"\n- Where `requestState` influences authorization, resource access, or which target gets mutated, `MCP_REQUEST_STATE_KEY` is set (≥ 32 bytes, the same on every instance a retry can reach). The framework then seals the string a handler returns and the SDK rejects any other state before the handler runs; unset, the state round-trips through the client and comes back attacker-controlled.\n- **A consent gate's state is server-issued and single-use.** The framework drops answers the client's declared capabilities do not cover, kind and mode, on both eras, so a client without `elicitation.form` — a URL-only client included — cannot pre-answer a form gate. A client that declared it still can: it may send `inputResponses` — and a `requestState` of its own, or one it was issued earlier — on the very first call, so a handler that only *compares* client-carried state against a fresh resolution deletes on an answer nobody was shown. A sealed state closes forgery but not replay within its 900 s lifetime. Keep what the prompt confirmed in a `ctx.state` record keyed by a random id — the operation (tool name, or the resource URI read), the caller (`ctx.auth` `clientId` and `sub`), the target, and a content hash so a same-path swap is caught — send only the id, redeem it before anything else in the handler, and ask again on an unknown, used, or expired id or on any field that differs from this call. Without the operation, an id minted by another gated tool or resource confirms this one; without the caller, another user in the same tenant redeems an id they were handed while `MCP_REQUEST_STATE_KEY` is unset. The record's storage is shared by every instance a 2026-07-28 retry can reach — `filesystem`, `supabase`, or `cloudflare-d1`, never `cloudflare-kv`, whose eventual consistency widens the race below.\n- **Redeeming is not atomic.** Read-then-delete stops a sequential replay, but concurrent retries carrying one id can each read the record before any delete lands and each run the action. Until `ctx.state` gains an atomic `take` ([#593](https:\u002F\u002Fgithub.com\u002Fcyanheads\u002Fmcp-ts-core\u002Fissues\u002F593)), an action that must not repeat — a payment, a send, a publish — is idempotent per record (the record id as the upstream idempotency key), or the risk is accepted knowingly and recorded in the findings.\n- **The weak point is answerability, not availability.** `ctx.requestInput` is present on every transport and both protocol eras — the 2025-era shim issues the real `elicitation\u002Fcreate` round trip, the 2026-07-28 client fulfils the embedded request directly. A client that never retries simply leaves the destructive step un-run, which fails safe. Keep `destructiveHint: true` so client-side approval flows still surface the risk, and do not accept \"proceed anyway when the round is unavailable\" as a fallback. On a 2025-era connection whose client lacks the capability, `ctx.requestInput` throws `client_capability_missing` inside the handler; catching that to run the side effect is exactly this bypass — let it propagate. So is skipping the prompt because `ctx.clientCapabilities` lacks `elicitation`: that property decides whether to ask for optional context, never whether consent is needed.\n\n**Smell:** `destructiveHint: true` file with no `ctx.requestInput` in it. Or `ctx.inputs.accepted('confirm')` with no schema argument — the content could be anything. Or a gate that proceeds on `ctx.inputs` without redeeming a `ctx.state` record, whose record omits the operation or the caller, or that compares a target carried in `requestState`. Or a non-repeatable action behind a gate with no idempotency key. Or a handler that re-issues the same request after a `decline`.\n\n#### Axis 4 — Upstream auth shape\n\nWhat credentials the server holds, and the blast radius if one leaks.\n\n**Look in:** `src\u002Fservices\u002F*`, `src\u002Fconfig\u002Fserver-config.ts`.\n\n**Check:**\n\n- Each upstream API key scoped to minimum required? (No admin keys for read workflows.)\n- Services re-mint downstream tokens with correct `aud`, or passthrough the caller's?\n- Server holds OAuth for N services × M tenants — what does one-tenant compromise expose?\n- Per-tenant rate limits on upstream calls?\n\n**Smell:** one global `API_KEY` used across all tenants + retry loop with no upper bound.\n\n#### Axis 5 — Input sinks\n\nLLM-supplied inputs feel internal but aren't. Classic sinks apply, amplified. Sampling responses and roots-derived paths are MCP-specific sinks that look internal but carry LLM\u002Fclient trust.\n\n**Look in:** all handlers.\n\n```bash\n# URL sinks — SSRF\ngrep -rn \"z.string().url()\" src\u002F\n\n# Path sinks — traversal\ngrep -rnE \"readFile|writeFile|readdirSync|createReadStream|statSync\" src\u002F\n\n# Shell sinks — command injection\ngrep -rnE \"\\b(exec|spawn|execSync|spawnSync)\\b\" src\u002F\n\n# Merges — prototype pollution\ngrep -rnE \"Object\\.assign\\b|structuredClone\" src\u002F\n\n# Lookups — prototype chain read through an object literal\ngrep -rnE \"\\[[a-zA-Z_$][a-zA-Z0-9_$.]*\\] *\\?\\? |\\[[a-zA-Z_$][a-zA-Z0-9_$.]*\\] *\\|\\| \" src\u002F\n\n# Roots — client-shared filesystem\ngrep -rnE \"roots\u002Flist|ctx\\.roots\" src\u002F\n\n# Schema laxity — fields sneaking past validation\ngrep -rnE \"\\.passthrough\\(\\)|\\.loose\\(\\)|looseObject\\(|\\.catchall\\(\" src\u002Fmcp-server\u002F\n```\n\n**Check:**\n\n- URL-taking tools block private IPs, `file:\u002F\u002F`, `ftp:\u002F\u002F`, `localhost`, DNS rebind?\n- Path-taking tools canonicalize (`path.resolve` + assert `startsWith(root + sep)`)?\n- **Upstream URL paths built from caller segments refuse `.` and `..`?** `encodeURIComponent` leaves dots untouched, and the URL parser resolves dot segments, so a file key or archive-member input of `..\u002F..\u002Fme` retargets the request (credentials attached) at another endpoint on the same host. Redirects on authenticated requests should follow only within the upstream origin.\n- **Caller text spliced into an upstream query language next to server-built filter clauses stays well-formed?** Some search backends fall back to plain-text matching when they can't parse a query. An unclosed quote or a trailing `\\` from the caller then silently drops every filter clause while the tool still reports them as applied.\n- Roots-derived paths: resolved result stays within *one* declared root (iterate and assert), not assumed-safe because \"the client said so\"?\n- Shell-using tools use an allowlist (never string-concat)?\n- Regex \u002F glob \u002F filter inputs bounded (length cap, complexity limits, execution timeout) — ReDoS-safe?\n- **The server's own patterns are linear-time on hostile input?** Every `.regex()` in an input schema, and every regex a handler or normalizer runs over caller text, sees attacker-length strings before any length cap applies. Loose \"raw\" patterns that admit un-normalized input (`\\s*` runs, optional quotes and separators around a repeated group) are the usual source of polynomial backtracking. Time each one against a long adversarial string (thousands of spaces, then a character that forces failure). Milliseconds is fine; seconds is a finding.\n- User-JSON merges reject `__proto__`, `constructor`, `prototype` keys?\n- **Lookup tables keyed by input-derived text are a `Map`, not an object literal?** The read direction of the same defect: `TABLE[key] ?? fallback` walks the prototype chain, so a key of `constructor` (or `toString`, `valueOf`) returns a function the `??` does not catch — it is not nullish — and string coercion then emits `function Object() { [native code] }` into the output. Lowercasing the key masks the camelCase members and leaves `constructor` reachable, so it is not a fix. A `Map` has no prototype chain; `Object.create(null)` works too.\n- **Input schemas `.strict()`** — unknown fields rejected, not silently passed to downstream code that destructures with `...rest`?\n- **Output schemas without `.passthrough()` \u002F `.loose()` \u002F `.catchall()`** — no accidental exfiltration of fields your schema didn't declare?\n**Smell:** `z.string().url()` with no allowlist; `readFile(input.path)` with no canonicalization.\n\n#### Axis 6 — Tenant isolation\n\n`ctx.state` is tenant-scoped. Module-scope state is not.\n\n**Look in:** `src\u002Fservices\u002F*`.\n\n```bash\ngrep -rnE \"^(const|let) .* = new (Map|Set|WeakMap|Array)\" src\u002Fservices\u002F\ngrep -rn \"^let \" src\u002Fservices\u002F\n```\n\n**Check:**\n\n- Module-scope `Map` \u002F `Set` \u002F cache near tenant-handling code?\n- Upstream connections pooled per-tenant or shared?\n- Any code path uses the global `logger` while carrying per-tenant data (bypassing auto-correlated `ctx.log`)?\n- Could tenant B, served after tenant A, read tenant A's cached data?\n\n**Smell:** service file with top-level `const cache = new Map()`.\n\n#### Axis 7 — Leakage back\n\nWhat accidentally reaches the LLM, user, or observability sinks.\n\n**Look in:** `throw new McpError(...)` and `ctx.fail(reason, msg, data)` sites, error factory calls (`notFound`, `httpErrorFromResponse`, …), `McpError.data` fields (the `data` arg flows through both paths), output schemas, and every logging \u002F telemetry surface — not just `ctx.log`.\n\n```bash\ngrep -rnE \"new McpError|ctx\\.fail\\(|httpErrorFromResponse\\(\" src\u002F\ngrep -rnE \"\\b(ctx\\.log|console\\.(log|info|warn|error|debug)|logger\\.)\" src\u002F\ngrep -rnE \"(Sentry\\.|captureException|setTag|setContext|addBreadcrumb)\" src\u002F\ngrep -rnE \"(setAttribute|setAttributes|span\\.)\" src\u002F  # OpenTelemetry\n```\n\n**Check:**\n\n- Error `data` fields (whether passed via `ctx.fail(reason, msg, data)`, `new McpError(code, msg, data)`, or factory calls) carry upstream response bodies, auth headers, stack traces?\n- `httpErrorFromResponse` body capture sweeping in too much (default 500-byte cap is fine for most APIs but consider `captureBody: false` when the upstream returns auth-bearing payloads)?\n- Output schemas include token prefixes, internal IDs, session identifiers?\n- `format()` renders fields that shouldn't leave the server?\n- `ctx.log.info(msg, body)` where `body` is the raw request (may contain secrets)?\n- `console.*` calls near auth \u002F token \u002F request-body handling — bypasses structured redaction?\n- OpenTelemetry span attributes \u002F Sentry breadcrumbs carry tokens, PII, or full request bodies?\n- Secret \u002F token \u002F HMAC comparisons use `===` or `==` instead of constant-time (`timingSafeEqual` \u002F `crypto.timingSafeEqual`) — leaks length and prefix via timing?\n\n**Smell:** `throw new McpError(code, upstream.message, { raw: upstream.body })` or `throw ctx.fail('upstream_failed', e.message, { raw: e.response.body })`. Or: `if (apiKey === expected)` on a request-auth path.\n\n#### Axis 8 — Resource bounds\n\nUnbounded = DoS of self, upstream, or the LLM's context window (billing-DoS is real).\n\n**Look in:** handlers with loops, pagination, retries, or inputs that feed `JSON.parse` \u002F schema validation.\n\n```bash\ngrep -rnE \"while\\s*\\(|for\\s*\\(.*of\" src\u002Fmcp-server\u002Ftools\u002Fdefinitions\u002F\ngrep -rnE \"cursor|nextPage|paginate\" src\u002F\ngrep -rn \"JSON.parse\\b\" src\u002F\n```\n\n**Check:**\n\n- Pagination loops have a total-items cap?\n- Retry logic has max attempts + exponential backoff?\n- Output size proportional to input — is there a ceiling?\n- Tools callable in a loop fail-fast on degenerate input (empty string, `0`, `null`)?\n- `JSON.parse` \u002F Zod `.parse()` inputs have a size + nesting-depth limit applied before parse?\n- **Per-tenant per-tool** call rate limit (a single tenant looping `delete_record` 10k\u002Fsec hits you before it hits upstream)?\n- Concurrency cap on long-running tools so one tenant can't starve the event loop?\n\n**Smell:** `while (cursor) { results.push(...); cursor = next; }` with no max count. Or: `JSON.parse(await req.text())` with no `Content-Length` check upstream.\n\n#### Axis 9 — Canvas (only if `CANVAS_PROVIDER_TYPE=duckdb`)\n\nDataCanvas is opt-in and deliberately trades isolation for cross-agent token-shareable working sets — designed for public-data tabular servers (BrAPI, OpenAlex, etc.) where session-pinning isn't desired. The trade only holds when the deployment matches that assumption. Skip this axis entirely when canvas is disabled (`CANVAS_PROVIDER_TYPE=none`, the default).\n\n**Look in:** `src\u002Fconfig\u002Fserver-config.ts`, the `setCanvas(core.canvas)` wiring in `setup()` and every tool reading the canvas accessor, deployment config (wrangler \u002F Dockerfile \u002F proxy).\n\n**Check:**\n\n- Data registered on canvases is **already public** or already-shared-out-of-band. The composite `(tenantId, canvasId)` scope collapses to `('default', canvasId)` in `MCP_AUTH_MODE=none` — anyone with the `canvasId` attaches.\n- External rate limiting (CDN, reverse proxy, WAF) fronts the deployment so the ~10¹⁸ keyspace can't be brute-forced. Without it, the entropy assumption breaks and discovery becomes feasible.\n- `CANVAS_MAX_CANVASES_PER_TENANT` (default 500) sized against the container's memory cap — each canvas is its own DuckDB instance up to `CANVAS_DEFAULT_MEMORY_LIMIT_MB`, so the cap bounds how many a tenant can hold, not how much memory they use. Under `MCP_AUTH_MODE=none` every caller shares the one tenant.\n- `CANVAS_TTL_MS` \u002F `CANVAS_ABSOLUTE_CAP_MS` not absurdly long. Defaults (24 h sliding \u002F 7 d absolute) are reasonable; longer widens the window an unreferenced `canvasId` stays guessable.\n- `CANVAS_EXPORT_PATH` is the engine's file surface: each canvas's DuckDB instance reads and writes only under it and the private scratch directory. It must not point into a shared mount, the repo, the app directory, a directory holding anything callers shouldn't read, or one another service serves from. The path-sandbox blocks `..` traversal but doesn't prevent the configured root from being a bad choice, and a broad root widens what the engine can reach.\n- Axis 1 (description templating from canvas-supplied content), Axis 5 (no parallel service runs caller SQL outside the canvas API's `query()` \u002F `registerView()` — the exported `assertReadOnlyQuery` covers only the statement and plan checks, not the whole gate), and Axis 7 (errors from canvas operations don't leak the failed SQL string back through `McpError.data`) all apply.\n\n**Smell:** `MCP_AUTH_MODE=none` deployment registering per-user data (recent activity, account state, cart contents) onto a canvas. Or: `CANVAS_EXPORT_PATH=\u002Fsrv\u002Fstatic` with a static file server pointing at the same root.\n\n### 3. Quick sanity pass\n\nFast, sometimes high-leverage. Outside the eight axes.\n\n- `bun audit` — any direct high\u002Fcritical?\n- `package.json` — `postinstall` \u002F lifecycle scripts on added deps?\n- New deps have npm provenance? `npm view \u003Cpkg> --json | jq .dist.attestations` — missing attestation on a security-critical dep is a yellow flag\n- `.env.example` — placeholder values only, never real?\n- Server-specific `ConfigSchema` — fails loudly on missing required keys (not silent defaults)?\n- Any `process.env.*` reads outside the config parser (bypasses validation)?\n- Collect `fuzzTool` results from Step 1 — triage crashes \u002F leaks as Axis 5 \u002F Axis 8 findings.\n\n### 4. Report\n\nThree sections. Summary → findings → numbered options.\n\n#### Summary (1 paragraph)\n\nDefinitions reviewed, axes covered, count by severity, the single most important finding.\n\n#### Findings\n\nGroup by severity. Each 3–5 lines.\n\n| Severity | Meaning |\n|:---------|:--------|\n| **critical** | Exploitable now: auth bypass, exfiltration, arbitrary code\u002Ffile\u002Fnetwork access |\n| **high** | Structural gap with clear attacker benefit even without immediate PoC (destructive op without a consent round, admin scope on read tool, SSRF-capable URL input) |\n| **medium** | Defense-in-depth gap weakening a boundary (missing per-tenant rate limit, error carries upstream response) |\n| **low** | Hardening \u002F polish (tighter output schema, narrower error data, minor comment) |\n\nFormat:\n\n```\n**\u003Cfile_or_tool> — Axis \u003CN> — \u003Ccritical|high|medium|low>**\nIssue: \u003Cone line: what's wrong>\nImpact: \u003Cone line: what can go wrong>\nFix: \u003Cone line: the change>\n```\n\n#### Options\n\nNumbered, cherry-pickable.\n\n```\n1. Add SSRF guard to `fetch_url.tool.ts` — block private IPs + non-http schemes (critical, #1)\n2. Gate `delete_record.tool.ts` behind a `ctx.requestInput` confirmation round (high, #3)\n3. Split `admin` into `record:read` + `record:write` across 4 tools (high, #4)\n4. Move `const tokenCache = new Map()` out of module scope in `auth-service.ts` (medium, #7)\n5. Cap pagination loop in `list_all_tickets` at 1000 items (medium, #9)\n6. Strip upstream response body from `McpError.data` in `sync-service.ts` (low, #11)\n```\n\nEnd with:\n\n> Pick by number (e.g. \"do 1, 3, 5\" or \"expand on 2\").\n\n## Checklist\n\n- [ ] Scope confirmed (whole server \u002F module \u002F diff)\n- [ ] Map built: tools \u002F resources \u002F prompts, services, upstream APIs, auth mode, consent-round \u002F roots usage\n- [ ] Deployment surface reviewed (if HTTP): bind address, Origin allowlist, session ID, unauth routes, auth-spec compliance\n- [ ] `fuzzTool` started in parallel\n- [ ] Axis 1 — LLM-facing surfaces (tool \u002F resource \u002F prompt output + descriptions) framed and static\n- [ ] Axis 2 — scope granularity audited\n- [ ] Axis 3 — destructive ops verified to gate on a `ctx.requestInput` round that redeems a `ctx.state` record bound to the operation, caller, and target, the response schema-validated, decline\u002Fcancel terminal, non-repeatable actions idempotent per record, `MCP_REQUEST_STATE_KEY` set where state drives a mutation\n- [ ] Axis 4 — upstream auth + token passthrough reviewed\n- [ ] Axis 5 — input sinks (URL \u002F path \u002F roots \u002F shell \u002F proto \u002F schema strictness \u002F ReDoS) checked\n- [ ] Axis 6 — tenant isolation: module-scope state swept\n- [ ] Axis 7 — leakage back: errors \u002F outputs \u002F `ctx.log` \u002F `console.*` \u002F telemetry \u002F constant-time comparisons\n- [ ] Axis 8 — resource bounds on loops \u002F retries \u002F pagination \u002F parse size+depth \u002F per-tenant rate\n- [ ] **If `CANVAS_PROVIDER_TYPE=duckdb`:** Axis 9 — public-data assumption holds, external rate limiting in place, max-canvases-per-tenant + TTLs sized for the deployment, `CANVAS_EXPORT_PATH` (the engine's file surface) doesn't reach shared, served, or caller-private paths, caller SQL reaches DuckDB only through the canvas API\n- [ ] Quick sanity pass: `bun audit`, lifecycle scripts, `.env.example`, config validation, new-dep provenance\n- [ ] Report: summary → grouped findings → numbered options\n","## Context\n\nAn MCP server is a new attack surface with unique properties — tool output feeds back into the LLM's context, scopes gate what the model can do on the user's behalf, and per-request state must stay tenant-scoped. This skill walks a server through eight axes shaped around what the server builder actually controls. Framework-level concerns (transport, JSON-RPC parsing, auto-correlation, error classification) are out of scope — `mcp-ts-core` handles those.\n\n**Read the code. Don't trust patterns from memory.**\n\n## When to Use\n\n- Before a release\n- After adding or modifying a batch of handlers or services\n- Periodically (quarterly-ish)\n- User asks for a \"security review\", \"audit\", \"hardening pass\", or similar\n\n## Inputs\n\nGather before starting. Ask if unclear:\n\n1. **Scope** — whole server, specific module, or recent diff?\n2. **Known concerns** — anything the user already suspects?\n3. **Deployment context** — multi-tenant? public network? auth mode? (stdio \u002F local-http \u002F public-http behave differently)\n4. **Severity floor** — report all findings, or skip medium\u002Flow?\n\n## Steps\n\n### 1. Build the map\n\nSurface what you're auditing before diving in. Paths below assume the `mcp-ts-core` layout — adjust to your repo.\n\n```bash\nfind src\u002Fmcp-server\u002Ftools\u002Fdefinitions -name \"*.tool.ts\" | sort\nfind src\u002Fmcp-server\u002Fresources\u002Fdefinitions -name \"*.resource.ts\" 2>\u002Fdev\u002Fnull | sort\nfind src\u002Fmcp-server\u002Fprompts\u002Fdefinitions -name \"*.prompt.ts\" 2>\u002Fdev\u002Fnull | sort\nfind src\u002Fservices -maxdepth 1 -mindepth 1 -type d | sort\n```\n\nNote: tool \u002F resource \u002F prompt counts, auth mode, storage provider, upstream APIs, which tools have `destructiveHint`, which handlers request a consent round via `ctx.requestInput`, which services hold module-scope state, whether the server reads `roots`.\n\n**If transport is streamable HTTP or SSE**, also capture:\n\n- Bind address (`127.0.0.1` for local, or `0.0.0.0` \u002F public interface?)\n- Origin allowlist (DNS rebinding mitigation) — configured, or wildcard \u002F missing?\n- Session ID source (framework CSPRNG, or builder-supplied?) and binding to auth identity\n- Any unauthenticated routes (`\u002Fhealthz`, `\u002Fsse`, metadata endpoints) — do they leak tool lists or tenant hints?\n- MCP Authorization spec: if implemented, PKCE enforced, token audience (`aud`) checked, resource indicators used\n\n**If `CANVAS_PROVIDER_TYPE=duckdb` is set**, also capture:\n\n- Auth mode — canvas in `MCP_AUTH_MODE=none` collapses the composite `(tenantId, canvasId)` scope to `('default', canvasId)`, where the ID is the only differentiator\n- `CANVAS_MAX_CANVASES_PER_TENANT`, `CANVAS_TTL_MS`, `CANVAS_ABSOLUTE_CAP_MS`, `CANVAS_EXPORT_PATH` values\n- Whether external rate limiting (CDN, reverse proxy, WAF) fronts the deployment — required to keep the ~10¹⁸ canvasId keyspace operationally infeasible to brute-force\n\nUse `TaskCreate` — one task per axis. Mark complete as you go.\n\n**Run `fuzzTool` in parallel.** `@cyanheads\u002Fmcp-ts-core\u002Ftesting\u002Ffuzz` catches crashes, memory leaks, and prototype pollution automatically on each tool — start it now so results are ready when you reach Axis 5.\n\n### 2. Walk the eight axes\n\n#### Axis 1 — LLM-facing surfaces as injection vector\n\nAnything the server sends to the client that reaches the LLM's context is a potential injection surface: tool output, resource content, prompt text, and the metadata the LLM reads to decide what to call. Relayed upstream content (tickets, scraped text, emails, DB rows) can carry adversarial instructions even when your code is honest.\n\n**Look in:**\n\n- Every `*.tool.ts` — `output` schema + `format()`\n- Every `*.resource.ts` — content returned from `resources\u002Fread`\n- Every `*.prompt.ts` — templated message content\n- Every definition file — `description`, `title`, `annotations`, and `inputSchema` field descriptions (templated from untrusted data?)\n\n**Check:**\n\n- Handlers that return raw upstream text \u002F DB rows without structural framing?\n- Does `format()` wrap untrusted content in delimiters (blockquote, fenced code, `\u003Cdata>` tags)?\n- Output schema distinguishes \"data\" fields from free-form text?\n- Resource content (`resources\u002Fread`) framed the same way tool output is?\n- Prompt templates interpolate untrusted data without escaping — treating tenant-controlled strings as trusted instructions?\n- Tool \u002F resource \u002F prompt **descriptions** templated from runtime data? Static strings are safer; templated descriptions enable \"tool poisoning\" (adversarial metadata steering the LLM toward a dangerous tool).\n- Descriptions mutated mid-session? Rug-pull surface: client approved the v1 description, server now advertises v2 behavior.\n\n**Smell:** `return { body: await fetch(url).then(r => r.text()) }` rendered directly in `format()`. Or: `description: \\`Look up ${tenant.customLabel}\\`` where `customLabel` is tenant-supplied.\n\n#### Axis 2 — Scope granularity\n\nEvery `auth: [...]` entry is a blast-radius dial.\n\n**Look in:** every `*.tool.ts` — `auth:` array.\n\n```bash\ngrep -rn \"auth: \\[\" src\u002Fmcp-server\u002Ftools\u002Fdefinitions\u002F\n```\n\n**Check:**\n\n- Tools with `['admin']`, `['*']`, or `[]`?\n- A single scope covering two capabilities that should be separated (read vs write)?\n- Read-only tools never require write scopes?\n- `MCP_AUTH_DISABLE_SCOPE_CHECKS=true` set in production? When on, both `withRequiredScopes` and `checkScopes` early-return — every authenticated user gets every tool, and runtime tenant patterns like `team:${input.teamId}:write` no longer guard. Acceptable only when paired with a real server-side ACL (path filter, allowlist, upstream API enforcement).\n\n**Smell:** every tool shares the same scope string. Or: `MCP_AUTH_DISABLE_SCOPE_CHECKS=true` set without a documented compensating ACL — confirm the deployment relies on a meaningful access control layer below the framework before approving.\n\n#### Axis 3 — Destructive ops without a consent round\n\n`ctx.requestInput` moves consent off the LLM and onto the user: the handler returns an `input_required` result and only runs the side effect once it is re-entered and redeems the record it stored when it asked. An accepted response on `ctx.inputs` alone proves nothing — a client can send one on a call nothing prompted for. Destructive tools without that round trust the LLM not to be tricked.\n\n**Look in:** handlers with `destructiveHint: true` or side-effecting verbs in names (`delete_*`, `send_*`, `pay_*`, `publish_*`, `drop_*`).\n\n```bash\ngrep -rn \"destructiveHint\" src\u002Fmcp-server\u002Ftools\u002Fdefinitions\u002F\ngrep -rnE \"ctx\\.requestInput|ctx\\.inputs\" src\u002Fmcp-server\u002Ftools\u002Fdefinitions\u002F\n```\n\n**Check:**\n\n- Each destructive handler reads `ctx.inputs` for the confirmation and returns `ctx.requestInput(...)` before the side effect?\n- The confirmation **response** is validated — `ctx.inputs.accepted(key, Schema)` with a schema, not the bare overload. The SDK never re-validates a response against the schema its request advertised, and the payload is LLM-mediated: \"user confirmed\" does not mean \"user authored these exact fields.\"\n- A **declined or cancelled** response is terminal — checked via `ctx.inputs.view(key)` and thrown on, never re-asked (a re-ask loops until the round budget runs out) and never treated as consent.\n- Consent is scoped to the specific target (e.g., record ID rendered in the message), not a generic \"proceed?\"\n- Where `requestState` influences authorization, resource access, or which target gets mutated, `MCP_REQUEST_STATE_KEY` is set (≥ 32 bytes, the same on every instance a retry can reach). The framework then seals the string a handler returns and the SDK rejects any other state before the handler runs; unset, the state round-trips through the client and comes back attacker-controlled.\n- **A consent gate's state is server-issued and single-use.** The framework drops answers the client's declared capabilities do not cover, kind and mode, on both eras, so a client without `elicitation.form` — a URL-only client included — cannot pre-answer a form gate. A client that declared it still can: it may send `inputResponses` — and a `requestState` of its own, or one it was issued earlier — on the very first call, so a handler that only *compares* client-carried state against a fresh resolution deletes on an answer nobody was shown. A sealed state closes forgery but not replay within its 900 s lifetime. Keep what the prompt confirmed in a `ctx.state` record keyed by a random id — the operation (tool name, or the resource URI read), the caller (`ctx.auth` `clientId` and `sub`), the target, and a content hash so a same-path swap is caught — send only the id, redeem it before anything else in the handler, and ask again on an unknown, used, or expired id or on any field that differs from this call. Without the operation, an id minted by another gated tool or resource confirms this one; without the caller, another user in the same tenant redeems an id they were handed while `MCP_REQUEST_STATE_KEY` is unset. The record's storage is shared by every instance a 2026-07-28 retry can reach — `filesystem`, `supabase`, or `cloudflare-d1`, never `cloudflare-kv`, whose eventual consistency widens the race below.\n- **Redeeming is not atomic.** Read-then-delete stops a sequential replay, but concurrent retries carrying one id can each read the record before any delete lands and each run the action. Until `ctx.state` gains an atomic `take` ([#593](https:\u002F\u002Fgithub.com\u002Fcyanheads\u002Fmcp-ts-core\u002Fissues\u002F593)), an action that must not repeat — a payment, a send, a publish — is idempotent per record (the record id as the upstream idempotency key), or the risk is accepted knowingly and recorded in the findings.\n- **The weak point is answerability, not availability.** `ctx.requestInput` is present on every transport and both protocol eras — the 2025-era shim issues the real `elicitation\u002Fcreate` round trip, the 2026-07-28 client fulfils the embedded request directly. A client that never retries simply leaves the destructive step un-run, which fails safe. Keep `destructiveHint: true` so client-side approval flows still surface the risk, and do not accept \"proceed anyway when the round is unavailable\" as a fallback. On a 2025-era connection whose client lacks the capability, `ctx.requestInput` throws `client_capability_missing` inside the handler; catching that to run the side effect is exactly this bypass — let it propagate. So is skipping the prompt because `ctx.clientCapabilities` lacks `elicitation`: that property decides whether to ask for optional context, never whether consent is needed.\n\n**Smell:** `destructiveHint: true` file with no `ctx.requestInput` in it. Or `ctx.inputs.accepted('confirm')` with no schema argument — the content could be anything. Or a gate that proceeds on `ctx.inputs` without redeeming a `ctx.state` record, whose record omits the operation or the caller, or that compares a target carried in `requestState`. Or a non-repeatable action behind a gate with no idempotency key. Or a handler that re-issues the same request after a `decline`.\n\n#### Axis 4 — Upstream auth shape\n\nWhat credentials the server holds, and the blast radius if one leaks.\n\n**Look in:** `src\u002Fservices\u002F*`, `src\u002Fconfig\u002Fserver-config.ts`.\n\n**Check:**\n\n- Each upstream API key scoped to minimum required? (No admin keys for read workflows.)\n- Services re-mint downstream tokens with correct `aud`, or passthrough the caller's?\n- Server holds OAuth for N services × M tenants — what does one-tenant compromise expose?\n- Per-tenant rate limits on upstream calls?\n\n**Smell:** one global `API_KEY` used across all tenants + retry loop with no upper bound.\n\n#### Axis 5 — Input sinks\n\nLLM-supplied inputs feel internal but aren't. Classic sinks apply, amplified. Sampling responses and roots-derived paths are MCP-specific sinks that look internal but carry LLM\u002Fclient trust.\n\n**Look in:** all handlers.\n\n```bash\n# URL sinks — SSRF\ngrep -rn \"z.string().url()\" src\u002F\n\n# Path sinks — traversal\ngrep -rnE \"readFile|writeFile|readdirSync|createReadStream|statSync\" src\u002F\n\n# Shell sinks — command injection\ngrep -rnE \"\\b(exec|spawn|execSync|spawnSync)\\b\" src\u002F\n\n# Merges — prototype pollution\ngrep -rnE \"Object\\.assign\\b|structuredClone\" src\u002F\n\n# Lookups — prototype chain read through an object literal\ngrep -rnE \"\\[[a-zA-Z_$][a-zA-Z0-9_$.]*\\] *\\?\\? |\\[[a-zA-Z_$][a-zA-Z0-9_$.]*\\] *\\|\\| \" src\u002F\n\n# Roots — client-shared filesystem\ngrep -rnE \"roots\u002Flist|ctx\\.roots\" src\u002F\n\n# Schema laxity — fields sneaking past validation\ngrep -rnE \"\\.passthrough\\(\\)|\\.loose\\(\\)|looseObject\\(|\\.catchall\\(\" src\u002Fmcp-server\u002F\n```\n\n**Check:**\n\n- URL-taking tools block private IPs, `file:\u002F\u002F`, `ftp:\u002F\u002F`, `localhost`, DNS rebind?\n- Path-taking tools canonicalize (`path.resolve` + assert `startsWith(root + sep)`)?\n- **Upstream URL paths built from caller segments refuse `.` and `..`?** `encodeURIComponent` leaves dots untouched, and the URL parser resolves dot segments, so a file key or archive-member input of `..\u002F..\u002Fme` retargets the request (credentials attached) at another endpoint on the same host. Redirects on authenticated requests should follow only within the upstream origin.\n- **Caller text spliced into an upstream query language next to server-built filter clauses stays well-formed?** Some search backends fall back to plain-text matching when they can't parse a query. An unclosed quote or a trailing `\\` from the caller then silently drops every filter clause while the tool still reports them as applied.\n- Roots-derived paths: resolved result stays within *one* declared root (iterate and assert), not assumed-safe because \"the client said so\"?\n- Shell-using tools use an allowlist (never string-concat)?\n- Regex \u002F glob \u002F filter inputs bounded (length cap, complexity limits, execution timeout) — ReDoS-safe?\n- **The server's own patterns are linear-time on hostile input?** Every `.regex()` in an input schema, and every regex a handler or normalizer runs over caller text, sees attacker-length strings before any length cap applies. Loose \"raw\" patterns that admit un-normalized input (`\\s*` runs, optional quotes and separators around a repeated group) are the usual source of polynomial backtracking. Time each one against a long adversarial string (thousands of spaces, then a character that forces failure). Milliseconds is fine; seconds is a finding.\n- User-JSON merges reject `__proto__`, `constructor`, `prototype` keys?\n- **Lookup tables keyed by input-derived text are a `Map`, not an object literal?** The read direction of the same defect: `TABLE[key] ?? fallback` walks the prototype chain, so a key of `constructor` (or `toString`, `valueOf`) returns a function the `??` does not catch — it is not nullish — and string coercion then emits `function Object() { [native code] }` into the output. Lowercasing the key masks the camelCase members and leaves `constructor` reachable, so it is not a fix. A `Map` has no prototype chain; `Object.create(null)` works too.\n- **Input schemas `.strict()`** — unknown fields rejected, not silently passed to downstream code that destructures with `...rest`?\n- **Output schemas without `.passthrough()` \u002F `.loose()` \u002F `.catchall()`** — no accidental exfiltration of fields your schema didn't declare?\n**Smell:** `z.string().url()` with no allowlist; `readFile(input.path)` with no canonicalization.\n\n#### Axis 6 — Tenant isolation\n\n`ctx.state` is tenant-scoped. Module-scope state is not.\n\n**Look in:** `src\u002Fservices\u002F*`.\n\n```bash\ngrep -rnE \"^(const|let) .* = new (Map|Set|WeakMap|Array)\" src\u002Fservices\u002F\ngrep -rn \"^let \" src\u002Fservices\u002F\n```\n\n**Check:**\n\n- Module-scope `Map` \u002F `Set` \u002F cache near tenant-handling code?\n- Upstream connections pooled per-tenant or shared?\n- Any code path uses the global `logger` while carrying per-tenant data (bypassing auto-correlated `ctx.log`)?\n- Could tenant B, served after tenant A, read tenant A's cached data?\n\n**Smell:** service file with top-level `const cache = new Map()`.\n\n#### Axis 7 — Leakage back\n\nWhat accidentally reaches the LLM, user, or observability sinks.\n\n**Look in:** `throw new McpError(...)` and `ctx.fail(reason, msg, data)` sites, error factory calls (`notFound`, `httpErrorFromResponse`, …), `McpError.data` fields (the `data` arg flows through both paths), output schemas, and every logging \u002F telemetry surface — not just `ctx.log`.\n\n```bash\ngrep -rnE \"new McpError|ctx\\.fail\\(|httpErrorFromResponse\\(\" src\u002F\ngrep -rnE \"\\b(ctx\\.log|console\\.(log|info|warn|error|debug)|logger\\.)\" src\u002F\ngrep -rnE \"(Sentry\\.|captureException|setTag|setContext|addBreadcrumb)\" src\u002F\ngrep -rnE \"(setAttribute|setAttributes|span\\.)\" src\u002F  # OpenTelemetry\n```\n\n**Check:**\n\n- Error `data` fields (whether passed via `ctx.fail(reason, msg, data)`, `new McpError(code, msg, data)`, or factory calls) carry upstream response bodies, auth headers, stack traces?\n- `httpErrorFromResponse` body capture sweeping in too much (default 500-byte cap is fine for most APIs but consider `captureBody: false` when the upstream returns auth-bearing payloads)?\n- Output schemas include token prefixes, internal IDs, session identifiers?\n- `format()` renders fields that shouldn't leave the server?\n- `ctx.log.info(msg, body)` where `body` is the raw request (may contain secrets)?\n- `console.*` calls near auth \u002F token \u002F request-body handling — bypasses structured redaction?\n- OpenTelemetry span attributes \u002F Sentry breadcrumbs carry tokens, PII, or full request bodies?\n- Secret \u002F token \u002F HMAC comparisons use `===` or `==` instead of constant-time (`timingSafeEqual` \u002F `crypto.timingSafeEqual`) — leaks length and prefix via timing?\n\n**Smell:** `throw new McpError(code, upstream.message, { raw: upstream.body })` or `throw ctx.fail('upstream_failed', e.message, { raw: e.response.body })`. Or: `if (apiKey === expected)` on a request-auth path.\n\n#### Axis 8 — Resource bounds\n\nUnbounded = DoS of self, upstream, or the LLM's context window (billing-DoS is real).\n\n**Look in:** handlers with loops, pagination, retries, or inputs that feed `JSON.parse` \u002F schema validation.\n\n```bash\ngrep -rnE \"while\\s*\\(|for\\s*\\(.*of\" src\u002Fmcp-server\u002Ftools\u002Fdefinitions\u002F\ngrep -rnE \"cursor|nextPage|paginate\" src\u002F\ngrep -rn \"JSON.parse\\b\" src\u002F\n```\n\n**Check:**\n\n- Pagination loops have a total-items cap?\n- Retry logic has max attempts + exponential backoff?\n- Output size proportional to input — is there a ceiling?\n- Tools callable in a loop fail-fast on degenerate input (empty string, `0`, `null`)?\n- `JSON.parse` \u002F Zod `.parse()` inputs have a size + nesting-depth limit applied before parse?\n- **Per-tenant per-tool** call rate limit (a single tenant looping `delete_record` 10k\u002Fsec hits you before it hits upstream)?\n- Concurrency cap on long-running tools so one tenant can't starve the event loop?\n\n**Smell:** `while (cursor) { results.push(...); cursor = next; }` with no max count. Or: `JSON.parse(await req.text())` with no `Content-Length` check upstream.\n\n#### Axis 9 — Canvas (only if `CANVAS_PROVIDER_TYPE=duckdb`)\n\nDataCanvas is opt-in and deliberately trades isolation for cross-agent token-shareable working sets — designed for public-data tabular servers (BrAPI, OpenAlex, etc.) where session-pinning isn't desired. The trade only holds when the deployment matches that assumption. Skip this axis entirely when canvas is disabled (`CANVAS_PROVIDER_TYPE=none`, the default).\n\n**Look in:** `src\u002Fconfig\u002Fserver-config.ts`, the `setCanvas(core.canvas)` wiring in `setup()` and every tool reading the canvas accessor, deployment config (wrangler \u002F Dockerfile \u002F proxy).\n\n**Check:**\n\n- Data registered on canvases is **already public** or already-shared-out-of-band. The composite `(tenantId, canvasId)` scope collapses to `('default', canvasId)` in `MCP_AUTH_MODE=none` — anyone with the `canvasId` attaches.\n- External rate limiting (CDN, reverse proxy, WAF) fronts the deployment so the ~10¹⁸ keyspace can't be brute-forced. Without it, the entropy assumption breaks and discovery becomes feasible.\n- `CANVAS_MAX_CANVASES_PER_TENANT` (default 500) sized against the container's memory cap — each canvas is its own DuckDB instance up to `CANVAS_DEFAULT_MEMORY_LIMIT_MB`, so the cap bounds how many a tenant can hold, not how much memory they use. Under `MCP_AUTH_MODE=none` every caller shares the one tenant.\n- `CANVAS_TTL_MS` \u002F `CANVAS_ABSOLUTE_CAP_MS` not absurdly long. Defaults (24 h sliding \u002F 7 d absolute) are reasonable; longer widens the window an unreferenced `canvasId` stays guessable.\n- `CANVAS_EXPORT_PATH` is the engine's file surface: each canvas's DuckDB instance reads and writes only under it and the private scratch directory. It must not point into a shared mount, the repo, the app directory, a directory holding anything callers shouldn't read, or one another service serves from. The path-sandbox blocks `..` traversal but doesn't prevent the configured root from being a bad choice, and a broad root widens what the engine can reach.\n- Axis 1 (description templating from canvas-supplied content), Axis 5 (no parallel service runs caller SQL outside the canvas API's `query()` \u002F `registerView()` — the exported `assertReadOnlyQuery` covers only the statement and plan checks, not the whole gate), and Axis 7 (errors from canvas operations don't leak the failed SQL string back through `McpError.data`) all apply.\n\n**Smell:** `MCP_AUTH_MODE=none` deployment registering per-user data (recent activity, account state, cart contents) onto a canvas. Or: `CANVAS_EXPORT_PATH=\u002Fsrv\u002Fstatic` with a static file server pointing at the same root.\n\n### 3. Quick sanity pass\n\nFast, sometimes high-leverage. Outside the eight axes.\n\n- `bun audit` — any direct high\u002Fcritical?\n- `package.json` — `postinstall` \u002F lifecycle scripts on added deps?\n- New deps have npm provenance? `npm view \u003Cpkg> --json | jq .dist.attestations` — missing attestation on a security-critical dep is a yellow flag\n- `.env.example` — placeholder values only, never real?\n- Server-specific `ConfigSchema` — fails loudly on missing required keys (not silent defaults)?\n- Any `process.env.*` reads outside the config parser (bypasses validation)?\n- Collect `fuzzTool` results from Step 1 — triage crashes \u002F leaks as Axis 5 \u002F Axis 8 findings.\n\n### 4. Report\n\nThree sections. Summary → findings → numbered options.\n\n#### Summary (1 paragraph)\n\nDefinitions reviewed, axes covered, count by severity, the single most important finding.\n\n#### Findings\n\nGroup by severity. Each 3–5 lines.\n\n| Severity | Meaning |\n|:---------|:--------|\n| **critical** | Exploitable now: auth bypass, exfiltration, arbitrary code\u002Ffile\u002Fnetwork access |\n| **high** | Structural gap with clear attacker benefit even without immediate PoC (destructive op without a consent round, admin scope on read tool, SSRF-capable URL input) |\n| **medium** | Defense-in-depth gap weakening a boundary (missing per-tenant rate limit, error carries upstream response) |\n| **low** | Hardening \u002F polish (tighter output schema, narrower error data, minor comment) |\n\nFormat:\n\n```\n**\u003Cfile_or_tool> — Axis \u003CN> — \u003Ccritical|high|medium|low>**\nIssue: \u003Cone line: what's wrong>\nImpact: \u003Cone line: what can go wrong>\nFix: \u003Cone line: the change>\n```\n\n#### Options\n\nNumbered, cherry-pickable.\n\n```\n1. Add SSRF guard to `fetch_url.tool.ts` — block private IPs + non-http schemes (critical, #1)\n2. Gate `delete_record.tool.ts` behind a `ctx.requestInput` confirmation round (high, #3)\n3. Split `admin` into `record:read` + `record:write` across 4 tools (high, #4)\n4. Move `const tokenCache = new Map()` out of module scope in `auth-service.ts` (medium, #7)\n5. Cap pagination loop in `list_all_tickets` at 1000 items (medium, #9)\n6. Strip upstream response body from `McpError.data` in `sync-service.ts` (low, #11)\n```\n\nEnd with:\n\n> Pick by number (e.g. \"do 1, 3, 5\" or \"expand on 2\").\n\n## Checklist\n\n- [ ] Scope confirmed (whole server \u002F module \u002F diff)\n- [ ] Map built: tools \u002F resources \u002F prompts, services, upstream APIs, auth mode, consent-round \u002F roots usage\n- [ ] Deployment surface reviewed (if HTTP): bind address, Origin allowlist, session ID, unauth routes, auth-spec compliance\n- [ ] `fuzzTool` started in parallel\n- [ ] Axis 1 — LLM-facing surfaces (tool \u002F resource \u002F prompt output + descriptions) framed and static\n- [ ] Axis 2 — scope granularity audited\n- [ ] Axis 3 — destructive ops verified to gate on a `ctx.requestInput` round that redeems a `ctx.state` record bound to the operation, caller, and target, the response schema-validated, decline\u002Fcancel terminal, non-repeatable actions idempotent per record, `MCP_REQUEST_STATE_KEY` set where state drives a mutation\n- [ ] Axis 4 — upstream auth + token passthrough reviewed\n- [ ] Axis 5 — input sinks (URL \u002F path \u002F roots \u002F shell \u002F proto \u002F schema strictness \u002F ReDoS) checked\n- [ ] Axis 6 — tenant isolation: module-scope state swept\n- [ ] Axis 7 — leakage back: errors \u002F outputs \u002F `ctx.log` \u002F `console.*` \u002F telemetry \u002F constant-time comparisons\n- [ ] Axis 8 — resource bounds on loops \u002F retries \u002F pagination \u002F parse size+depth \u002F per-tenant rate\n- [ ] **If `CANVAS_PROVIDER_TYPE=duckdb`:** Axis 9 — public-data assumption holds, external rate limiting in place, max-canvases-per-tenant + TTLs sized for the deployment, `CANVAS_EXPORT_PATH` (the engine's file surface) doesn't reach shared, served, or caller-private paths, caller SQL reaches DuckDB only through the canvas API\n- [ ] Quick sanity pass: `bun audit`, lifecycle scripts, `.env.example`, config validation, new-dep provenance\n- [ ] Report: summary → grouped findings → numbered options\n",{"name":5,"metadata":47,"description":51},{"type":34,"author":48,"version":49,"audience":50},"cyanheads","1.13","external","Review an MCP server for common security gaps: LLM-facing surfaces as injection vector (tools, resources, prompts, descriptions), scope blast radius, destructive ops without consent, upstream auth shape, input sinks (URL \u002F path \u002F roots \u002F shell \u002F schema strictness \u002F ReDoS), tenant isolation, leakage through errors and telemetry, unbounded resources, and HTTP-mode deployment surface. Use before a release, after a batch of handler changes, or when the user asks for a security review, audit, or hardening pass. Produces grouped findings and a numbered options list.\n","main","3df1d0d67b30ff15236561f8c0f9f06d33f42dfd","skills\u002Fmcp-servers\u002Fcyanheads-security-pass",17,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia","https:\u002F\u002Feth2030.com","Hardcore infra. Building @alt-research and applied cryptography.","2026-11-15 02:28:10",{"source":8,"skillName":5,"commands":62,"prompt":72,"zipAvailable":73},[63,66,69],{"tool":64,"command":65},"npx","npx skills add jiayaoqijia\u002Fcryptoskill --skill security-pass",{"tool":67,"command":68},"bunx","bunx skills add jiayaoqijia\u002Fcryptoskill --skill security-pass",{"tool":70,"command":71},"pnpm","pnpm dlx skills add jiayaoqijia\u002Fcryptoskill --skill security-pass","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fcyanheads-security-pass\u002FSKILL.md",true,[75,79,85],{"path":76,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":78,"sourceHtmlUrl":16},"LICENSE","许可证",11317,{"path":80,"resourceType":81,"resourceTypeDesc":82,"sizeBytes":83,"sourceHtmlUrl":84},"SOURCE.md","REFERENCE","参考文档",372,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fcyanheads-security-pass\u002FSOURCE.md",{"path":86,"resourceType":81,"resourceTypeDesc":82,"sizeBytes":87,"sourceHtmlUrl":88},"TRUST.auto.yaml",2197,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fcyanheads-security-pass\u002FTRUST.auto.yaml",[90,100,108,116,124,132],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":94,"licenseFileUrl":95,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":99},"01M7DTKCERMV0RNX3HZJP4CZ26","troves","Deposit and withdraw from Troves DeFi yield vault strategies on Starknet. View available strategies, check positions, and manage vault deposits. Use this skill when the user mentions Troves, vault, yield vault, DeFi vault, strategy, yield farming, vault deposit, vault withdraw, earning yield through vaults, passive yield strategies, or wants to deposit into or withdraw from a yield strategy — even if they don't say \"Troves\" explicitly.","MIT","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-troves\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-troves\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":94,"licenseFileUrl":104,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":99},"01M7DTK6CJSMGC8KCQHGNYFZBD","trade","Swap tokens on Starknet via Fibrous DEX aggregator. Supports per-provider selection (avnu, ekubo, or auto to race all). Use this skill when the user wants to swap, exchange, trade, convert, buy, or sell one token for another on Starknet. Also use when the user asks about token prices, exchange rates, DEX routing, best swap route, or wants to check how much they would receive for a given amount — even if they don't explicitly say \"swap\".","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-trade\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-trade\u002FSKILL.md",[],[],{"skillNo":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":94,"licenseFileUrl":112,"sourceHtmlUrl":113,"categories":114,"keywords":115,"publishedAt":99},"01M7DTJZ6A0X4PAW3Y8W4J9K64","staking","Stake, unstake, claim, and compound rewards for STRK, WBTC, tBTC, SolvBTC, and LBTC on Starknet. View validators, pools, and staking positions. Use this skill when the user mentions staking, delegating, validators, staking pools, rewards, compounding, unstaking, earning yield, passive income on crypto, or wants to earn on their STRK or BTC tokens — even if they don't say \"stake\" explicitly.","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-staking\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-staking\u002FSKILL.md",[],[],{"skillNo":117,"name":118,"nameZh":6,"description":119,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":94,"licenseFileUrl":120,"sourceHtmlUrl":121,"categories":122,"keywords":123,"publishedAt":99},"01M7DTJSDZJKCDMW7GHRF4BRH5","send","Send STRK, ETH, or any ERC-20 token to a Starknet address. Supports simulation (dry-run) before execution. Use this skill when the user wants to send, transfer, pay, tip, or move tokens to another wallet address on Starknet. Also trigger when the user mentions sending funds to someone, making a payment, transferring assets, or moving crypto to a specific address — even if they just say \"pay 10 STRK to 0x...\".","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-send\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-send\u002FSKILL.md",[],[],{"skillNo":125,"name":126,"nameZh":6,"description":127,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":94,"licenseFileUrl":128,"sourceHtmlUrl":129,"categories":130,"keywords":131,"publishedAt":99},"01M7DTJG1E480D51ZQ7WKDQ26K","portfolio","View a comprehensive DeFi portfolio dashboard and optimize portfolio allocation via automated rebalancing. Use this skill when the user wants an overview, summary, dashboard, total value, net worth, portfolio rebalancing, target allocation, or wants to see all their DeFi positions across Starknet at once. Also trigger when the user asks \"what do I have\", \"show me everything\", \"how much am I worth\", \"my positions\", \"my investments\", \"rebalance my portfolio\", \"I want 50% ETH\", \"optimize my holdings\", or any request for a holistic view of their Starknet holdings — even if they don't explicitly say \"portfolio\".","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-portfolio\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-portfolio\u002FSKILL.md",[],[],{"skillNo":133,"name":134,"nameZh":6,"description":135,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":94,"licenseFileUrl":136,"sourceHtmlUrl":137,"categories":138,"keywords":139,"publishedAt":99},"01M7DTJ7M8TE9R2N36HFBZDGVD","multi-swap","Execute multiple token swaps in a single Starknet transaction via Fibrous (default). Supports per-provider selection (avnu, ekubo, or auto to race all). Supports 2-3 swap pairs bundled into one multicall. Use this skill when the user wants to swap multiple token pairs at once, do batch swaps, execute several trades simultaneously, perform parallel swaps, or do bulk trading in one transaction. Also trigger when the user mentions \"two swaps\", \"three swaps\", \"swap X and Y at the same time\", or wants to convert multiple tokens in a single call.","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-multi-swap\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-multi-swap\u002FSKILL.md",[],[]]