Back to skill

Security audit

budget-analyzer-claw

Security checks for vulnerabilities and agentic risk

Overview

This budget-analysis skill is mostly coherent, but it tells the agent to inspect broad session history for cost estimates, which can expose unrelated conversation content.

Install only if you are comfortable with the agent using session metadata for budget analysis, and avoid letting it read full session histories unless you explicitly approve a limited set of sessions and time range. Treat generated costs as estimates and keep reports out of public channels.

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

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
SKILL.md:109
Finding

Overbroad Access to Session History for Cost Estimation

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 109-111
Vulnerability Type: Excessive access to sensitive session data
Risk Level: Medium

Relevant workflow, rendered in English:

text
If historical data is required:
1. Query `sessions_list` to obtain the recent session list.
2. Invoke `sessions_history` for every session to estimate usage.

Technical Analysis

The documented workflow instructs the Agent to enumerate recent sessions and invoke sessions_history for each one. Session history can contain prompts, responses, operational instructions, customer information, and other sensitive conversation content. Cost analysis ordinarily requires only model identifiers, token counts, and billing metadata.

Accessing complete histories for every session therefore violates least-privilege and data-minimization principles when equivalent usage metadata is available through session_status, sessions_list, provider billing information, or a dedicated usage interface. The Python scripts do not directly perform this access; the exposure originates from the instructions that govern Agent tool usage.

Attack Path

  1. A user requests historical cost analysis.
  2. The Agent loads and follows the workflow in SKILL.md.
  3. The Agent invokes sessions_list to enumerate recent sessions.
  4. The Agent invokes sessions_history for each enumerated session.
  5. Conversation content unrelated to billing becomes available in the Agent's active context.
  6. That content may subsequently be summarized, logged, included in a report, or exposed through an erroneous response.

Exploitation is limited by the permissions of the session tools. The workflow does not independently bypass access controls, but it encourages use of all history that the Agent is already authorized to retrieve rather than requesting only the minimum billing metadata.

Impact Assessment

