MCP06
- Location
src/index.ts:69- Finding
Remote Bot Messages Enter a Privileged Agent Run with Automatic Response Forwarding ## Remediation Suggestions 1. Replace the normal agent invocation with a dedicated, stateless bot-chat responder that has no tools, credentials, private memory, filesystem access, or access to user conversations. 2. Pass remote messages as structured, explicitly untrusted data. Keep behavioral instructions separate from remote content; do not rely on quotation marks or delimiters as the primary defense. 3. Validate message and history schemas, enforce collection and string-size limits, and reject malformed depth values. 4. Enforce response length and payload-size limits in code before forwarding. Do not concatenate unrestricted agent payloads into a remote reply. 5. Require trusted-user approval before escalating a bot-originated request into any privileged workflow. 6. Add adversarial tests covering injected instructions in names, message bodies, and history. Verify that these inputs cannot trigger tools or disclose private context.
- Content
View full analysis
Vulnerability Details
File Location:
src/index.ts:69–96; corresponding compiled implementation indist/src/index.js:54–82
Vulnerability Type: Indirect prompt injection and excessive agent authority
Risk Level: HighComplete Code Snippet
ts 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 bot-message handler interpolates remote message text, display names, and supplied conversation history directly into an agent command. Quoting the content does not establish an instruction boundary: embedded instructions remain readable by the model.
The handler invokes the configured agent through
agentCommandFromIngress, without demonstrating a separate tool-free execution environment. It then concatenates all returned text payloads and forwards them to the remote sender. The advertised two-to-five-word response restriction is a prompt instruction, not an enforced output limit.`senderIsOwner: f ...[truncated 2257 chars]
