Back to skill

Security audit

Memory Lesson Manager

Security checks for vulnerabilities and agentic risk

Overview

This skill is mostly a disclosed local memory manager, but its bundled shell scripts include real unsafe patterns that can execute injected shell code or search outside the intended memory area.

Install only if you are comfortable with local shell scripts that create and modify memory, diary, state, and skill files. Run mutating commands with --dry-run first where available, keep backups or version control, do not run rollback rm -rf commands casually, and avoid using untrusted environment variables or untrusted --type values until the eval and path traversal issues are fixed.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (2)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/test-memory-system.sh:55
Finding

Arbitrary Command Execution Through Workspace Environment Variables and eval

Content
View full analysis
/dev/null 2>&1; then ((PASSED++)) log_pass "$desc" return 0 ``` The environment-derived path is embedded into command strings at the call sites: ```bash check "HOT 目录存在" "[ -d \"$MEMORY_DIR/lessons/HOT\" ]" check "WARM/errors 目录存在" "[ -d \"$MEMORY_DIR/lessons/WARM/errors\" ]" check "WARM/corrections 目录存在" "[ -d \"$MEMORY_DIR/lessons/WARM/corrections\" ]" check "WARM/best-practices 目录存在" "[ -d \"$MEMORY_DIR/lessons/WARM/best-practices\" ]" check "WARM/feature-requests 目录存在" "[ -d \"$MEMORY_DIR/lessons/WARM/feature-requests\" ]" check "WARM/decisions 目录存在" "[ -d \"$MEMORY_DIR/lessons/WARM/decisions\" ]" check "WARM/projects 目录存在" "[ -d \"$MEMORY_DIR/lessons/WARM/projects\" ]" check "WARM/people 目录存在" "[ -d \"$MEMORY_DIR/lessons/WARM/people\" ]" check "COLD/archive 目录存在" "[ -d \"$MEMORY_DIR/lessons/COLD/archive\" ]" ``` ### Technical Analysis The script accepts `OPENCLAW_WORKSPACE` or `CLAW_WORKSPACE` from its execution environment. These values are treated as filesystem paths but are subsequently interpolated into strings representing shell commands. The `check` function executes each resulting string with `eval`. Unlike a normal quoted path comparison, `eval` reparses the complete string as shell syntax. Shell metacharacters embedded in a workspace environment variable can therefore terminate the intended test expression and introduce arbitrary commands. The issue is exploitable when an attacker can control the environment used to launch the script. This can occur ...[truncated 1550 chars]
Remediation
View remediation

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
scripts/search-lessons.sh:133
Finding

Directory Traversal in Lesson Type Selection Enables Out-of-Scope Markdown Discovery

Content
View full analysis
/dev/null; then RESULTS+=("$file") ((MATCH_COUNT++)) # 达到限制则停止 if [ "$MATCH_COUNT" -ge "$LIMIT" ]; then break fi fi done < <(find "$SEARCH_DIR" -name "*.md" -type f -print0 2>/dev/null) ``` ### Technical Analysis The documented purpose of `--type` is to select a lesson category such as `errors`, `corrections`, or `best-practices`. The implementation does not enforce those categories and does not reject absolute paths, `..` components, or symbolic-link escapes. Consequently, a value such as `../../..` can cause `SEARCH_DIR` to resolve outside `memory/lessons/WARM`. The only validation is whether the resulting directory exists. `find` then recursively enumerates Markdown files beneath that out-of-scope location, and `grep` searches their contents. For matching files, the script prints the file path, first-line title, parent directory, and match count. Although it does not print every matching line, this still permits discovery and partial disclosure of unrelated Markdown documents. Carefully selected regular expressions can also test whether particular terms occur in those files. ### Attack Path 1. The attacker can invok ...[truncated 1513 chars]
Remediation
View remediation
/dev/null && pwd -P) || { log_error "Lesson type directory does not exist" exit 1 } case "$SEARCH_DIR/" in "$BASE_DIR/"*) ;; *) log_error "Search directory escapes the lesson directory" exit 1 ;; esac ``` 3. Reject `..`, absolute paths, path separators, control characters, and empty option values before path construction. 4. Account for symbolic links. Canonical-path containment checks should occur after symlink resolution, or `find` should be configured so links cannot escape the managed directory. 5. Validate `--limit` as a bounded positive integer and check that all options requiring values actually received one. 6. Add regression tests for values such as `../`, `../../state`, absolute paths, symlinked category directories, missing option arguments, and category names outside the allowlist. ]]>
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (37)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

声明描述的是一个较完整的“学习记录与技能提取工具(V2.0)”,核心能力包括学习条目记录、自动分层、状态恢复和技能提取。实际代码只是一个 shell 脚本,用于创建新的技能目录和模板文件,充其量是“技能提取流程”的脚手架工具。它没有读取或分析学习条目,也没有执行自动分层或状态恢复逻辑,因此与声明的主要用途存在明显差距。虽然“提取技能”这一主题部分相关,但实现范围远小于且实质不同于声明,因此应判定为描述与行为不匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

The description presents the skill as a tool for recording learning items, extracting skills, automatic HOT/WARM/COLD classification, and state restoration. The supplied code chunk does not perform learning-record ingestion, classification, promotion, archiving, or skill extraction. Instead, its primary purpose is environment initialization: scaffolding a memory directory structure and related markdown/template/state files on disk. While this setup supports the broader memory system, the code chunk’s actual behavior is materially different from the declared end-user functionality, so this is a description/behavior mismatch.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The declared description presents a comprehensive learning-record management and skill-extraction tool with features such as recording various learning item types, HOT/WARM/COLD tiering, state restoration, and skill extraction. The supplied code does not implement those functions. Instead, it performs a narrower and different task: parsing a diary markdown file for learning IDs and adding cross-links between the diary and existing lesson files. While this may be tangentially related to a learning-record system, the primary purpose and concrete capabilities of the code chunk are materially different from the declared description. Therefore this is a clear description-behavior mismatch.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

声明描述的是一个以“记录”和“提取”为核心的学习管理工具,包含创建学习条目、分层晋升/归档、状态恢复、技能提取等较完整的知识管理能力。而提供的代码片段仅实现了对 WARM 层 Markdown 文件的文本/模糊搜索:解析查询参数、构造同义词搜索模式、在指定目录中 grep 匹配并输出结果。该行为与“结构化记录工具”的核心目的明显不一致,且出现了未声明的搜索能力。虽然搜索学习条目可能与学习系统相关,但它不足以代表声明中的主要功能,因此应判定为描述与实际行为不匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The declared description presents an operational learning/memory management tool that records and organizes lessons and extracts skills. The supplied code does not implement those user-facing behaviors. Instead, it is a QA/test harness for the skill itself: it inspects workspace paths, verifies required directories/templates/scripts, checks executable permissions and metadata, and reports test results. While these checks support the broader system, this code chunk’s primary purpose is installation/integrity testing, which is materially different from the declared purpose.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The declared description emphasizes a structured learning-memory system with learning entry creation, tier promotion/archiving, state recovery, and skill extraction. The supplied code does not implement those core functions. Instead, it performs diary file quality checks: verifying file existence, reflection sections, priority tags, content length, optional learning-link presence, and problem/solution notes. It can also modify files by creating missing diary files and appending or editing template content when --fix is used. These behaviors are materially different from the declared primary purpose, so this is a clear description-behavior mismatch.

Content

No source excerpt is available for this finding.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
89% confidence
Finding

The rollback instructions include a destructive recursive deletion command (rm -rf memory/lessons/{HOT,WARM,COLD}) that, if copied blindly or run in an unexpected directory/context, can irreversibly delete data. Even though it is presented as rollback guidance, documentation in an agent skill can be surfaced to users or automated workflows, making destructive shell commands materially risky.

Content

Scanner excerpt · references/migration-guide.md (reported line 123)May include surrounding context.

bash
# 1. 删除新结构
rm -rf memory/lessons/{HOT,WARM,COLD}
rm -rf state

# 2. 恢复备份

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
93% confidence
Finding

The command rm -rf memory/lessons deletes the full lessons tree before restore, creating a high risk of accidental or irreversible data loss if the backup path is wrong, missing, or expands unexpectedly. In the context of an agent skill, users may treat documented commands as trusted operational steps, so embedding force-delete commands increases the chance of damaging execution.

Content

Scanner excerpt · references/migration-guide.md (reported line 127)May include surrounding context.

md
rm -rf state

# 2. 恢复备份
rm -rf memory/lessons
cp -r memory-backup-*/memory/lessons memory/

# 3. 验证恢复

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding

The skill advertises and references multiple shell-based scripts that create, modify, archive, and search files, but the manifest does not declare any explicit tool scope such as allowed shell or filesystem permissions. That creates an authorization and review gap: an operator cannot easily tell what capabilities the skill needs, and broad shell access could be granted implicitly or unexpectedly.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

Broad and ambiguous trigger phrases increase the chance that the skill activates in contexts the user did not intend. In a skill that can write, modify, promote, and archive files, over-triggering can lead to unintended filesystem changes or workflow interference even without malicious intent.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The skill documentation states that it can modify, promote, and archive user files, but it does not clearly warn about impact or require confirmation. In a memory-management context, silent edits or archival can alter records, break workflows, or hide data in unexpected locations, making this a meaningful integrity risk.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The entire migration guide is written only in Chinese, with no indication that users may choose another language or that the skill is region-specific. Under the policy rule for natural-language constraints, this effectively imposes a locale/language requirement without documented opt-in or justification.

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 operational guidance in a single language and does not indicate that users may choose another language or that the skill is intentionally limited to a Chinese-speaking context. Under the language/locale policy, forcing one language without opt-in is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

This markdown file includes a command for validate-diary.sh --fix, which by name and context indicates automatic repair of diary content. The surrounding documentation provides no caution that the command may edit files, overwrite formatting, or should be reviewed before use.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The markdown instructs users to run archive-cold.sh in execute mode after showing a dry-run, but it does not explicitly warn that this operation archives entries and may affect file organization or retrieval. Because archiving changes the state/location of user-maintained records, the documentation should clearly disclose that effect.

Content

No source excerpt is available for this finding.

Skill Enumeration

Medium
Category
Agent Snooping
Confidence
80% confidence
Finding

Skill enumerates or reads other installed skills. Access to other skills' SKILL.md files or the skills directory reveals prompt instructions, capabilities, and secrets that should be invisible to peer skills.

Content

Scanner excerpt · references/usage-examples.md (reported line 301)May include surrounding context.

md
[INFO] 创建技能:git-auth-helper
[STEP] 1/4 创建目录结构
[STEP] 2/4 创建 SKILL.md
[INFO] 已创建:./skills/git-auth-helper/SKILL.md
[STEP] 3/4 创建 references 目录
[STEP] 4/4 创建 scripts 目录

Skill Enumeration

Medium
Category
Agent Snooping
Confidence
80% confidence
Finding

Skill enumerates or reads other installed skills. Access to other skills' SKILL.md files or the skills directory reveals prompt instructions, capabilities, and secrets that should be invisible to peer skills.

Content

Scanner excerpt · references/usage-examples.md (reported line 311)May include surrounding context.

md
[INFO] 创建技能:git-auth-helper
[STEP] 1/4 创建目录结构
[STEP] 2/4 创建 SKILL.md
[INFO] 已创建:./skills/git-auth-helper/SKILL.md
[STEP] 3/4 创建 references 目录
[STEP] 4/4 创建 scripts 目录

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This markdown file contains user-facing operational instructions only in Chinese, including headings, parameter descriptions, and migration guidance. Under the policy rule, forcing a specific language without user opt-in or documented justification is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The header comments and usage text describe archiving as moving WARM entries that have not been used for 90 days and specifically list '最后出现日期 > days 天前' as the condition. However, the implementation computes archive eligibility from filesystem modification time at L263-L266 and overrides the user-facing threshold with dynamic 30/90/180-day cutoffs based on grep-derived reference counts at L247-L260, which materially contradicts the documented behavior.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

Comments and usage text state the script '建立双向链接' and says it adds a related-lessons section to the diary. However, while the lesson file receives a concrete diary link, the diary receives entries like lessons/WARM/*/$lesson_id*.md, which are not the actual located LESSON_FILE path and may not resolve to a usable reciprocal link.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The help text says --all will handle '本周所有日记', implying multi-file weekly processing. In the implementation, PROCESS_ALL is set when --all is passed, but never used later; the script always builds exactly one DIARY_FILE from TARGET_DATE and processes only that file.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The header comments and usage text state that promotion requires usage within 7 days and at least 3 uses, but the implemented eligibility check uses a reference-count threshold of less than 2 as the cutoff. This is an active contradiction in intent documentation, not just an omitted detail, and it can cause operators to believe stricter criteria are enforced than the code actually applies.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This shell script creates the HOT directory and later writes to HOT and lesson markdown files, which are safety-relevant file modifications. Although it logs actions, there is no explicit user confirmation before executing non-dry-run changes, and the script also supports a force mode that can override normal checks.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The manifest describes a tool for recording structured learning items, tiering them, restoring state, and extracting skills. This script instead validates free-form diary files and, in --fix mode, creates or edits diary markdown content, which is a distinct diary-quality-check capability not clearly covered by the declared skill purpose.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

This shell script supports a --fix mode that can create a missing diary file and append or modify content in existing diary files, but the help text only says it will 'automatically fix repairable issues' without clearly warning that it will write to user files. Although individual actions are logged during execution, there is no clear pre-execution disclosure or confirmation before these file modifications occur.

Content

No source excerpt is available for this finding.