The Agent may obtain read access to conf ...[truncated 370 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove the instruction to retrieve complete session histories for routine cost analysis.
  2. Use session_status, session-list usage metadata, provider billing exports, or a dedicated usage API that returns only model, token, cost, agent, and timestamp fields.
  3. If history access is unavoidable, require explicit user authorization before retrieval.
  4. Restrict retrieval to user-selected sessions and the smallest necessary time range.
  5. Extract only usage metadata and prevent message bodies from entering reports, logs, or temporary files.
  6. Add an explicit prohibition against collecting prompts and responses for billing calculations.
  7. Apply access controls so that an Agent can inspect only sessions belonging to the requesting user or authorized billing scope.

T09 · Insecure Skill Coding Practices

Note
Location
SKILL.md:49
Finding

Predictable Shared Temporary File Used for Sensitive Usage Data

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 49-53
Vulnerability Type: Unsafe temporary-file handling
Risk Level: Low

bash
python3 ~/.openclaw/skills/budget-analyzer-claw/scripts/calculate-cost.py \
  --file /tmp/usage.json --budget 500

Technical Analysis

The documented workflow instructs the Agent to store structured usage records at the fixed path /tmp/usage.json. Those records include agent names, model identifiers, and token consumption. A predictable filename in a shared temporary directory can be exposed to other local users or processes.

Depending on operating-system permissions and how the preceding write operation is implemented, another local process could monitor the file, pre-create it, replace its contents, or use a symbolic link. The calculator subsequently opens the supplied path without checking ownership, permissions, file type, or whether it is a symbolic link. The documentation also does not require secure creation or immediate deletion.

The vulnerable write operation itself is not implemented in the reviewed scripts, so symbolic-link overwrite consequences depend on the Agent or shell mechanism used to create the file. Reading attacker-modified JSON through calculate-cost.py can nevertheless produce false cost and budget reports.

Attack Path

  1. A local attacker predicts that the workflow will use /tmp/usage.json.
  2. The attacker monitors or pre-creates that path before the cost-analysis workflow runs.
  3. The Agent writes sensitive usage data to the predictable location, allowing the attacker to read it if permissions are weak; alternatively, the attacker replaces the contents before calculation.
  4. calculate-cost.py opens /tmp/usage.json and processes the data without validating the file's ownership or provenance.
  5. The attacker obtains usage metadata or causes manipulated costs, agent totals, and budget status to appear in the generated report.

...[truncated 497 chars]

Remediation
View remediation

Remediation Suggestions

  1. Prefer piping the JSON records to calculate-cost.py through standard input so no temporary file is required.
  2. If a file is necessary, create it with a secure temporary-file API that generates an unpredictable filename and atomically applies owner-only permissions.
  3. Place temporary data in a private runtime directory owned by the executing user rather than at a fixed shared path.
  4. Reject symbolic links and verify that the input is a regular file owned by the expected user before reading it.
  5. Open files with platform protections equivalent to exclusive creation and no symbolic-link following where available.
  6. Delete the file in a guaranteed cleanup block immediately after calculation.
  7. Avoid storing prompts, responses, credentials, or other session content in the usage record.
Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • 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
Findings (8)

Tp4

High
Category
MCP Tool Poisoning
Confidence
91% confidence
Finding

声明描述的是一个较完整的预算监控与预警系统,但实际代码只完成了基础的成本汇总与按 agent 分项展示。它没有时间维度处理,因此不能回答今日/本周/本月;没有持续监控、调度、状态存储或异常检测逻辑,因此不支持实时监控、主动预警、阈值管理或激增检测;也没有趋势分析、优化建议、周期报告生成等功能。虽然“计算花了多少钱”和“哪个 agent 最费钱”这部分与声明部分重合,但整体能力范围明显小于所宣称的主要用途,因此属于描述与行为不匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

声明描述的是一个较完整的财务/预算分析与控制技能,而实际代码只是一个离线的异常检测小工具。两者有部分重叠:代码确实涉及“成本异常激增预警”这一子能力,符合声明中的第(5)点的一部分。但该代码不是实时监控器,不会主动检测,也不连接账单/API/员工级成本数据,因此无法支持大部分已声明的核心用途。代码也没有表现出额外未声明的敏感能力;问题主要在于声明明显宽于实际实现,且主用途从“全面预算分析守门员”缩减为“单点成本异常检测脚本”。

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

L011 描述技能会在检测到异常时主动预警,但这里没有说明由谁检测、基于哪些具体信号触发,也未给出不触发的边界条件。对于清单式技能调用说明而言,这种激活条件过于模糊,可能导致主动触发范围不清。

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

L012 将“预算”“成本”“花了多少”“省钱”“预警”等常见表达都列为触发条件,其中多项可出现在大量普通对话中,且未说明必须限定在 OpenClaw 资源支出或账单分析语境下。这种宽泛触发描述容易与日常交流重叠,增加意外调用该技能的风险。

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
84% confidence
Finding

This markdown file presents all user-facing guidance exclusively in Chinese, and there is no indication that the skill is region-specific or that users can opt into this locale. Under the policy, forcing a specific language without user choice is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The _note value is written entirely in Chinese while the rest of the file uses English keys and values, creating an implicit language constraint for users reading or maintaining this configuration. The file does not offer a language choice or explain a region-specific reason for requiring Chinese, which fits the language/locale policy violation criteria.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

The file’s natural-language comments are written exclusively in Chinese, including operational descriptions such as budget limits, alert thresholds, and whitelist behavior. Under the policy, forcing a specific language without user opt-in or clear region-specific justification is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

This code file contains its docstring, CLI help text, and output messages entirely in Chinese, which imposes a specific language on all users. Under the policy, language constraints should either offer user opt-in/choice or be clearly justified as region-specific, which is not present here.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.