Back to skill

Security audit

Api Cost Optimizer

Security checks for vulnerabilities and agentic risk

Overview

This skill is mostly a disclosed local cost-estimation helper, but its shell scripts handle user-controlled inputs unsafely enough that installation should be reviewed carefully.

Review or patch the scripts before relying on this skill. It should be safe enough for a trusted local operator using normal numeric inputs, but do not expose it to untrusted parameters or hostile environment/path values, and treat its reports as estimates rather than actual billing analysis.

Vulnerability Patterns
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (2)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/estimate.sh:17
Finding

Expression and Command Injection Through Unvalidated bc Input

Content
View full analysis
Remediation
View remediation
&2 exit 1 ;; esac if [ "$value" -eq 0 ]; then printf 'Error: %s must be greater than zero\n' "$name" >&2 exit 1 fi } require_positive_integer "heartbeat interval" "$HB_INTERVAL" require_positive_integer "tasks per day" "$TASKS_PER_DAY" require_positive_integer "average input tokens" "$AVG_INPUT" require_positive_integer "average output tokens" "$AVG_OUTPUT" ``` 2. Apply explicit upper bounds to prevent overflow and resource-exhaustion input. For example, limit heartbeat values to a reasonable number of seconds, tasks to an operational maximum, and token counts to supported model context limits. 3. Reject whitespace, signs, decimal notation, newlines, statement separators, and calculator-language syntax unless a field explicitly requires decimals. 4. Prefer validated shell integer arithmetic for integer-only operations: ```bash API_CALLS_PER_DAY=$((86400 / HB_INTERVAL)) ``` 5. Where decimal calculations require `bc`, construct a fixed program and substitute only values that have already passed strict validation. Do not pass raw arguments or environment values into calculator source. 6. Add negative tests covering zero, negative values, newlines, very large values, operators, semicolons, parentheses, and implementation-specific `bc` commands. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/heartbeat_diagnosis.sh:17
Finding

Python Source Injection Through Unescaped Configuration Paths

Content
View full analysis
/dev/null || echo "auto") fi fi ``` A second occurrence in the same file uses the same unsafe construction: ```bash if [ -f "$CONFIG_FILE" ]; then CONFIG_TOOLS=$(python3 -c " import json, sys try: with open('$CONFIG_FILE', 'r') as f: cfg = json.load(f) tools = cfg.get('tools', cfg.get('skills', cfg.get('plugins', []))) if isinstance(tools, list): print(len(tools)) else: print(0) except: print(0) " 2>/dev/null || echo "0") fi ``` From `scripts/heartbeat_diagnosis.sh`: ```bash CONFIG_FILE="${HOME}/.openclaw/openclaw.json" if [ -f "$CONFIG_FILE" ]; then INTERVAL=$(python3 -c " import json, sys, re try: with open('$CONFIG_FILE', 'r') as f: cfg = json.load(f) hb = cfg.get('agents', {}).get('defaults', {}).get('heartbeat', {}) result = 'auto' if i ...[truncated 3664 chars]
Remediation
View remediation
Vulnerability Patterns
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • 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 (9)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The code is broadly aligned with the general cost-analysis theme in the description: it inspects heartbeat configuration, estimates daily/weekly/monthly/yearly spend, and emits recommendations. However, the description materially overstates the capability by claiming analysis of 'API usage patterns' and diagnosis of cost issues in a way that suggests real usage-based analysis. In reality, the script performs heuristic estimation using fixed assumptions such as 20 tasks/day, 6000 input tokens, and 1500 output tokens, plus simple local file/config counting. It does not read logs, usage telemetry, API records, or billing data. Additionally, the script has an apparent defect where TOOL_OVERHEAD_DAY references TOOL_CALLS_DAY, which is undefined, reinforcing that the implementation is not a full analysis of tool overhead as advertised. So this is a partial but meaningful description-behavior mismatch.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
89% confidence
Finding

The code is aligned with part of the description: it diagnoses heartbeat configuration inefficiency, reads OpenClaw config, estimates recurring costs, and gives recommendations. However, the declared purpose is materially broader than the actual implementation. There is no analysis of real API usage patterns, logs, request volumes, model selection, or overall agent spend beyond heartbeat traffic. The script uses static token estimates and simple provider price tables rather than analyzing actual usage. So the description overstates the implemented capability, making this a mismatch.

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 59)May include surrounding context.

md
./scripts/analyze.sh

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
./scripts/analyze.sh

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
./scripts/heartbeat_diagnosis.sh

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
./scripts/heartbeat_diagnosis.sh

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
./scripts/estimate.sh <heartbeat_seconds> <tasks_per_day> <avg_input_tokens> <avg_output_tokens>

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
./scripts/estimate.sh <heartbeat_seconds> <tasks_per_day> <avg_input_tokens> <avg_output_tokens>

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
70% confidence
Finding

Without declared permissions the skill's intent is opaque and cannot be validated.

Content

No source excerpt is available for this finding.