T02 · Agent Memory Poisoning
- Location
hook/handler.js:128- Finding
Untrusted Cross-Agent Memories Are Persistently Injected into Privileged Bootstrap Context
- Content
View full analysis
{ const ownFilter = agentName ? `AND (agent = $3 OR agent IS NULL)` : ''; const ownParams = agentName ? [minImportance, ownSlots, agentName] : [minImportance, ownSlots]; const { rows: ownRows } = await pool.query( `SELECT content, tier, importance, type, agent, context FROM brainx_memories WHERE tier IN ('hot', 'warm') AND importance >= $1 AND superseded_by IS NULL ${ownFilter} ORDER BY importance DESC, last_seen DESC NULLS LAST, created_at DESC LIMIT $2`, ownParams ); const crossFilter = agentName ? `AND agent IS DISTINCT FROM $3 AND agent IS NOT NULL` : ''; const crossParams = agentName ? [minImportance, crossSlots, agentName] : [minImportance, crossSlots]; const { rows: crossRows } = await pool.query( `SELECT content, tier, importance, type, agent, context FROM brainx_memories WHERE tier IN ('hot', 'warm') AND importance >= $1 AND superseded_by IS NULL ${crossFilter} ORDER BY CASE WHEN 'cross-agent' = ANY(tags) THEN 1 ELSE 0 END DESC, importance DESC, last_seen DESC NULLS LAST, created_at DESC LIMIT $2`, crossParams ); return [...ownRows, ...crossRows]; }, "queryTopMemories"); } ``` ```js function buildMemorySection(agentName, timestamp, teamMems, ownMems) { const lines = [BRAINX_START, ...[truncated 4532 chars]- Remediation
View remediation
