Back to skill

Security audit

Token Pilot

Security checks for vulnerabilities and agentic risk

Overview

This token-optimization skill is mostly coherent, but it persistently changes all agents' instruction files and includes automatic cleanup modes that can move or delete local workspace files without strong safeguards.

Install only if you want a token optimizer that can persistently modify every agent's AGENTS.md. Review the init preview carefully, avoid --yes unless you have backups, and do not run optimize.js --apply on important workspaces without manually checking the files it would move or delete first.

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

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/optimize.js:43
Finding

Overbroad workspace cleanup can move or delete legitimate files

Content
View full analysis
{ const ext = path.extname(f).toLowerCase(); return junkExts.includes(ext) && fs.statSync(path.join(wsDir, f)).isFile(); }); if (junkFiles.length) { const junkSize = junkFiles.reduce((sum, f) => sum + fs.statSync(path.join(wsDir, f)).size, 0); issues.push({ type: 'junk', severity: 'high', msg: `${junkFiles.length} non-essential files in workspace root (${formatBytes(junkSize)})`, detail: junkFiles.map(f => ` ${f} (${formatBytes(fs.statSync(path.join(wsDir, f)).size)})`), fix: 'Move to scripts/ subdirectory or delete', savings: estimateTokens(junkFiles.map(f => readSafe(path.join(wsDir, f)) || '').join('')), }); if (apply) { const scriptsDir = path.join(wsDir, 'scripts'); if (!fs.existsSync(scriptsDir)) fs.mkdirSync(scriptsDir, { recursive: true }); for (const f of junkFiles) { const src = path.join(wsDir, f); const dst = path.join(scriptsDir, f); fs.renameSync(src, dst); } console.log(` ✅ Moved ${junkFiles.length} files to scripts/`); } } // 2. BOOTSTRAP.md still exists? const bootstrap = path.join(wsDir, 'BOOTSTRAP.md'); if (fs.existsSync(bootstrap)) { const size = fs.statSync(bootstrap).size; issues.push({ type: 'bootstrap', severity: 'high', msg: `BOOTSTRAP.md still exists (${formatBytes(size)}) — injected every session after setup is done`, fix: 'Delete it (bootstrap is complete)', savings: estimateTokens(readSafe(bootstrap) || ''), }); if (apply) { fs.unlinkSync(bootstrap); console.log(' ✅ Deleted BOOTSTRAP.md'); } } ``` ### Technical Analysis The `--ap ...[truncated 2016 chars]
Remediation
View remediation
` and `--delete-bootstrap` so destructive operations require specific authorization. ]]>

T05 · Unauthorized Access and Privilege Escalation

Note
Location
scripts/audit.js:62
Finding

Full diagnostics read sensitive Agent memory and configuration beyond metadata needs

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/init.sh:99
Finding

Malformed persistence markers can erase unrelated Agent instructions

Content
View full analysis
0) rules = rules line "\n" } index($0, start) { printing=1; printf "%s", rules; next } index($0, end) { printing=0; next } !printing { print } ' "$target" > "$tmp" mv "$tmp" "$target" return 1 else { cat "$target"; echo ""; echo "---"; echo ""; echo "$CORE_CONTENT"; } > "$tmp" mv "$tmp" "$target" return 0 fi } ``` Removal logic in `scripts/uninstall.sh`: ```bash if grep -qF "$START_MARKER" "$agents_md"; then tmp="$(mktemp)" awk -v start="$START_MARKER" -v end="$END_MARKER" ' $0 == start { skip=1; next } skip && $0 == end { skip=0; next } !skip { print } ' "$agents_md" > "$tmp" sed -i -e :a -e '/^\n*$/{$d;N;ba}' "$tmp" 2>/dev/null || true mv "$tmp" "$agents_md" echo "[REMOVED] $agent_name/AGENTS.md" fi ``` ### Technical Analysis Both scripts begin suppressing output after encountering the start marker and resume only when an end marker is found. Neither implementation validates that: - Exactly one start marker exists. - Exactly one corresponding end marker exists. - The end marker occurs after the start marker. - The marker block is structurally valid before replacement. If the end marker is missing, every line after the start marker is omitted from the generated temporary file. The temporary file is then moved over the original `AGENTS.md`, permanently deleting unrelated instructions. The update script uses substring matching through `index()`, while the uninstall script r ...[truncated 1533 chars]
Remediation
View remediation
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (45)

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · README.md (reported line 261)May include surrounding context.

第二步:删除技能目录(可选)

bash
rm -rf ~/.openclaw/skills/token-pilot

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · README.md (reported line 261)May include surrounding context.

第二步:删除技能目录(可选)

bash
rm -rf ~/.openclaw/skills/token-pilot

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The skill description does not reveal that it can uninstall injected blocks, edit multiple AGENTS.md files, and remove initialization flags. This is effectively stateful environment management, and the lack of accurate disclosure can cause operators to grant trust to a tool with persistent administrative reach.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The skill description does not reveal that it can uninstall injected blocks, edit multiple AGENTS.md files, and remove initialization flags. This is effectively stateful environment management, and the lack of accurate disclosure can cause operators to grant trust to a tool with persistent administrative reach.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The skill description does not reveal that it can uninstall injected blocks, edit multiple AGENTS.md files, and remove initialization flags. This is effectively stateful environment management, and the lack of accurate disclosure can cause operators to grant trust to a tool with persistent administrative reach.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The skill description does not reveal that it can uninstall injected blocks, edit multiple AGENTS.md files, and remove initialization flags. This is effectively stateful environment management, and the lack of accurate disclosure can cause operators to grant trust to a tool with persistent administrative reach.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The skill description does not reveal that it can uninstall injected blocks, edit multiple AGENTS.md files, and remove initialization flags. This is effectively stateful environment management, and the lack of accurate disclosure can cause operators to grant trust to a tool with persistent administrative reach.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

