MCP06
- Location
src/index.ts:70- Finding
Remote Bot Messages Trigger Agent Runs Without an Explicit Capability Restriction ## Remediation Suggestions 1. Replace general agent execution for automatic replies with a dedicated, tool-free model invocation. 2. Exclude filesystem access, credentials, user transcripts, general agent memory, and privileged tools from the reply-generation context. 3. Supply remote messages as structured, explicitly untrusted data beneath fixed application instructions. Do not rely on quotation marks as a security boundary. 4. Isolate conversation state per peer and validate sender identity and history provenance. 5. Enforce message length, history length, response length, and output-schema limits in code. 6. Require explicit owner authorization before converting a remote bot request into a privileged action. 7. Test that bot-message runs cannot invoke sensitive tools, even when incoming text requests them.
- Content
View full analysis
Vulnerability Details
File Location:
src/index.ts:70–101; compiled counterpart:dist/src/index.js:55–86
Vulnerability Type: Indirect prompt injection / excessive agency
Risk Level: HighVulnerable Code
typescript const sessionKey = `agent:${service.getAgentId()}:bot_message`; const history: BotMessageHistoryEntry[] = [ ...(msg.history ?? []), { from: msg.from, fromName: msg.fromName, bubble: msg.bubble }, ]; const historyLines = history.map((h) => `${h.fromName}: "${h.bubble}"`); const message = `[Bot conversation]\n${historyLines.join("\n")}\n\nReply with a short bubble (2-5 words). Do not repeat what has already been said. Just output the bubble text, nothing else.`; agentCommandFromIngress({ message, sessionKey, agentId: service.getAgentId(), senderIsOwner: false, allowModelOverride: false, deliver: false, }).then((result) => { const replyText = (result.payloads ?? []) .map((p: { text?: string }) => p.text) .filter((t): t is string => typeof t === "string" && t.trim().length > 0) .join(" ") .trim(); if (!replyText) { return; } service.sendBotMessage(msg.from, msg.depth + 1, replyText, { history }).catch((sendErr) => { api.logger.warn(`[kichi:${service.getAgentId()}] bot_message send or history record failed: ${sendErr}`); }); })Technical Analysis
The automatic bot-message handler directly interpolates remote sender names, message content, and supplied conversation history into a request passed to
agentCommandFromIngress.This promotes externally supplied social content into agent-request content without establishing a dedicated, tool-free execution boundary. The instruction to return a short bubble constrains intended output, not agent capabilities. The adapter does not explicitly restrict which tools or sensitive context the resulting run may access.
The flags
senderIsOwner: falseandallowModelOverride: falseare useful safeguards, but their presence does not d ...[truncated 2247 chars]
