Back to skill

Security audit

openclaw-optimize

Security checks for vulnerabilities and agentic risk

Overview

This performance optimizer is mostly purpose-aligned, but it can automatically delete OpenClaw memory/history files and make host-level runtime changes without clear confirmation or rollback.

Review before installing or running. Prefer diagnostic/report commands first, avoid --full, --clean-history, and pro auto_optimize unless you have backed up OpenClaw memory/history files and understand what will be deleted. Do not run the wrapper from untrusted directories, do not run it with elevated privileges, and avoid the README archive path unless you can verify the release source and hash.

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

T08 · Insecure Dependencies

Error
Location
README.md:43
Finding

Unverified Third-Party Archive and Runtime Dependency Installation

Content
View full analysis
/dev/null; then echo -e "${RED}✗ 需要 Python3${NC}" exit 1 fi if ! python3 -c "import psutil" 2>/dev/null; then echo -e "${YELLOW}⚠ 安装依赖: pip install psutil${NC}" pip install psutil -q fi } ``` ### Technical Analysis The installation instructions retrieve a release archive from a personal GitHub repository and install it without validating a cryptographic hash or signature. The archive's shell scripts are subsequently made executable. Consequently, the code ultimately executed by the user is determined by the remote release asset rather than solely by the audited project content. There is also a source inconsistency: the README references `github.com/zhmza/openclaw-optimize`, while `SKILL.md` documents `github.com/openclaw/openclaw-optimize`. This ambiguity makes it harder for users to identify the authoritative source. The wrapper performs `pip install psutil` if the import is unavailable. The dependency has no exact version constraint, lock file, or hash, and installation occurs as a side effect of invoking the Skill rather than during a controlled installation phase. Although `psutil` is a legitimate package, this pattern unnecessarily exposes executio ...[truncated 1159 chars]
Remediation
View remediation
openclaw-optimize-v2.0.0.tar.gz" | sha256sum --check - ``` 3. Prefer signed release artifacts and verify signatures against a documented maintainer key. 4. Download with failure-safe options such as `curl --fail --location --proto '=https'`. 5. Inspect archive paths before extraction and reject absolute paths or `..` traversal entries. 6. Pin Python dependencies to reviewed versions and hashes in a requirements or lock file: ```text psutil== --hash=sha256: ``` 7. Remove implicit `pip install` behavior from runtime commands. If a dependency is missing, exit with a clear installation instruction. 8. Explicitly advise users not to install or run the Skill as root. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
openclaw-optimize.sh:66
Finding

Arbitrary Code Execution Through Python Module Shadowing

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
openclaw_optimize.py:216
Finding

Automatic Irrecoverable Deletion of Agent Memory Files

Content
View full analysis
Dict: """清理旧记录""" cleaned = 0 freed_bytes = 0 cutoff = datetime.now() - timedelta(days=days) if self.memory_dir.exists(): for f in self.memory_dir.iterdir(): if f.is_file(): mtime = datetime.fromtimestamp(f.stat().st_mtime) if mtime < cutoff: freed_bytes += f.stat().st_size f.unlink() cleaned += 1 return { "cleaned_files": cleaned, "freed": self._human_readable(freed_bytes) } ``` Full optimization calls this deletion routine with a three-day retention period: ```python # 2. Clean history print("2. 清理历史记录...") clean_result = self.history.clean_old(days=3) results["actions"].append({ "name": "clean_history", "result": clean_result }) ``` The shell command also runs deletion without requesting confirmation: ```bash # Cleanup echo "" echo "清理3天前的记录..." python3 -c " from openclaw_optimize import HistoryOptimizer opt = HistoryOptimizer() result = opt.clean_old(days=3) print(f\" ✓ 清理文件: {result['cleaned_files']} 个\") print(f\" ✓ 释放空间: {result['freed']}\") " ``` The Pro implementation supports dry-run but defaults it to disabled: ```python def smart_cleanup(self, keep_days: int = 7, dry_run: bool = False) -> Dict: """智能清理""" results = { 'cleaned_files': 0, 'freed_bytes': 0, 'details': [] } cutoff = time.time() - (keep_day ...[truncated 3257 chars]
Remediation
View remediation
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
Findings (28)

Intent-Code Divergence

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

Calling sys.modules.clear() does not clear a benign cache; it wipes the interpreter's loaded module registry and can break runtime invariants unpredictably. In an agent environment this can cause crashes, undefined behavior, and corruption of the running process while presenting itself as a harmless optimization.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

This block writes to /proc/sys/vm/drop_caches and calls sync, which changes kernel-level cache behavior rather than merely optimizing OpenClaw. That exceeds the stated scope of a performance-tuning skill and can disrupt the host system, require elevated privileges, or create instability when run inappropriately.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

At this execution path, the script runs automatic optimization that can delete history files without first obtaining user confirmation or giving a clear warning. Silent destructive behavior is especially dangerous in a maintenance tool because users are likely to trust it and run it broadly.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
95% confidence
Finding

The installation and usage guidance describes aggressive garbage collection, cache cleaning, history optimization, auto-fix, and one-click repair without warning about side effects such as data loss, reduced audit history, service instability, or unintended configuration changes. Because the skill is specifically positioned to change runtime behavior and clean artifacts, omission of warnings materially increases the chance of destructive use.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
96% confidence
Finding

