MCP07
- Location
plugin/dist/index.js:2625- Finding
Memory consolidation bypasses write authorization through an unrestricted storage upsert ## Remediation Suggestions 1. **Enforce authorization at the storage boundary.** Require a caller identity for ordinary `updateNote()` operations and verify `canWrite()` against the stored note before any upsert. Reserve a separate, explicit maintenance interface for trusted internal operations. 2. **Authorize both merge participants.** Exclude non-writable notes before candidate generation, and recheck both notes immediately before mutation. Abort the merge if either authorization check fails. 3. **Restrict interactive consolidation.** Permit namespace-wide consolidation only for authorized owners or administrators. If ordinary chat participants may consolidate, constrain the operation to their permitted subject scope and writable notes. 4. **Validate dedicated-collection isolation.** Detect unintended collection reuse across agents. Where reuse is intentional, retain agent and reader filtering rather than relying exclusively on physical collection isolation. 5. **Handle partial failures safely.** Preflight authorization before replacing either note. Record merge state so failures during replacement, retirement, or link updates can be recovered without leaving unauthorized or inconsistent changes. 6. **Add regression tests.** Verify that consolidation cannot modify or retire non-writable notes, including when two agents share a dedicated collection, the protected note is selected as the retained note, or retirement of the second note is denied.
- Content
View full analysis
Vulnerability Details
File Location:
plugin/dist/index.js:2625–2730— consolidation processing and unauthorized write;plugin/dist/index.js:4183–4208— model-accessible tool handler.
Vulnerability Type: Missing authorization for persistent memory modification (CWE-862).
Risk Level: Medium.Technical Analysis
The
memory_consolidatetool invokes consolidation using the current agent’s storage scope. Consolidation retrieves private notes without requiring that the caller can write them:javascript const rawNotes = await ctx.listNotes(agentId); const allNotes = rawNotes.filter((n) => n.agent_id !== "shared");After selecting a sufficiently similar pair and receiving an affirmative LLM merge decision, consolidation updates the retained note and calls the unrestricted storage method:
javascript keepNote.content = mergeDecision.merged; keepNote.tags = Array.from(/* @__PURE__ */ new Set([...keepNote.tags, ...dropNote.tags])); keepNote.keywords = Array.from(/* @__PURE__ */ new Set([...keepNote.keywords, ...dropNote.keywords])); keepNote.links = Array.from(/* @__PURE__ */ new Set([...keepNote.links, ...dropNote.links])).filter( (id) => id !== keepNote.id && id !== dropNote.id ); keepNote.retrieval_count = (keepNote.retrieval_count || 0) + (dropNote.retrieval_count || 0); const keepAccessTime = new Date(keepNote.last_accessed || keepNote.timestamp).getTime(); const dropAccessTime = new Date(dropNote.last_accessed || dropNote.timestamp).getTime(); keepNote.last_accessed = keepAccessTime >= dropAccessTime ? keepNote.last_accessed || keepNote.timestamp : dropNote.last_accessed || dropNote.timestamp; const embedText = buildEmbedText(keepNote); keepNote.embedding = await encode(embedText); keepNote.hash = (0, import_crypto.createHash)("md5").update(keepNote.content).digest("hex"); keepNote.evolution_history = keepNote.evolution_history || []; keepNote.evolution_history.push({ triggeredBy: dropNote.id, triggeredAt: (/* @__PURE__ */ ...[truncated 3881 chars]
