Back to skill

Security audit

Context Memory

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly aligned with context-memory management, but it automatically persists and later reuses conversation-derived data with weak controls and an unsafe session-path write pattern.

Review this skill before installing. It is designed to preserve context by writing handoff and memory files, so do not use it for sensitive conversations unless you are comfortable with local plaintext retention. If installed, restrict session IDs to safe characters, store snapshots in a private per-project directory, add redaction and retention rules, and require confirmation before reinjecting saved memory into future sessions.

Vulnerability Patterns
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • 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
Findings (4)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/compaction-extract.sh:12
Finding

Unvalidated Session Identifier Enables Path Traversal and Unsafe File Writes

Content
View full analysis
/dev/null) [ -z "$SESSION_ID" ] && SESSION_ID="${NC_SESSION:-}" [ -z "$SESSION_ID" ] && echo '{"continue":true}' && exit 0 SESSION_DIR="${SESSIONS_DIR}/${SESSION_ID}" HANDOFFS_DIR="${SESSION_DIR}/handoffs" STATE_FILE="${SESSION_DIR}/compaction-extract.json" mkdir -p "$HANDOFFS_DIR" # Track stop count STOP_COUNT=0 if [ -f "$STATE_FILE" ]; then STOP_COUNT=$(jq -r '.stop_count // 0' "$STATE_FILE" 2>/dev/null) fi STOP_COUNT=$((STOP_COUNT + 1)) # Update state TMP="${STATE_FILE}.${$}.tmp" jq -n --argjson count "$STOP_COUNT" '{"stop_count":$count}' > "$TMP" mv "$TMP" "$STATE_FILE" # Only extract every N stops if [ $((STOP_COUNT % EXTRACT_INTERVAL)) -ne 0 ]; then echo '{"continue":true}' exit 0 fi # Extract last assistant message as knowledge to preserve LAST_MSG=$(echo "$INPUT" | jq -r '.last_assistant_message // ""' 2>/dev/null | head -c 5000) [ -z "$LAST_MSG" ] && echo '{"continue":true}' && exit 0 TIMESTAMP=$(date +%s) HANDOFF_FILE="${HANDOFFS_DIR}/pre-compact-${TIMESTAMP}.md" cat > "$HANDOFF_FILE" << EOF # Pre-Compaction Knowledge Extract Timestamp: $(date -u +"%Y-%m-%dT%H:%M:%SZ") Session: ${SESSION_ID} Stop count: ${STOP_COUNT} ## Context Summary ${LAST_MSG} EOF ``` ### Technical Analysis The session identifier comes directly from hook input or the `NC_SESSION` environment variable. It is concatenated into filesystem paths without validation, canonicalization, containment checks, or symlink checks. A value containing `../` components can cause `SESSION_DIR` to resolve outside `~/.openclaw/shared-context/sessions`. The script then performs several filesystem operations using the escaped path: - Recursive directory creation through `mkdir -p`. - Reading ...[truncated 1655 chars]
Remediation
View remediation

T02 · Agent Memory Poisoning

Error
Location
scripts/compaction-extract.sh:41
Finding

Raw Conversation Content Can Poison Persistent Agent Memory

Content
View full analysis
/dev/null | head -c 5000) [ -z "$LAST_MSG" ] && echo '{"continue":true}' && exit 0 TIMESTAMP=$(date +%s) HANDOFF_FILE="${HANDOFFS_DIR}/pre-compact-${TIMESTAMP}.md" cat > "$HANDOFF_FILE" << EOF # Pre-Compaction Knowledge Extract Timestamp: $(date -u +"%Y-%m-%dT%H:%M:%SZ") Session: ${SESSION_ID} Stop count: ${STOP_COUNT} ## Context Summary ${LAST_MSG} EOF jq -n --arg ctx "Knowledge snapshot saved to handoffs/pre-compact-${TIMESTAMP}.md (stop #${STOP_COUNT})." \ '{"hookSpecificOutput":{"additionalContext":$ctx}}' ``` ### Technical Analysis The hook stores the complete last assistant message, up to 5,000 bytes, as persistent memory. It does not extract structured decisions, distinguish data from instructions, record the provenance of individual statements, or neutralize imperative text. Assistant output can contain or quote attacker-controlled material originating from: - User prompts. - Repository files. - Tool output. - Logs and external documents. - Previous injected context. The documented workflow later loads handoff documents or decision records into an agent prompt or `additionalContext`. Consequently, hostile instructions captured in a snapshot can survive compaction or session boundaries and be presented to a future agent as trusted working context. The script itself only injects a notification containing the saved filename. Exploitation across sessions depends on using the documented handoff restoration workflow, which explicitly instructs later agents or hooks t ...[truncated 1309 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/compaction-extract.sh:9
Finding

