Back to skill

Security audit

Memory Optimizer

Security checks for vulnerabilities and agentic risk

Overview

The skill is purpose-aligned for memory indexing, but it stores full memory text in a plaintext index and can retain redacted content while also encouraging background monitoring.

Review this skill before installing if your OpenClaw memory may contain private data. It duplicates memory text into a plaintext index, may preserve text after you edit it out of the original file, starts a background watcher in quickstart, and installs an unpinned Python dependency. Avoid running the installer with sudo, consider a virtual environment, and inspect or patch the index cleanup behavior before use.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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)

T08 · Insecure Dependencies

Warning
Location
install.sh:22
Finding

Unpinned Third-Party Dependency Installation

Content
View full analysis

Vulnerability Details

File Location: install.sh:22-24
Additional Locations: SKILL.md:25-27, docs/README.md:49-52, skill.json:27-33
Vulnerability Type: Unpinned dependency installation and supply-chain exposure
Risk Level: Medium

Vulnerable Code

bash
# 安装依赖
echo "📦 安装 Python 依赖..."
pip3 install watchdog

The same unrestricted package installation is declared in skill.json:

json
"dependencies": [
  "watchdog"
],
"commands": [
  "pip3 install watchdog",
  "chmod +x scripts/*.py scripts/*.sh"
]

Technical Analysis

The installer obtains the latest version of watchdog resolved by the user's configured Python package index. It does not specify an audited version, verify an integrity hash, use a lock file, or isolate the dependency in a dedicated virtual environment.

The dependency is legitimate and necessary for the real-time watcher, and no dependency-confusion or typosquatting package was identified in the supplied project. Nevertheless, unrestricted dependency resolution means the code installed today may differ from the code reviewed or installed later. A compromised upstream release, compromised package index, maliciously configured index, or incompatible future release could introduce arbitrary installation-time or runtime behavior.

Because pip3 installs packages using the privileges of the invoking user, the resulting exposure depends on how the installer is launched. Normal use exposes the OpenClaw user's account and data; running the installer with elevated privileges would unnecessarily increase the potential impact.

Attack Path

  1. An attacker compromises the upstream package, its maintainer account, a configured package index, or the dependency delivery path.
  2. A malicious version becomes the version selected by the unrestricted pip3 install watchdog command.
  3. The user executes install.sh.
  4. Pip retrieves and installs the se ...[truncated 837 chars]
Remediation
View remediation

Remediation Suggestions

  1. Pin watchdog to a reviewed version rather than resolving the newest release:

    bash
    python3 -m pip install 'watchdog==<reviewed-version>'
    
  2. Maintain a requirements lock file containing integrity hashes and install with hash enforcement:

    bash
    python3 -m pip install --require-hashes -r requirements.txt
    
  3. Install dependencies into a dedicated virtual environment rather than modifying the user's global Python environment.

  4. Document that the installer must not be run with sudo or as root.

  5. Keep the pinned dependency under periodic security review and update it through an explicit, tested release process.

  6. Ensure SKILL.md, docs/README.md, and skill.json all use the same pinned and verified dependency specification.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/memory-dedup.py:31
Finding

Plaintext and Stale Retention of Complete Agent Memory Content

Content
View full analysis

Vulnerability Details

File Location: scripts/memory-dedup.py:31-33
Additional Locations: scripts/memory-dedup.py:145-181, scripts/memory-watcher.py:40-42, scripts/memory-watcher.py:96-133
Vulnerability Type: Plaintext sensitive-data storage and incomplete index replacement
Risk Level: Medium

Vulnerable Code

The index is written as an ordinary plaintext JSON file without explicitly enforcing restrictive permissions:

python
def save_index(index: dict):
    """保存索引文件"""
    INDEX_FILE.parent.mkdir(parents=True, exist_ok=True)
    with open(INDEX_FILE, 'w', encoding='utf-8') as f:
        json.dump(index, f, indent=2, ensure_ascii=False)

Complete memory chunks are stored rather than only hashes or minimal retrieval metadata:

python
def index_file(file_path: str, index: dict) -> dict:
    """索引单个文件,返回更新后的索引"""
    with open(file_path, 'r', encoding='utf-8') as f:
        content = f.read()

    file_hash = compute_hash(content)
    chunks = chunk_memory(content)

    new_chunks = 0
    for i, chunk in enumerate(chunks):
        chunk_hash = compute_hash(chunk)

        # 如果 chunk 已存在,跳过
        if chunk_hash in index["chunks"]:
            continue

        # 新增 chunk
        index["chunks"][chunk_hash] = {
            "content": chunk,
            "source": file_path,
            "chunk_index": i,
            "total_chunks": len(chunks),
            "indexed_at": datetime.now().isoformat()
        }
        new_chunks += 1

    # 更新文件记录
    index["files"][file_path] = {
        "hash": file_hash,
        "chunks": len(chunks),
        "indexed_at": datetime.now().isoformat()
    }

The watcher implements the same behavior:

python
def save_index(self):
    """保存索引文件"""
    self.index_file.parent.mkdir(parents=True, exist_ok=True)
    with open(self.index_file, 'w', encoding='utf-8') as f:
        json.dump(self.in
...[truncated 2766 chars]
Remediation
View remediation

Remediation Suggestions

  1. Before re-indexing a modified file, remove all chunks previously associated with that file, then add the current chunks.

  2. Redesign deduplication metadata so a chunk can safely track multiple source files. Removing one source must not delete a shared chunk still referenced by another file.

  3. Explicitly create and maintain the index with owner-only permissions:

    python
    os.chmod(INDEX_FILE, 0o600)
    

    Use restrictive creation flags so the file is never briefly exposed with broader permissions.

  4. Write the index atomically to a temporary file in the same directory, set mode 0600, flush and synchronize it, and then replace the destination with os.replace.

  5. Validate and repair permissions when loading an existing index.

  6. Store only hashes and minimal metadata unless plaintext chunk content is strictly required. If content search is required, document the duplication and retention behavior clearly.

  7. Consider encryption at rest using a securely managed key when memory files may contain confidential data.

  8. Add regression tests confirming that text removed from a modified source file is no longer present or searchable in .index.json.

  9. Apply the same hardened storage and replacement logic to both memory-dedup.py and memory-watcher.py to prevent inconsistent behavior.

Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (15)

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

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

索引文件损坏:

bash
rm ~/.openclaw/workspace/memory/.index.json
python3 scripts/memory-dedup.py ./memory/

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · docs/README.md (reported line 284)May include surrounding context.

索引文件损坏:

bash
rm ~/.openclaw/workspace/memory/.index.json
python3 scripts/memory-dedup.py ./memory/

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The skill documents automatic cleanup of deleted-file indexes and archival of memories older than 90 days, but it does not clearly warn users that data may be moved out of the active search path or become harder to retrieve. In a memory-management skill, this behavior is expected, but without explicit safeguards or recovery guidance it can lead to accidental data unavailability or perceived loss.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The README advertises automatic archival, movement of files older than 90 days, compression, and index cleanup, but it does not prominently warn that these operations modify or remove active files from their original location. In an agent memory context, unattended data-moving behavior can cause unintended loss of discoverability or operational confusion if users assume memories remain searchable in place.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The cron setup instructs users to schedule unattended execution of the archive script, but the documentation does not clearly warn that it will run automatically and modify stored memory files and indexing state. Because the job persists beyond the current session, users may forget it is active and later misinterpret moved or missing files as corruption or data loss.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
85% confidence
Finding

The documented use of crontab establishes persistent, unattended behavior that continues after the initiating session, which is risky in an agent skill handling user memory. While cron itself is legitimate, persistence is security-relevant here because it causes ongoing automated modification of user data without in-band runtime visibility or repeated consent.

Content

Scanner excerpt · docs/README.md (reported line 98)May include surrounding context.

bash
# 添加 cron 任务(每季度第一天运行)
crontab -e

# 添加以下行:
0 9 1 1,4,7,10 * ~/.openclaw/workspace/scripts/memory-archive.sh

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The installer writes into the user's workspace, copies executable scripts, changes permissions, and runs pip3 install watchdog without any confirmation, dry-run mode, or clear warning about side effects. In an agent-skill context, silent filesystem modification and dependency installation increase risk because users may run the script with trust assumptions and may not realize it changes their environment or pulls code from package repositories.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The script launches memory-watcher.py in the background against a ./memory/ directory immediately after installation, without requiring explicit user confirmation or clearly disclosing that persistent monitoring will continue after the script exits. In a tool described as a memory optimization package, silent background monitoring increases the risk of unintended collection, processing, or retention of user data and reduces the user's ability to give informed consent.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

This Python file contains its top-level description, CLI help text, and status messages in Chinese only, which imposes a specific language on users. Under the policy, locale-specific behavior should either provide user opt-in/choice or clearly document why the locale restriction is required.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The docstring promises age-based cleanup for chunks from deleted files, but the implementation removes all orphan chunks immediately and does not check any timestamp or 30-day threshold. This mismatch can cause unintended data loss, especially if file metadata or the index becomes temporarily inconsistent, and it undermines operator trust in cleanup behavior.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The top-level docstring, usage guidance, and operational descriptions are entirely in Chinese, which imposes a specific language on users without any opt-in or fallback. Under the policy, locale or language constraints should be optional or explicitly justified as region-specific.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill description is written entirely in Chinese, which creates a language-specific presentation in the manifest without indicating that users can choose another language. Under the stated policy, forcing a specific language without opt-in is 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 throughout the skill are presented in Chinese, which effectively forces a specific language for users reading setup and operating guidance. The file does not offer an English alternative, user language choice, or justification that this is intended only for a Chinese-speaking or region-specific audience.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
98% confidence
Finding

The script's comments and all visible output strings are in Chinese, with no option for the user to select another language. This can violate language or locale policy when the skill is not explicitly documented as Chinese-only or region-specific.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

The script's comments and all user-visible status messages are in Chinese, with no indication that this locale is optional or required for a region-specific use case. This can violate language/locale policy when a skill forces a specific language without user opt-in.

Content

No source excerpt is available for this finding.