High
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill's operational instructions are presented as mandatory agent behavior in Chinese, beginning with "Agent 必读" and directing immediate execution steps. There is no indication that language choice is optional or based on user preference, which can violate language/locale policy expectations.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

These lines direct the agent to execute an initialization script that appends rules into every agent's AGENTS.md file. That is dangerous because it creates persistent, environment-wide prompt injection and behavior modification across other agents, potentially overriding local policy and enlarging the blast radius of a single skill.

Content

No source excerpt is available for this finding.

Vague Triggers

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The activation trigger includes broad phrases like starting work or asking for help, causing the skill to run checks before normal replies. Overbroad triggers are dangerous because they can unexpectedly launch filesystem inspection or setup flows during ordinary conversation, without a narrowly scoped user request.

Content

No source excerpt is available for this finding.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
- `audit.js` 现在只检查白名单文件,不再误报所有文件大小

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill advertises optimization but also documents auto-fix behavior that can move files and delete BOOTSTRAP.md. File deletion and restructuring exceed a safe audit role and can cause data loss or break bootstrap behavior, especially if users invoke optimization expecting read-only analysis.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill is described as automatic token optimization during interaction, but the documented setup includes persistent modification of all agents' AGENTS.md files and ongoing behavioral changes. This mismatch can cause users to authorize what appears to be transient optimization while actually granting broad, durable configuration changes across the environment.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The activation terms are overly broad and tied to normal conversation topics like token usage, optimization, or consumption. This can cause the skill to activate unexpectedly during unrelated discussions, increasing the chance of unplanned behavior such as prompting for initialization or influencing agent actions in contexts where the user did not intend to invoke the skill.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The on-demand loading model again relies on broad keywords without tight scope boundaries, making accidental activation likely. In a skill that can alter agent behavior and recommend or perform environment changes, ambiguous triggers materially increase operational risk.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The file table describes scripts/audit.js as "只读" at L276, but immediately documents scripts/optimize.js as supporting --apply automatic fixes at L277. Elsewhere the skill is framed primarily as token optimization and diagnosis, so calling the tooling read-only in the same documentation while also exposing an auto-modifying optimizer is an active contradiction in the documented intent of the scripts.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
83% confidence
Finding

The skill instructs the agent to use shell commands and Node scripts, but its manifest does not declare a clear tool scope or allowed-tools boundary. That creates an authorization/transparency gap: users and enforcement layers may treat it as a benign optimization skill while it in fact needs filesystem and execution capabilities.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The manifest says the skill activates on session start or when users ask about token usage/cost/audit, which is ambiguous and broad. Such wording can cause automatic invocation in contexts where users did not expect environment inspection or setup prompts.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The overview does not prominently warn that the skill includes a setup flow that can persistently modify agent instruction files. Omitting this in the headline description undermines informed consent for a behavior that changes future agent operation.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The skill instructs agents to run shell commands and Node scripts early in the interaction flow. Even if intended for setup, this grants execution behavior not obviously necessary from the high-level description and increases the chance of unintended command execution against user environments.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
76% confidence
Finding

The guidance explicitly recommends writing context to disk for later subagent use. Persisting context can expose sensitive task data beyond the active session, especially if the file is left behind, broadly readable, or reused by other agents without minimization.

Content

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

md
After completing a novel complex task → proactively suggest creating a Skill to capture the pattern.

### [coding-lead] Context File Pattern
Write context to disk → lean ACP prompt ("Read .openclaw/context.md") → significant savings vs embedding.
Prefer disk context files for large context, but **include essential info (project path, stack, key constraint) directly in spawn prompt** (~200-500 chars) so ACP agent can bootstrap even if context file is missing.

ACP model awareness: claude-code (complex) → codex (quick) → direct exec (simple <60 lines).

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
86% confidence
Finding

The documentation frames audit as read-only diagnostics, but adjacent commands in the same skill include apply behavior that modifies and deletes files. Mixing read-only and mutating operations under one umbrella can mislead users and cause accidental execution of destructive actions.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The auto-fix command is documented with deletion behavior but without an immediate warning at the point of use. Users may interpret it as harmless optimization and trigger irreversible workspace changes.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This markdown file contains prescriptive operational instructions entirely in Chinese, such as activation and behavior rules, but does not indicate that the user may choose another language or that the skill is intentionally limited to a Chinese-speaking context. Under the language/locale policy, forcing a specific language without user opt-in is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
79% confidence
Finding

This duplicate finding points to the same persistence guidance: keeping fixed content stable and moving high-frequency facts into persistent files increases the chance that stale, sensitive, or maliciously planted instructions survive beyond the current task. In an agent skill, that persistence is more dangerous because future sessions may treat retained content as trusted operating context.

Content

Scanner excerpt · references/TOKEN-PILOT-CORE.md (reported line 11)May include surrounding context.

md
无依赖的工具调用合并为一个 block 同时发出(read A + read B + read C,不分三次)。工具结果超过500字符只提取相关部分,不整体回显。

### 写文件
改动 <30% 时用 edit,不用 write 全覆盖。输出只展示变更行 ±2 行上下文,不贴完整文件。

### Prompt Cache 保护
SOUL.md / AGENTS.md 内容保持稳定,不加时间戳、session id 等每次变化的字段。动态内容(工具结果、memory_search 注入)放后面,不穿插进固定内容中。高频固定事实写进 SOUL.md 或 MEMORY.md 顶部,不靠每次语义搜索命中。

Static analysis

Detected: suspicious.destructive_delete_command

Documentation contains a destructive delete command without an explicit confirmation gate.

Warn
Code
suspicious.destructive_delete_command
Location
README.md:261