T02 · Agent Memory Poisoning
- Location
lib/hooks.ts:214- Finding
Persistent Prompt Injection Through Untrusted Memory Recall
- Content
View full analysis
= 4) { window.accumulatedContent.push(userContent); } ``` ```ts // lib/hooks.ts:268-275 if (sig.shouldCapture && sig.score >= minSignificance) { const id = await store.add(combinedContent, { sessionKey, conversationId: sessionKey, turnIndex: window.turnCount, messageType: "exchange", source: "assistant", category: sig.category as any, }); ``` ```ts // lib/hooks.ts:364-365 const memories = await store.search(prompt, maxInjections, threshold); if (memories.length > 0) { ``` ```ts // lib/hooks.ts:388-390 if (Array.isArray(event.prependContext)) { event.prependContext.push(context); } ``` ```ts // lib/hooks.ts:507-526 function formatMemorySection( memories: Awaited>, contextBudget: number = 2000, ): string { if (memories.length === 0) return ""; const limited = memories.slice(0, 3); const lines = limited.map((r) => { const cat = r.metadata?.category ?? "other"; const age = formatAge(r.metadata?.createdAt ?? ""); const score = Math.round(r.score * 100); let content = r.content; if (content.length > 150) { content = content.slice(0, 150) + "..."; } return `[${cat}·${score}%·${age}] ${content}`; }); const joined = lines.join("\n"); const truncated = joined.length > contextBudget ? joined.slice(0, contextBudget) + "..." : joined; return ` ## 🧠 Memories (${limited.length}/${memories.length}) ${truncated} `; } ``` ### Technical Analysis Conversation content controlled by a user is accumulated, classifie ...[truncated 2305 chars]- Remediation
View remediation
