Back to skill

Security audit

Session Memory (Workspace)

Security checks for vulnerabilities and agentic risk

Overview

The skill is coherent and local-only, but it reads private OpenClaw session logs and persists near-verbatim chat excerpts into long-term memory without redaction or clear retention controls.

Install only if you are comfortable letting this skill read your local OpenClaw chat logs and write selected days into persistent memory. Review generated memory/YYYY-MM-DD.md files, avoid using it on sensitive sessions, and delete or edit stored summaries that contain secrets, personal data, or misleading instructions.

Vulnerability Patterns
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
Findings (1)

T02 · Agent Memory Poisoning

Warning
Location
scripts/session-to-memory.js:72
Finding

Untrusted Session Content Is Persisted Without Neutralizing Embedded Instructions

Content
View full analysis

Vulnerability Details

File Location: scripts/session-to-memory.js, lines 72–91 and 127–163
Vulnerability Type: Persistent memory poisoning through untrusted transcript ingestion
Risk Level: Medium

Vulnerable Code

js
function extractMessages(lines, maxMessages) {
  const messages = [];
  for (const obj of lines) {
    if (obj.type !== 'message' || !obj.message) continue;
    const role = obj.message.role;
    if (role !== 'user' && role !== 'assistant') continue;
    const parts = obj.message.content || [];
    for (const p of parts) {
      if (p.type === 'text' && p.text && typeof p.text === 'string') {
        const text = p.text.trim();
        if (text.length > 0) messages.push({ role, text, ts: obj.timestamp });
        if (messages.length >= maxMessages) return messages;
      }
    }
  }
  return messages;
}

function buildSummaryMarkdown(sessionId, date, messages) {
  const lines = [
    `### Session ${sessionId.slice(0, 8)}`,
    '',
  ];
  for (const m of messages) {
    const label = m.role === 'user' ? '**User**' : '**Assistant**';
    const preview = m.text.slice(0, 800) + (m.text.length > 800 ? '…' : '');
    lines.push(`- ${label}: ${preview.replace(/\n/g, ' ')}`);
  }
  lines.push('');
  return lines.join('\n');
}
js
let body = '';
for (const { sessionId, messages } of sessionsForDate) {
  body += buildSummaryMarkdown(sessionId, date, messages);
}
const newSection = `## Session summary\n\n${body}`;

try {
  if (!fs.existsSync(memoryDir)) fs.mkdirSync(memoryDir, { recursive: true });
} catch (e) {
  console.error(JSON.stringify({ ok: false, error: `mkdir memory: ${e.message}` }));
  process.exit(1);
}

let finalContent;
if (opts.append && fs.existsSync(memoryFile)) {
  const existing = fs.readFileSync(memoryFile, 'utf-8');
  if (existing.match(/\n## Session summary\n/i)) {
    finalContent = existing.replace(/\n## Session summary\n[\s\S]*/i, '\n' + newSection);
  } else {
    finalContent = existing.trimEnd() + '
...[truncated 2681 chars]
Remediation
View remediation

Remediation Suggestions

  1. Treat every imported transcript field as untrusted data and preserve that trust classification in structured metadata.
  2. Store transcript excerpts in a clearly delimited quotation or data block that downstream prompts explicitly prohibit from supplying instructions.
  3. Escape or neutralize Markdown constructs and control-like syntax before writing excerpts to memory.
  4. Prefer generating a constrained factual summary rather than copying raw messages. Validate the summary against a schema that excludes directives, tool requests, and behavioral rules.
  5. Add detection for instruction-hijacking patterns and either omit flagged content or require explicit user confirmation before persistence.
  6. Separate historical conversation archives from trusted agent memory. Retrieval logic should place archives in an untrusted context section.
  7. Ensure downstream memory consumers follow an enforced rule that retrieved session text is evidence only and cannot override system, developer, or current-user instructions.
  8. Record provenance, original role, session identifier, and creation time for each entry so retrieved material can be evaluated appropriately.
  9. Add security tests using messages such as “ignore previous instructions” and verify that persisted and retrieved content cannot alter agent behavior.
Vulnerability Patterns
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (6)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The declared description includes two substantive capabilities: writing session summaries to daily memory files and searching session history. The supplied code chunk only covers the second capability. It parses CLI arguments, reads .jsonl session files from a sessions directory, searches user/assistant message text for a query, applies optional date filtering, and prints matching snippets. There is no code to generate summaries, no file-writing behavior, and no interaction with daily memory files. Because the description materially overstates the implemented behavior and references different storage targets, this is a description/behavior mismatch.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
92% confidence
Finding

The implemented behavior partially matches the description: it does write session summaries to daily memory files. However, the declared purpose also says it can 'search session history' so OpenClaw can recall and cite past conversations, and no search functionality appears in this code chunk. The script only filters sessions by date, extracts messages, and writes markdown summaries. Additionally, the code accesses local session files under the user's home directory and writes to workspace/memory, while the declared permissions list is empty; this is an access mismatch relevant to resource usage. Overall, the description overstates the code's capabilities.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
88% confidence
Finding

The skill is explicitly designed to persist prior conversation content into durable memory files and to search historical sessions later. That creates a real privacy and data-retention risk because sensitive information from chats may be stored beyond the original session boundary and later resurfaced to the agent or user without sufficient minimization, consent, or filtering.

Content

Scanner excerpt · README.md (reported line 3)May include surrounding context.

md
# session-memory

OpenClaw skill: write session summaries into daily memory files and search session history so the agent can recall and cite past conversations.

## Features

Session Persistence

Medium
Category
Rogue Agent
Confidence
90% confidence
Finding

This skill is explicitly designed to persist session content and make past conversations searchable, which creates a real privacy and data-retention risk if sensitive material is included. The context makes the behavior expected, but also inherently security-relevant because it expands the lifetime and discoverability of prior chat content.

Content

Scanner excerpt · SKILL.md (reported line 4)May include surrounding context.

md
---
name: session-memory
version: 1.0.0
description: Write session summaries to daily memory files and search session history so OpenClaw can recall and cite past conversations.
metadata: { "openclaw": { "emoji": "📅", "requires": { "bins": ["node"] } } }
---

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The skill encourages persisting past conversation content into durable memory files without a prominent user warning about retention, sensitivity, or consent. That can cause users or downstream agents to store confidential chat data permanently and make it retrievable later via memory search or citations.

Content

No source excerpt is available for this finding.

Vague Triggers

Low
Category
Not specified by scanner
Confidence
86% confidence
Finding

The invocation guidance is broad enough that an agent may use this skill for ordinary 'search prior chats' requests without checking whether the user wants persistent storage or whether the chats contain sensitive information. In context, that increases the risk of over-collection or unexpected retrieval of historical conversations.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.