Conversation Snapshots Are Persisted Without Restrictive Permissions or Retention Controls

Content
View full analysis
"$TMP" mv "$TMP" "$STATE_FILE" ``` ```bash LAST_MSG=$(echo "$INPUT" | jq -r '.last_assistant_message // ""' 2>/dev/null | head -c 5000) [ -z "$LAST_MSG" ] && echo '{"continue":true}' && exit 0 TIMESTAMP=$(date +%s) HANDOFF_FILE="${HANDOFFS_DIR}/pre-compact-${TIMESTAMP}.md" cat > "$HANDOFF_FILE" << EOF # Pre-Compaction Knowledge Extract Timestamp: $(date -u +"%Y-%m-%dT%H:%M:%SZ") Session: ${SESSION_ID} Stop count: ${STOP_COUNT} ## Context Summary ${LAST_MSG} EOF ``` ### Technical Analysis The script automatically writes conversation-derived content to plaintext files under the user's home directory. It does not: - Set a restrictive `umask`. - Explicitly create directories with mode `0700`. - Explicitly create files with mode `0600`. - Filter secrets or sensitive values. - Encrypt stored content. - Define expiration or deletion behavior. - Limit the total number or age of snapshots. Actual accessibility depends on the user's existing umask and permissions on parent directories. With permissive settings, files may be readable by other local users or processes. Even when permissions are restrictive, indefinite retention increases exposure to later account compromise, backups, indexing tools, or accidental disclosure. ### Attack Path 1. An assistant message contains a token, internal path, proprietary code, ...[truncated 819 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Note
Location
scripts/compaction-extract.sh:10
Finding

Unvalidated Extraction Interval Can Terminate the Stop Hook

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (24)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

声明描述的是一个偏高层的上下文管理/知识传递技能,而实际代码仅是一个辅助脚本,用于从 transcript 中读取最后一次 API 响应的 input_tokens。虽然与 'context estimation' 触发词有弱相关性,但它既不能获取上下文窗口大小,也不能管理上下文、压缩知识、跨 session 传递决策或生成交接文档。因此其主要目的与声明不符,属于实质性描述-行为不匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

声明聚焦于‘上下文管理、跨 session 知识传递、压缩前知识保留’等高层工作流能力;而代码仅是测试一个 shell 脚本是否能从 transcript 中提取 input/output token usage,并过滤 streaming placeholder。虽然声明中的 trigger 含有 token budget/context estimation,与 token 统计有弱相关性,但该代码并未实现或展示跨阶段决策传递、记忆整合、handoff 文档生成等核心能力,主要目的与声明明显不一致,因此应判定为 mismatch。

Content

No source excerpt is available for this finding.

Env Variable Harvesting

High
Category
Data Exfiltration
Confidence
60% confidence
Finding

Code enumerates, copies, or searches environment variables for secrets. Bulk environment access can collect credentials unrelated to the skill's stated purpose.

Content

Scanner excerpt · tests/test_compaction_extract.py (reported line 15)May include surrounding context.

python
@pytest.fixture
def env(tmp_path):
    e = os.environ.copy()
    e["HOME"] = str(tmp_path)
    sessions = tmp_path / ".openclaw" / "shared-context" / "sessions"
    sessions.mkdir(parents=True)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
83% confidence
Finding

The skill clearly instructs use of shell commands, environment variables, and file reads/writes via hooks and scripts, but it does not declare any tool scope or allowed-tools boundaries. That omission weakens least-privilege controls and can cause the skill to run with broader capabilities than users or reviewers expect.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill instructs writing structured handoff documents to disk before compaction or stage changes, potentially storing sensitive user data, internal decisions, file paths, or secrets in persistent files. Without an explicit warning, consent model, retention policy, or sanitization guidance, users may unknowingly create durable local records that survive beyond the active session.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill explicitly persists prior session content and instructs later agents to re-inject it into prompts, creating a natural-language channel for cross-session data leakage. If the stored handoff contains secrets, personal data, or task-confidential information, later prompts or agents may expose that data outside its original scope.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

