T02 · Agent Memory Poisoning
- Location
src/index.ts:396- Finding
Persistent Memory Poisoning Through Automatic Capture and Prompt Reinjection
- Content
View full analysis
= { preference: /\b(prefer|like|always|never|want|love|hate|enjoy|favor|rather)\b/i, decision: /\b(decided|chosen|selected|will use|going with|switched to|moved to|picking)\b/i, fact: /\b(completed|version|status|count|running|deployed|migrated|installed|updated|is at|currently)\b/i, entity: /\b(company|team|person|project|service|app|platform|organization)\b/i, }; ``` ```ts private extractFacts(userMessage: string, agentResponse: string): string[] { const facts: string[] = []; const combined = `${userMessage}\n${agentResponse}`; const sentences = combined .split(/[.!?\n]+/) .map((s) => s.trim()) .filter((s) => s.length > 20); for (const sentence of sentences) { if (isNoise(sentence)) continue; if (sentence.endsWith("?")) continue; if (containsCredential(sentence)) continue; for (const pattern of Object.values(CATEGORY_PATTERNS)) { if (pattern.test(sentence)) { facts.push(scrubCredentials(sentence)); break; } } } return facts.slice(0, 3); } ``` ```ts const memoryBlock = relevant .map((m) => { const pct = Math.round((m.score || 0) * 100); return ` - [${m.category}] (${pct}% relevant) ${m.text}`; }) .join("\n"); const injection = ` Relevant memories from past sessions (use silently to inform ...[truncated 2614 chars]- Remediation
View remediation
