T05 · Unauthorized Access and Privilege Escalation
Warning
- Location
- scripts/advisor.js:176
- Finding
- Unrestricted Access to Private Conversation History<![CDATA[ ## Vulnerability Details **File Location**: `scripts/advisor.js:18-19, 176-231` **Vulnerability Type**: Excessive access to sensitive local session data **Risk Level**: Medium ### Complete Code Snippet ```js const SESSIONS_DIR = join(HOME, '.openclaw', 'agents', 'main', 'sessions'); const SESSIONS_META = join(SESSIONS_DIR, 'sessions.json'); function loadHistoryMessages(maxSessions = 5, maxMsgsPerSession = 50) { if (!existsSync(SESSIONS_DIR)) return []; let activeIds = []; if (existsSync(SESSIONS_META)) { try { const meta = JSON.parse(readFileSync(SESSIONS_META, 'utf8')); activeIds = Object.values(meta) .filter(s => s.sessionId) .sort((a, b) => (b.updatedAt ?? 0) - (a.updatedAt ?? 0)) .slice(0, maxSessions) .map(s => s.sessionId); } catch { /* ignore */ } } if (activeIds.length === 0) { try { const files = readdirSync(SESSIONS_DIR) .filter(f => f.endsWith('.jsonl') && !f.includes('.deleted')) .slice(0, maxSessions); activeIds = files.map(f => f.replace('.jsonl', '')); } catch { /* ignore */ } } const messages = []; for (const id of activeIds) { const filePath = join(SESSIONS_DIR, `${id}.jsonl`); if (!existsSync(filePath)) continue; try { const lines = readFileSync(filePath, 'utf8').split('\n'); let count = 0; for (const line of lines) { if (!line.trim()) continue; try { const event = JSON.parse(line); if ( event.type === 'message' && event.message?.role === 'user' && Array.isArray(event.message.content) ) { const text = event.message.content .filter(c => c.type === 'text') .map(c => c.text ?? '') .join(' '); if (text.trim()) { messages.push({ text, timestamp: event.timestamp, sessionId: id }); count++; if (count >= maxMsgsPerSes ...[truncated 2636 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Require explicit, informed consent immediately before accessing historical sessions. 2. Make manual `recommend <task>` mode the default and keep history analysis strictly opt-in. 3. Allow users to select the sessions or time range that may be analyzed. 4. Process one message at a time and retain only aggregate keyword counts rather than complete message text. 5. Do not store timestamps or session identifiers unless they are essential to the recommendation. 6. Apply maximum file-size and message-length limits before parsing transcripts. 7. Exclude content likely to contain secrets, such as authorization headers, private keys, access tokens, and password-like values. 8. Run history analysis in a restricted process with read access only to explicitly approved transcript files. 9. Document exactly which files are read, how many messages are processed, and whether any derived information is retained. ]]>
