Back to skill

Security audit

Daxiang Memory Optimization

Security checks for vulnerabilities and agentic risk

Overview

This skill is review-worthy because it can automatically prune and overwrite agent memory, with weak recovery safeguards and a hard-coded plaintext archive path.

Install only if you are comfortable with a skill that can automatically remove agent memory. Review or change the defaults before use: disable auto-prune, require dry-run and confirmation, use workspace-relative archives, protect or encrypt archived memory, and add backups or rollback before saving pruned memory.

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 (3)

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:455
Finding
Batch pruning silently discards retained memory records from earlier batches## Vulnerability Details **File Location**: `SKILL.md`, lines 455–469 **Vulnerability Type**: Logic error causing destructive data loss **Risk Level**: High **Vulnerable Code**: ```python for i in range(0, len(memories), batch_size): batch = memories[i:i + batch_size] for memory in batch: memory['relevance_score'] = calculate_relevance_score(memory, "") kept, pruned = prune_low_value_memories(batch) pruned_count += len(pruned) log(f"Batch {i // batch_size + 1}: pruned {len(pruned)} memories") log(f"Total pruned: {pruned_count} memories") return kept ``` ### Technical Analysis The `kept` variable is overwritten during every loop iteration. Consequently, the function returns only the retained records from the final batch rather than all retained records across all batches. This defect becomes active whenever the number of memory records exceeds `batch_size`, which defaults to 50. Records that pass the relevance threshold in earlier batches are omitted from the returned collection. The usage examples elsewhere in the document save returned memory collections, so passing this incomplete result to the documented save operation can overwrite the active memory store and permanently remove valid records. This is an integrity and availability vulnerability in the Skill's memory-management logic. Exploitation does not grant operating-system privileges, but it can destroy Agent state, safety context, decisions, and audit history within the affected workspace. ### Attack Path 1. An attacker or untrusted workload causes the active memory collection to exceed the configured batch size. 2. Important target records are positioned in any batch other than the final batch. 3. Batch pruning evaluates those records and correctly places retained records into the local `kept` variable. 4. A later loop iteration overwrites `kept` with the retained records from the next batch. 5. The function retu ...[truncated 791 chars]
Remediation
## Remediation Suggestions Accumulate retained records across every batch instead of returning the final batch's local result: ```python def batch_prune_memories(memories, batch_size=50): all_kept = [] pruned_count = 0 for i in range(0, len(memories), batch_size): batch = memories[i:i + batch_size] for memory in batch: memory['relevance_score'] = calculate_relevance_score(memory, "") batch_kept, batch_pruned = prune_low_value_memories(batch) all_kept.extend(batch_kept) pruned_count += len(batch_pruned) if len(all_kept) + pruned_count != len(memories): raise RuntimeError("Memory-count invariant failed") return all_kept ``` Additional hardening should include: - Add tests covering zero, one, and multiple batches. - Verify that `retained_count + pruned_count == input_count` before saving. - Reject duplicate or missing memory identifiers. - Save changes atomically to a temporary file and replace the original only after validation. - Keep a recoverable backup or transaction journal before overwriting active memory.

T09 · Insecure Skill Coding Practices

Warning
Location
SKILL.md:335
Finding
Sensitive Agent memory is archived in plaintext at a hard-coded administrator path## Vulnerability Details **File Location**: `SKILL.md`, lines 335–357 **Vulnerability Type**: Plaintext sensitive-data storage and insecure path handling **Risk Level**: Medium **Vulnerable Code**: ```powershell function Archive-Memory { param( [hashtable]$Memory ) $archiveDir = "C:\Users\Administrator\.openclaw\workspace-main\memory\archive" if (-not (Test-Path $archiveDir)) { New-Item -ItemType Directory -Path $archiveDir -Force | Out-Null } $archiveFile = Join-Path $archiveDir "archive-$(Get-Date -Format 'yyyy-MM').json" $archiveEntry = @{ id = $Memory.id content = $Memory.content created_at = $Memory.created_at relevance_score = $Memory.relevance_score archived_at = (Get-Date -Format "yyyy-MM-dd HH:mm:ss") } $json = $archiveEntry | ConvertTo-Json -Compress Add-Content -Path $archiveFile -Value $json -Encoding UTF8 } ``` ### Technical Analysis The archive routine writes complete memory content to an unencrypted JSON file in a predictable, hard-coded location. The project documentation states that memory can contain conversation records, operational logs, decisions, and event details. Such content may include personal data, confidential instructions, operational information, or secrets supplied during Agent interactions. The routine does not redact sensitive fields, encrypt the archive, validate the target workspace, or explicitly enforce restrictive filesystem permissions. Hard-coding an Administrator workspace also creates a cross-workspace isolation risk: if execution is sufficiently privileged, data from one Agent or user context may be deposited into another fixed workspace. If execution is not privileged, the operation may fail and undermine archival guarantees. ### Attack Path 1. Sensitive information is stored in an Agent memory record. 2. The record is selected for pruning or capacity ...[truncated 933 chars]
Remediation
## Remediation Suggestions - Replace the hard-coded Administrator path with a validated, workspace-relative directory obtained from trusted configuration. - Resolve and canonicalize the archive path, then verify that it remains inside the current Agent's authorized workspace. - Create archive directories and files with owner-only permissions. - Encrypt archives at rest using an operating-system protected key or an approved secret-management service. - Redact credentials, authentication tokens, personal data, and other designated sensitive fields before serialization. - Separate archives by Agent and tenant to prevent cross-workspace exposure. - Avoid logging raw memory contents or encryption keys. - Fail closed if secure permissions, encryption, or workspace-boundary validation cannot be established. - Add tests confirming that one Agent cannot read or write another Agent's archive.

