T01 · Skill Instruction Hijacking
- Location
src/modules/session-bridge.ts:192- Finding
Cross-session transcript injection can disclose unrelated conversations and poison persistent memory
- Content
View full analysis
0) { const c = cands[0]; return { filePath: c.path, sessionId: c.sessionId, mtimeMs: c.mtime, matchedChatId: currentChatId ?? "(per-agent fallback)", }; } ``` ```ts const lines: string[] = [ "🔄 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━", ` PRIOR_SESSION_CHECKPOINT —— 上一段会话的尾段(${ageStr})`, "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━", "", `当前 session 因 OpenClaw runtime 硬 reset / compact 跟上文断了。enhance session-bridge 自动从前一个 session 文件拉回最后 ${msgs.length} 条 user/assistant 原始对话——**这是历史延续,不是用户当下的新请求**。`, "", `**前 session 完整文件**(需要中段/决策/tool result 时 Read 这个):\`${prior.filePath}\``, lastMsgTime ? `**最后一条消息时间**:${lastMsgTime}` : "", "", "**使用建议**:", "1. 用户没明示『延续昨天的话题』时,先把这段当作背景理解,不要主动 echo / 复述", "2. 需要更多上下文 → 主动 Read 上面那个完整 jsonl 文件(或 enhance_transcript_search)", "3. 重要决策 / 进展 / 用户偏好 → 调 `enhance_memory_store` 记到分类记忆,避免下次 reset 又得重新拉", "", "──── 历史尾段 message ────", "", ]; ``` ```ts const currentChatId = readChatId(currentJsonl); const prior = findPriorBridgeSource( sessionsDir, currentChatId, sessionId, priorMaxAgeMs, ); if (!prior) return undefined; const msgs = readLastMessages(prior.filePath, tailN, perMsgCap); if (msgs.length === 0) return undefined; const text = buildBridgeText(prior, msgs, maxChars); if (!text) return undefined; shouldBridge(dedupKey); return { prependContext: text }; ``` ### Technical Analysis The bridge normally attempts to identify a previous conversation by `chat_id`. If that identi ...[truncated 2287 chars]- Remediation
View remediation
