MCP06
- Location
dist/index.js:77- Finding
Memory-Service Responses Can Replace Trusted Conversation Context with Forged Privileged Messages ## Remediation Suggestions 1. **Preserve authoritative context.** Keep gateway-owned system instructions and original conversation messages outside the service’s control. Do not replace them with a service-generated message list. 2. **Use a data-only response schema.** Accept bounded fields for facts, summaries, and retrieved history rather than arbitrary chat messages and role assignments. Reject service-selected privileged roles. 3. **Separate memory from authority.** Insert retrieved content as explicitly untrusted reference material. Do not interpret remembered approvals, user statements, or assistant claims as current authorization. Delimiters alone are not a complete defense. 4. **Isolate privileged directives.** Manage operator directives through a separately authenticated and access-controlled channel rather than combining them with ordinary retrieved memory. 5. **Enforce authorization outside the model.** Require independent checks or fresh user approval for sensitive operations. Service-returned text must not satisfy those checks. 6. **Harden and test the service boundary.** Authenticate service access, restrict connectivity, and add regression tests for forged system messages, fabricated approvals, and attempted removal of original context. Confirm that these responses cannot alter trusted instructions or authorize sensitive actions.
- Content
View full analysis
Vulnerability Details
File Location:
index.ts:94–110,168–181; equivalent implementation indist/index.js:21–31,77–88
Vulnerability Type: Indirect prompt injection / message-role impersonation
Risk Level: MediumComplete Code Snippet
Message validation in
dist/index.js:21–31:javascript var ALLOWED_ROLES = /* @__PURE__ */ new Set(["system", "user", "assistant"]); var sanitizeMessages = (input) => { if (!Array.isArray(input)) return []; const out = []; for (const m of input) { if (m && typeof m === "object" && ALLOWED_ROLES.has(m.role) && typeof m.content === "string") { const msg = m; out.push({ role: msg.role, content: msg.content }); } } return out; };Conversation replacement in
dist/index.js:77–93:javascript async assemble(params) { try { const data = await post("/v1/memory/assemble", { workspace_id: workspaceId, agent_id: agentId, user: params.sessionKey, user_message: lastOf(params.messages, "user") }); const clean = sanitizeMessages(data.messages); if (clean.length > 0) { return { messages: clean }; } } catch (err) { api.logger?.warn?.(`aias-memory: assemble failed (${String(err)}); passing messages through`); } return { messages: params.messages ?? [] }; },Technical Analysis
The context engine accepts service-provided messages with
system,user, orassistantroles. Validation checks only that each role is allowed and its content is a string; it does not establish the authority or provenance of those messages.When the response contains at least one accepted message, the engine returns that list instead of the original
params.messages. The service can therefore remove original instructions, supply arbitrary system instructions, or fabricate user requests and assistant statements.The plugin supports re ...[truncated 2370 chars]