Automatic periodic snapshotting of decisions to disk creates persistent records of prior prompts, architectural choices, and possibly sensitive business or user information. Because this occurs on a timer via hooks, users may not realize that private context is being continuously saved outside the transient model context.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The working-memory design stores current plans and append-only decision logs on disk for later recovery, which can retain sensitive state across crashes, compaction, or future sessions. This persistence increases exposure to local disclosure, accidental reuse in unrelated tasks, and long-lived accumulation of confidential information.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The working-memory files preserve and replay prior decisions and state from disk, which can cause sensitive user-provided content to be retained and resurfaced in later runs. Because the design encourages automatic restoration after crash or compaction, it can unintentionally mix old and new contexts and leak information across task boundaries.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The skill content is written entirely in Chinese and does not indicate that the user may choose another language or that the document is intentionally limited to a Chinese-speaking audience. The policy for this audit requires flagging language or locale constraints when they are imposed without opt-in or clear justification.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The skill explicitly reads local transcript and decision history files, then reinjects recovered content into the active context automatically. That can resurface prior task data, sensitive prompts, file paths, decisions, or other session artifacts without user awareness or consent, creating a confidentiality and context-integrity risk even though the goal is operationally helpful.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

This markdown file presents all instructions and operational guidance in Chinese, which can impose a specific language on users without explicit opt-in. Under the policy criteria, forcing a language or locale without offering a choice is a natural-language policy violation unless clearly justified as region-specific.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

This markdown file presents its substantive instructions and descriptions in Chinese while the surrounding auditing context is in English, and it does not state that the skill is intended only for Chinese-speaking users or offer an opt-in language choice. That can violate language/locale policy by forcing a specific language without user selection.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The skill instructs the agent to persist plans and decision history to .working-state/ across compaction and session boundaries, but it does not warn users that potentially sensitive reasoning, task context, or proprietary data may be written to disk. In this context-management skill, that omission is more dangerous because persistence is the core feature, so operators may unknowingly retain confidential information longer than intended.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

This markdown file contains user-facing instructional content exclusively in Chinese, and there is no indication that users may choose another language or that the skill is intended only for a Chinese-speaking or region-specific audience. Under the language/locale policy, forcing a specific language without user opt-in is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The document explicitly describes reading accumulated transcripts and editing memory files across sessions, but it does not mention consent, retention limits, review controls, or user-visible disclosure of the privacy implications. In a context-memory skill, this omission is more dangerous because the feature is specifically designed to persist and consolidate cross-session information, increasing the chance of storing sensitive data without clear user awareness.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

This markdown file presents most instructional content in Chinese while embedding some English command text, but it does not state that the skill is Chinese-only or give users a language/locale option. Under the policy for natural-language violations, forcing a specific language without opt-in is a reportable issue.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The script periodically writes the last assistant message into a persistent handoff markdown file without any content filtering, redaction, or sensitivity checks. Because assistant messages often contain paraphrased user inputs, secrets, internal reasoning summaries, or security-relevant context, this creates a durable copy of potentially sensitive data that can later be read by other sessions, tools, or users with filesystem access.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · tests/test_compaction_extract.py (reported line 24)May include surrounding context.

python
def run(env, stdin_data="", session_id="test-sess"):
    env["NC_SESSION"] = session_id
    result = subprocess.run(
        ["bash", str(SCRIPTS_DIR / "compaction-extract.sh")],
        capture_output=True, text=True, env=env, input=stdin_data, timeout=10,
    )

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · tests/test_context_usage.py (reported line 18)May include surrounding context.

python
with tempfile.NamedTemporaryFile(mode='w', suffix='.jsonl', delete=False) as f:
        f.write(transcript_content)
        f.flush()
        result = subprocess.run(
            ["bash", str(SCRIPTS_DIR / "context-usage.sh"), f.name],
            capture_output=True, text=True, timeout=10,
        )

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

The primary description and nearly all instructional content are presented in Chinese, and the file does not indicate that language choice is optional or that the skill is region-specific. Under the policy, forcing a specific language without opt-in can be a natural-language policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The natural-language instructions and user-facing injected message are presented in Chinese, which effectively forces a specific language for users of the skill. The file does not offer an opt-in language choice or explain that the skill is intended only for a Chinese-language environment.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The operational instructions and examples are presented in Chinese, which can impose a language constraint on users or downstream agents without any opt-in or explanation. The file does not state that the skill is region-specific or offer an alternative language.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
94% confidence
Finding

The file presents the skill instructions entirely in Chinese, with no indication that the user can choose another language or that the skill is intentionally limited to a Chinese-speaking context. This can violate language/locale policy when a specific language is effectively forced without opt-in.

Content

No source excerpt is available for this finding.