Back to skill

Security audit

Mem Plus

Security checks for vulnerabilities and agentic risk

Overview

This memory skill is mostly purpose-aligned, but it can silently read and return broad local workspace file contents in a way that bypasses its own credential filtering.

Install only if you are comfortable with a memory tool that can index and directly read files under ~/.openclaw/workspace and store/search persistent memory locally. Keep secrets out of that workspace, review what files are present before using filename-like searches or mine, and treat forget as a permanent deletion command.

Vulnerability Patterns
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/mem-plus_cli.py:269
Finding

Credential Filtering Bypass in Direct Filename Retrieval

Content
View full analysis

Vulnerability Details

File Location: scripts/mem-plus_cli.py, lines 240–290 and 474–489
Vulnerability Type: Sensitive-data disclosure caused by inconsistent output sanitization
Risk Level: High

Vulnerable Code

The direct filename retrieval path reads and inserts raw workspace content:

python
def _filename_direct_inject(query: str, results: list) -> list:
    if not _looks_like_filename(query):
        return results

    workspace = os.path.expanduser('~/.openclaw/workspace')

    matched_result = None
    try:
        for fname in os.listdir(workspace):
            fpath = os.path.join(workspace, fname)
            if not os.path.isfile(fpath):
                continue
            ext = os.path.splitext(fname)[1].lower()
            if ext not in ('.md', '.txt', '.json', '.py', '.yaml', '.yml'):
                continue
            try:
                with open(fpath, encoding='utf-8', errors='ignore') as f:
                    first_lines = ''.join(f.readlines()[:50])
                heading_pattern = rf'^#\s*{re.escape(query)}\b'
                if re.search(
                    heading_pattern,
                    first_lines,
                    re.MULTILINE | re.IGNORECASE
                ):
                    with open(fpath, encoding='utf-8', errors='ignore') as f:
                        full_content = f.read(50000)
                    matched_result = {
                        'content': full_content,
                        'score': 999.0,
                        'source': fname,
                        'meta': {'mtime': os.path.getmtime(fpath)},
                        '_injected': True,
                        '_filename_boost': 999.0,
                    }
                    break
            except Exception:
                continue
    except Exception:
        pass

    if not matched_result:
        return results

    res
...[truncated 3690 chars]
Remediation
View remediation

Remediation Suggestions

  1. Move _filename_direct_inject() before the common sanitization stage so all result sources pass through the same controls:

    python
    results = _filename_direct_inject(query, results)
    
    if strip:
        for result in results:
            result['content'] = strip_metadata(result['content'])
    
    for result in results:
        result['content'] = filter_credentials(result['content'])
    
  2. Alternatively, sanitize full_content before constructing the injected result:

    python
    full_content = strip_metadata(full_content)
    full_content = filter_credentials(full_content)
    

    Centralized post-retrieval sanitization is preferable because it reduces the likelihood that future retrieval paths will bypass the controls.

  3. Apply residual credential detection after redaction. If sensitive content is still detected, reject the result rather than returning it.

  4. Use an allowlist of workspace files intended for memory retrieval instead of scanning every supported top-level file. Consider limiting retrieval to documented identity and memory files.

  5. Return only the relevant matched section rather than as many as 50,000 raw characters from the file. This reduces unnecessary exposure and follows data-minimization principles.

  6. Avoid using an unconditional 999.0 boost for directly read files. Rank them using the same relevance and policy checks as other results.

  7. Add regression tests covering:

    • A directly injected file containing a GitHub token.
    • Generic password and API-key assignments.
    • Sensitive metadata prefixes.
    • A secret occurring outside the first 50 lines but inside the returned content.
    • Verification that every returned result has passed the final sanitization stage.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (11)

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
| `scripts/mem-plus_cli.py` | v5 召回引擎入口(19KB) |

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 · scripts/mem-plus_cli.py (reported line 41)May include surrounding context.

python
# ─────────────────────────────────────────────────────────────────

def call_mempalace(args, timeout=30):
    env = os.environ.copy()
    env['PATH'] = f'/Users/mars/Library/Python/3.9/bin:{env.get("PATH", "")}'
    r = subprocess.run(
        [MEMPALACE_CLI] + args,

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The skill explicitly documents a memory-mining command over ~/.openclaw/workspace without any visible warning, consent flow, scope limitation, or exclusion guidance for sensitive files. In a personal-assistant memory system, mining a workspace can ingest private documents, source code, secrets, or unrelated third-party data, increasing the risk of over-collection and later disclosure through recall.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
80% confidence
Finding

The file-level description and multiple user-facing messages are written exclusively in Chinese, with no indication that users can select another language or locale. Under the language/locale policy, forcing a specific language without opt-in can be a natural-language policy violation unless explicitly justified.

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 · scripts/mem-plus_cli.py (reported line 43)May include surrounding context.

python
def call_mempalace(args, timeout=30):
    env = os.environ.copy()
    env['PATH'] = f'/Users/mars/Library/Python/3.9/bin:{env.get("PATH", "")}'
    r = subprocess.run(
        [MEMPALACE_CLI] + args,
        capture_output=True, text=True, timeout=timeout, env=env
    )

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The fallback embedding function sends raw query or content text to a local HTTP service at localhost:11434. Even though the destination is local, this still creates a data exfiltration channel to another process and may expose sensitive memory contents to an untrusted or compromised local service.

Content

No source excerpt is available for this finding.

Internal Network Request

Medium
Category
Server-Side Request Forgery
Confidence
70% confidence
Finding

Code issues a request to a loopback, link-local, or private-range host. This can reach internal services not meant to be exposed and is a common SSRF pivot.

Content

Scanner excerpt · scripts/mem-plus_cli.py (reported line 68)May include surrounding context.

python
embeddings = []
    for text in texts:
        payload = json.dumps({"model": "nomic-embed-text", "prompt": text}).encode()
        req = urllib.request.Request(
            "http://localhost:11434/api/embeddings",
            data=payload, headers={"Content-Type": "application/json"}, method="POST"
        )

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The filename injection path scans ~/.openclaw/workspace, opens matching files, and injects up to 50,000 bytes of full file content directly into search results based only on a query that looks like a filename. This bypasses the normal retrieval boundary and can expose sensitive local workspace data to any caller who can influence search queries, especially because it is silent and prioritized to rank 1.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The forget command permanently deletes a memory entry from a collection via collection.delete(ids=[memory_id]), but the code provides no confirmation prompt, warning message, or other user-facing disclosure before performing the deletion. Because this is an irreversible operation affecting stored user data, the lack of explicit warning is a safety concern.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

The natural-language instructions and descriptions are entirely in Chinese, but the file does not indicate that Chinese is optional, user-selected, or required for a region-specific purpose. Under the policy, forcing a specific language without user opt-in is a locale-policy concern.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

This code directly reads workspace files during search augmentation without user-facing disclosure, which weakens the user's ability to understand when local data is being accessed and returned. In this skill context, search is expected to retrieve indexed memory, not silently open arbitrary matching files from the workspace on demand.

Content

No source excerpt is available for this finding.