The quick-use section exposes commands for full optimization and history cleanup as simple, routine actions, but gives no warning that they may irreversibly delete history, alter performance settings, or impact system behavior. This is especially risky because users are encouraged to run them directly from the command line, lowering the barrier to accidental destructive changes.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The README advertises automatic detection, one-click fixes, real-time monitoring, and cleanup behavior without warning that these actions may modify system state, clear caches, delete history, or otherwise affect data and runtime stability. In a performance-tuning skill, undocumented automatic remediation increases the risk that a user runs destructive maintenance actions without understanding scope, rollback options, or side effects.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding

The skill documents shell commands and system-modifying operations but does not declare any explicit tool scope or permission boundaries. In an agent ecosystem, this can cause the skill to be invoked with broader-than-necessary capabilities, increasing the risk of unintended command execution, file modification, or privilege misuse.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The documented history-cleaning commands perform deletion of historical data but provide no warning about irreversibility, retention effects, or potential loss of audit/context information. Users or agents following the skill may destroy operational data needed for troubleshooting, compliance, or recovery.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The skill presents commands to disable skills without warning that functionality may be removed, dependencies may break, or security controls could be turned off. In a multi-skill system, disabling components can change runtime behavior in ways that are hard to predict and may reduce resilience or monitoring coverage.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

Configuration apply/reset commands modify active system behavior but are described as routine optimization steps without warning about service impact, unsafe defaults, or rollback needs. This can lead to accidental misconfiguration, degraded availability, or weakened logging/retention settings when executed automatically or by less experienced users.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
90% confidence
Finding

The skill instructs users to run sudo apt-get install, which requires elevated privileges and can modify the host system. Encouraging root-level package installation inside a skill increases the risk of unnecessary privilege escalation, supply-chain exposure, and accidental system-wide changes, especially if executed by an agent or copied without scrutiny.

Content

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

bash
# 系统工具
sudo apt-get install -y htop iotop nethogs

# Python 依赖
pip install psutil memory_profiler line_profiler

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The restart step is presented as part of a normal optimization workflow without warning that it interrupts the running service and may disconnect users or jobs. In production settings, an unplanned restart can cause downtime, failed requests, or state loss.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill recommends unattended cron-based cleanup and optimization, including garbage collection, database vacuuming, and emailed reporting, without warning that scheduled jobs can perform destructive or disruptive actions automatically. Automation magnifies impact because accidental deletion, performance regressions, or service interruptions can recur repeatedly without human review.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

All user-facing help and status text in the script is presented only in Chinese, with no option to choose another language. This creates a language-policy concern because the skill imposes a specific locale on users without documenting it as a justified region-specific constraint or offering opt-in.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The script automatically installs the psutil package from the network during routine execution, expanding its trust boundary and introducing supply-chain risk. A performance utility does not need to mutate the environment at runtime; if an attacker can influence package indexes, mirrors, or pip configuration, this behavior could lead to execution of untrusted code with the user's privileges.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The script performs package installation without prior confirmation, causing an unexpected state change and network access as a side effect of diagnostic/optimization commands. This is dangerous because users invoking a local maintenance tool may unknowingly trigger code download and installation, which increases supply-chain exposure and can break environments or violate operational policies.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The file's user-facing natural-language text and descriptions are presented in Chinese, including the top-level description and runtime output, with no indication that another language can be selected. This can violate a language/locale policy when the skill imposes a specific language without user opt-in.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
81% confidence
Finding

set_limit() changes the process resource limits via resource.setrlimit(RLIMIT_AS), which is a strong runtime control rather than simple monitoring or tuning. The manifest does not mention changing OS-level resource limits, and this capability could destabilize workloads rather than merely optimize OpenClaw performance.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The default full_optimize() flow invokes history.clean_old(days=3), which deletes workspace history files automatically as part of a performance operation. This is dangerous because it performs destructive data deletion without making that consequence explicit to the user, risking loss of conversation history, memory, or forensic/audit data under the guise of optimization.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The cleanup path deletes files from the workspace history area without any warning, confirmation, preview, or backup. In a tool presented as a performance optimizer, silently removing user data is unsafe because users may not expect persistent history and memory records to be destroyed during routine optimization.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The file-level description and user-facing strings are written in Chinese, indicating a fixed language choice with no opt-in or alternative locale handling. This can violate language/locale policy when a skill implicitly forces one language rather than offering a user choice or documenting a justified regional constraint.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The system cache clearing path performs privileged file writes and a system command without prior disclosure or consent. Even if intended as optimization, undisclosed host-level actions violate the principle of least surprise and can affect system behavior beyond OpenClaw.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
91% confidence
Finding

The code invokes a system command as part of an automated optimization path. Although the command arguments are fixed and not shell-injected, this still expands the skill's power into OS-level operations and can have side effects outside normal application tuning, especially when paired with privileged cache manipulation.

Content

Scanner excerpt · openclaw_optimize_pro.py (reported line 122)May include surrounding context.

python
try:
            # Linux: 清理页面缓存
            if os.path.exists('/proc/sys/vm/drop_caches'):
                subprocess.run(['sync'], check=True)
                with open('/proc/sys/vm/drop_caches', 'w') as f:
                    f.write('3')
        except Exception as e:

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The smart_cleanup routine deletes workspace history files based only on age, and auto_optimize can trigger it automatically. Destructive deletion of user data without strong justification, preview, or confirmation creates a real risk of data loss and may remove records the user still needs.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The document promotes broad actions such as '一键优化' and '自动优化' without defining what systems, files, or settings may be changed, or what preconditions and safeguards apply. In a performance-tuning skill, vague automation can mislead users into invoking invasive operations that affect availability, configuration integrity, or stored data without informed consent.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.