Back to skill

Security audit

Agent Optimize

Security checks for vulnerabilities and agentic risk

Overview

This skill is mainly a local OpenClaw performance diagnostic, but it reads sensitive local session and .env data and its documentation promotes cleanup, backup, and scheduled automation beyond its stated read-only permission model.

Install only if you are comfortable with a diagnostic tool reading OpenClaw session files, memory metadata, skill folders, config files, and the workspace .env file. Treat generated reports and /tmp backups as potentially sensitive, avoid enabling cron or auto-fix workflows without review, and prefer a revised version that avoids parsing secret values and clearly separates read-only diagnostics from write-capable cleanup.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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 (2)

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
src/index.js:69
Finding

Unnecessary Loading of Sensitive Session and Environment Data

Content
View full analysis
f.endsWith('.json')); sessionCount = sessions.length; sessions.forEach(session => { const filePath = path.join(sessionsPath, session); const stats = fs.statSync(filePath); sessionSize += stats.size; try { const content = fs.readFileSync(filePath, 'utf-8'); const lines = content.split('\n').length; if (lines > CONFIG.maxContextLines) { largeSessions.push({ name: session, lines }); } } catch (e) {} }); } ``` The configuration analysis also loads complete `.env` values: ```javascript const configPaths = [ path.join(PATHS.openclaw, 'openclaw.json'), path.join(PATHS.openclaw, 'config.json'), path.join(PATHS.workspace, 'openclaw.json'), path.join(PATHS.workspace, '.env'), ]; configPaths.forEach(configPath => { if (fs.existsSync(configPath)) { try { const content = fs.readFileSync(configPath, 'utf-8'); let config = {}; if (configPath.endsWith('.json')) { config = JSON.parse(content); } else if (configPath.endsWith('.env')) { content.split('\n').forEach(line => { const [key, value] = line.split('='); if (key && value) { config[key.trim()] = value.trim(); } }); } ``` ### Technical Analysis The diagnostic only needs session line counts and configuration key names. Nevertheless, it reads complete session files and parses complete `.env` values into process memory. Session histories may contain private conversations, credentials, tool results, and operational data. Environment files commonly contain API tokens, database passwords, and other secrets. Loading those values increases the a ...[truncated 1362 chars]
Remediation
View remediation

T05 · Unauthorized Access and Privilege Escalation

Note
Location
src/index.js:44
Finding

Shell Execution Exceeds the Declared Command Allowlist

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (18)

Intent-Code Divergence

High
Category
Not specified by scanner
Confidence
96% confidence
Finding

The file simultaneously denies writes while advertising automatic cleanup, deletion, archiving, and modification behaviors. Contradictory safety claims increase the chance that a reviewer, user, or execution framework will underestimate the skill's real risk and allow unsafe invocation.

Content

No source excerpt is available for this finding.

Scope Creep

High
Category
Not specified by scanner
Confidence
96% confidence
Finding

The documentation describes auto-fix, backup creation, permission repair, and cron-management despite the manifest denying writes and network. This creates a dangerous capability mismatch: operators may trust the manifest while the skill instructions encourage persistence, file modification, and scheduled execution.

Content

No source excerpt is available for this finding.

Lp1

High
Category
MCP Least Privilege
Confidence
96% confidence
Finding

The skill relies on multiple environment variables such as OPENCLAW_HOME and OPTIMIZE_* settings, but the declared permissions only list shell, read, and analyze. Undeclared environment access expands what the skill can learn about the runtime and host configuration, which matters because env values commonly contain paths, tokens, and deployment metadata.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
97% confidence
Finding

Including the workspace .env file in diagnostic scanning gives the skill direct access to secrets commonly stored there, such as API keys, passwords, and tokens. In a skill with read and shell permissions, this materially increases the sensitivity of the data the skill can access beyond what is necessary for optimization diagnostics.

Content

Scanner excerpt · src/index.js (reported line 281)May include surrounding context.

js
path.join(PATHS.openclaw, 'openclaw.json'),
    path.join(PATHS.openclaw, 'config.json'),
    path.join(PATHS.workspace, 'openclaw.json'),
    path.join(PATHS.workspace, '.env'),
  ];
  
  let configs = [];

Credential Access

High
Category
Privilege Escalation
Confidence
97% confidence
Finding

The .env parsing logic reads every key/value pair into memory, which is exactly the pattern used to harvest credentials from environment files. Even though the current report only stores keys, the act of parsing secret values is unnecessary for the stated purpose and creates avoidable exposure if logs, exceptions, or later code changes leak them.

Content

Scanner excerpt · src/index.js (reported line 296)May include surrounding context.

js
if (configPath.endsWith('.json')) {
          config = JSON.parse(content);
        } else if (configPath.endsWith('.env')) {
          content.split('\n').forEach(line => {
            const [key, value] = line.split('=');
            if (key && value) {

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

Nearly all user-facing documentation is presented in Chinese, and there is no indication that another language is supported or that the Chinese-only presentation is intentional for a region-specific audience. This can violate language/locale policy when users are not given a choice or opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The manifest description, use cases, and trigger phrases are predominantly in Chinese, and the rest of the skill documentation continues in Chinese without stating that users may interact in other languages. This creates a natural-language locale constraint without user opt-in or a documented regional justification, which matches the policy-violation category.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The skill is presented as a diagnostic/read-oriented optimizer, but it also documents '--auto-fix' and operational changes. This mismatch can mislead users or orchestration systems into invoking a skill under lower trust assumptions while it performs state-changing actions.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
93% confidence
Finding

This is the same session-persistence issue reflected by a duplicate finding: the skill recommends creating durable copies of memory and session artifacts before optimization. Even if intended as safety backup, it broadens the attack surface by preserving sensitive conversational data outside its normal storage boundary.

Content

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

bash
# 優化前自動備份
backup_dir="/tmp/agent-optimize-backup-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$backup_dir"
cp -r ~/.openclaw/workspace/*/memory "$backup_dir/"
cp -r ~/.openclaw/sessions "$backup_dir/"

Session Persistence

Medium
Category
Rogue Agent
Confidence
93% confidence
Finding

This is the same session-persistence issue reflected by a duplicate finding: the skill recommends creating durable copies of memory and session artifacts before optimization. Even if intended as safety backup, it broadens the attack surface by preserving sensitive conversational data outside its normal storage boundary.

Content

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

bash
# 優化前自動備份
backup_dir="/tmp/agent-optimize-backup-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$backup_dir"
cp -r ~/.openclaw/workspace/*/memory "$backup_dir/"
cp -r ~/.openclaw/sessions "$backup_dir/"

File System Enumeration

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Code scans file system directories looking for sensitive files. This could be reconnaissance for credential theft.

Content

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

解決方案:

bash
# 檢查權限
ls -la ~/.openclaw/workspace*/memory

# 修復權限
chmod -R u+rw ~/.openclaw/workspace*/memory

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

This code reads OpenClaw JSON configs and the workspace .env file, then parses all keys to detect duplicates. Even though it does not print values directly, reading .env and config files gives the skill credential-adjacent inspection capability beyond performance optimization, and future changes or error paths could expose secrets.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code formats the report timestamp with the hard-coded locale 'zh-CN', and the surrounding user-facing output throughout the file is exclusively in Chinese. Under the policy, forcing a specific language or locale without user opt-in is a natural-language policy violation unless clearly justified as region-specific.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

The markdown explicitly instructs users to redirect diagnosis output into reports/diagnosis-$(date +%Y%m%d).md, which creates a persistent file on disk. Because diagnostic reports may contain details about sessions, memory, configuration, or system state, the README should disclose that this stores potentially sensitive information locally.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The cron example sets up unattended daily execution of the diagnostic skill, which implies recurring collection or inspection of agent, configuration, and system information. The documentation does not warn users that this will run automatically and may continuously generate reports or process sensitive operational data.

Content

No source excerpt is available for this finding.

Lp4

Low
Category
MCP Least Privilege
Confidence
65% confidence
Finding

Declared permissions with no matching code capability may indicate removed functionality or pre-staging for future abuse.

Content

No source excerpt is available for this finding.

Lp4

Low
Category
MCP Least Privilege
Confidence
65% confidence
Finding

Declared permissions with no matching code capability may indicate removed functionality or pre-staging for future abuse.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Low
Category
Not specified by scanner
Confidence
74% confidence
Finding

The skill's main purpose is to analyze agent state and generate optimization recommendations. While system metrics may be useful, spawning a shell command via execSync to collect disk usage is a stronger capability than necessary for a mostly file-based diagnostic tool, and the manifest does not specifically justify command execution for this function.

Content

No source excerpt is available for this finding.