Back to skill

Security audit

OpenClaw Optimize

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly coherent for OpenClaw optimization, but it asks the agent to inspect sensitive local OpenClaw data and includes operational changes that need careful review.

Install only if you want an agent to audit your local OpenClaw cron setup. Before using deep trace or log analysis, confirm which session or job should be inspected, avoid sharing raw transcripts or config values in reports, and treat cron deletion or gateway restarts as admin actions requiring explicit approval and a rollback plan.

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

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
SKILL.md:42
Finding

Overbroad Access to Sensitive OpenClaw Configuration, Session Transcripts, and Logs

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 42, 53-58, 154, 185-211, and 226
Vulnerability Type: T05: Unauthorized Access and Privilege Escalation
Risk Level: Medium

Vulnerable Code

bash
cat ~/.openclaw/openclaw.json 2>/dev/null | head -5 || echo "No OpenClaw config"
bash
cat ~/.openclaw/openclaw.json | python3 -c "
import json, sys
cfg = json.load(sys.stdin)
plugins = cfg.get('plugins', {}).get('entries', {})
for name, p in plugins.items():
    print(f'{name}: enabled={p.get(\"enabled\", \"?\")}')
"
bash
cat ~/.openclaw/agents/main/sessions/<sessionId>.jsonl
bash
cat ~/.openclaw/agents/main/sessions/<id>.jsonl | python3 -c "
import json, sys
for line in sys.stdin:
    line = line.strip()
    if not line: continue
    msg = json.loads(line)
    t = msg.get('type','?')
    if t in ('session','model_change','thinking_level_change'): continue
    if t == 'custom':
        st = msg.get('customType','?')
        print(f'  CUSTOM/{st}: {len(json.dumps(msg.get(\"data\",{}))):>6} chars')
    elif t == 'message':
        role = msg.get('message',{}).get('role','?')
        content = msg.get('message',{}).get('content','')
        if isinstance(content, list):
            for block in content:
                bt = block.get('type','?')
                if bt == 'text':
                    print(f'  {role:>12} text: {len(block.get(\"text\",\"\")):>6} chars | {block.get(\"text\",\"\")[:120]}')
                elif bt in ('tool_use','toolCall'):
                    print(f'  {role:>12} tool: {block.get(\"name\",\"?\")} | input: {len(json.dumps(block.get(\"input\",{}))):>6} chars')
                elif bt in ('tool_result','toolResult'):
                    rc = block.get('content','')
                    print(f'  {role:>12} result: {len(str(rc)):>6} chars | {str(rc)[:120]}')
"
bash
...[truncated 3196 chars]
Remediation
View remediation

Remediation Suggestions

  1. Use field-level configuration parsing. Read only plugin names and enabled states rather than displaying or loading unrelated configuration fields into Agent-visible output.

    bash
    python3 -c "
    import json
    with open('$HOME/.openclaw/openclaw.json') as f:
        cfg = json.load(f)
    for name, plugin in cfg.get('plugins', {}).get('entries', {}).items():
        print(name, bool(plugin.get('enabled', False)))
    "
    
  2. Default to metadata-only trace analysis. Calculate block types, character counts, token usage, and tool-call counts without printing transcript text, tool arguments, or tool results.

  3. Require explicit consent for deep tracing. Before opening a transcript, identify the exact session and explain that it may contain private conversation and tool data. Proceed only after the user approves that specific access.

  4. Apply automatic redaction. Remove authorization headers, API keys, bearer tokens, cookies, email addresses, and other secrets before placing data in Agent context or reports.

  5. Constrain log collection. Filter by relevant error patterns and a narrow time range instead of reading the latest 300 lines indiscriminately. Avoid displaying complete lines when a count or event category is sufficient.

  6. Separate collection from presentation. Ensure raw configuration, transcript, and log content is never copied directly into the final report. Present only aggregated statistics and sanitized excerpts.

  7. Document data boundaries. State that optimization does not require credential values or complete conversation content and instruct the Agent to stop if such information is encountered.

Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (5)

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
85% confidence
Finding

Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Content

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

md
| `thinking` | assistant | Agent reasoning. Extended thinking on simple tasks = waste. |
| `tool_use` / `toolCall` | assistant | Tool calls. Count them. Are any redundant? |
| `text` | toolResult | **Tool results — often the single biggest token cost.** Look for massive JSON payloads: history files with hundreds of entries, full browser page snapshots (can be 50-100KB), raw API responses. |
| `text` | assistant (final) | The output summary. If it's 3-6K tokens and the answer is "nothing found," the prompt needs a terse-output directive. |

### Trace summary script

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The trigger phrases are broad enough to activate on generic complaints like 'agent is slow' or 'reduce token usage,' which could invoke this skill outside the intended OpenClaw cron-audit context. Misactivation matters because the skill contains invasive local inspection and modification guidance, increasing the chance of inappropriate file reads or system-changing recommendations in unrelated contexts.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The skill recommends irreversible cron deletion and does note 'always ask before deleting,' but it lacks an upfront destructive-operations warning in the skill description or initial safety framing. In a broadly triggered optimization skill, this raises the risk that users do not appreciate deletion is permanent until deep into execution guidance.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The skill includes service restart commands that change system state and can interrupt or alter a running OpenClaw deployment. Even though framed as troubleshooting, operational commands like restarting the gateway go beyond read-only audit guidance and can cause downtime or mask underlying issues if suggested or executed without strong gating.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
94% confidence
Finding

The skill explicitly instructs use of 'sudo systemctl restart openclaw-gateway', which introduces privileged execution guidance into an optimization workflow. If followed in the wrong environment, this can restart services unexpectedly and normalize escalation to root without sufficient necessity checks, making misuse materially more dangerous.

Content

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

launchctl kickstart -k gui/$(id -u)/ai.openclaw.gateway

Or if using systemd

sudo systemctl restart openclaw-gateway

text

### Rate limit errors after optimization

Static analysis

No suspicious patterns detected.