T09 · Insecure Skill Coding Practices

Warning
Location
SKILL.md:502
Finding
Automatic destructive memory maintenance lacks transactional and recovery safeguards## Vulnerability Details **File Location**: `SKILL.md`, lines 502–516; related defaults in `config.json`, lines 4–7 and 25–28 **Vulnerability Type**: Unsafe automatic deletion and overwrite behavior **Risk Level**: Medium **Vulnerable Code**: ```python def weekly_maintenance(): memories = load_all_memories() memories = control_memory_size(memories, window=200) memories, _ = prune_low_value_memories(memories, threshold=0.6) clean_old_archive() save_memories(memories) log("Weekly memory maintenance completed") ``` The corresponding configuration enables automatic pruning: ```json { "window": 200, "prune_threshold": 0.6, "enable_auto_prune": true, "prune_interval": 604800 } ``` Archive cleanup is also configured with finite retention: ```json { "enabled": true, "archive_dir": "memory/archive", "retention_days": 90 } ``` ### Technical Analysis The documented maintenance sequence automatically limits memory to 200 records, prunes records below a relevance threshold, cleans old archives, and then saves the reduced collection. The default configuration enables this process on a recurring interval. No dry-run mode, confirmation step, protected-record designation, backup validation, transactional save, rollback mechanism, or post-operation integrity check is shown. The scoring model relies on mutable properties such as relevance score, keywords, age, tags, and access frequency. Incorrect metadata or manipulated memory content can therefore influence which records survive. Archiving reduces immediate data-loss risk, but the maintenance sequence also invokes archive cleanup, while configuration limits retention to 90 days. A record incorrectly removed from active memory may consequently be deleted from its remaining archive after the retention period. ### Attack Path 1. An attacker or untrusted input creates enough records to exceed the 200-record ...[truncated 1126 chars]
Remediation
## Remediation Suggestions - Disable automatic destructive pruning by default and require explicit administrator opt-in. - Add a dry-run mode that reports proposed removals without modifying data. - Support pinned or protected records that cannot be pruned automatically. - Require confirmation when pruning exceeds a defined count or percentage. - Write the new memory state to a separate file, validate it, synchronize it to disk, and atomically replace the original. - Generate a signed or checksummed manifest of retained and removed record identifiers. - Create and verify a recoverable backup before changing active memory. - Separate archival from permanent deletion and require an independent policy for archive cleanup. - Validate metadata and prevent untrusted records from directly assigning authoritative relevance scores. - Impose rate limits and quotas to reduce memory-flooding attacks. - Alert operators when pruning rates exceed expected thresholds. - Test rollback behavior for interrupted writes, scoring failures, and archive failures.
Vulnerability Patterns
  • 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
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (3)

Missing User Warnings

Medium
Confidence
97% confidence
Finding
The skill advertises automatic pruning, deletion, and archiving of memories based on heuristic relevance thresholds without a prominent warning, confirmation flow, or clear retention safeguards. In a memory-management skill, this is materially dangerous because it can silently modify or remove important records, causing data loss, audit gaps, or corruption of the agent's long-term context.

Intent-Code Divergence

Medium
Confidence
95% confidence
Finding
The documentation presents archive behavior as configurable via `archive.archive_dir` set to `memory/archive`, but `Archive-Memory` hard-codes a Windows absolute path `C:\Users\Administrator\.openclaw\workspace-main\memory\archive`. This is not merely incomplete documentation: it actively diverges from the documented configuration model and stated archive location.

Natural-Language Policy Violations

Low
Confidence
95% confidence
Finding
The natural-language content of the skill is presented in Chinese, and there is no indication that users can select another language or that the skill is intentionally region-specific. This can violate language/locale policy when skills force a specific language without user opt-in.

Static analysis

No suspicious patterns detected.