Back to skill

Security audit

usage-costs

Security checks for vulnerabilities and agentic risk

Overview

This cost-reporting skill mostly matches its stated purpose, but it needs review because it executes a local configuration file and can persist usage history without clear safeguards.

Review before installing. This skill is not clearly malicious, but it should only be used where the external .context file is trusted and protected from modification. Users should also know that the skill may write cost aggregates to token-history.jsonl and should prefer explicit confirmation or a read-only default for normal reports.

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

T09 · Insecure Skill Coding Practices

Warning
Location
SKILL.md:11
Finding

Arbitrary Shell Command Execution Through Sourced Configuration File

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 11–14
Vulnerability Type: Executable configuration file / unsafe shell sourcing
Risk Level: Medium

Vulnerable Code

bash
CONTEXT_FILE="/opt/ocana/openclaw/workspace/skills/usage-costs/.context"
[ -f "$CONTEXT_FILE" ] && source "$CONTEXT_FILE"
# Provides: $OWNER_PHONE, $PRICING_INPUT, $PRICING_OUTPUT, $PRICING_CACHE_READ

Technical Analysis

The skill instructs the agent to load configuration by passing .context to the shell built-in source. Unlike a data-only configuration parser, source interprets every statement in the file as shell code in the current process. The file is outside the audited project artifact, and its contents, ownership, permissions, and integrity are not validated before execution.

Consequently, any party that can modify /opt/ocana/openclaw/workspace/skills/usage-costs/.context can place arbitrary shell commands in it. Those commands would execute when the skill performs its local-context initialization, with the same operating-system identity and privileges as the invoking OpenClaw process.

The file is also expected to expose OWNER_PHONE, although that personal value is not required by the documented cost-reporting workflow. Loading unnecessary sensitive data increases its accidental disclosure surface.

Attack Path

  1. An attacker obtains write access to the external .context file or its parent directory through a compromised account, another vulnerable component, or insecure filesystem permissions.
  2. The attacker inserts shell commands into the file, for example:
    bash
    PRICING_INPUT=3
    arbitrary_attacker_command
    
  3. A user invokes the usage-cost skill.
  4. The agent follows the initialization instructions and executes:
    bash
    source "$CONTEXT_FILE"
    
  5. The attacker's command runs in the agent's shell context without content validation or an allowlist.
  6. The command can access resources available to ...[truncated 1113 chars]
Remediation
View remediation

Remediation Suggestions

  1. Do not execute configuration files with source, ., eval, or equivalent shell mechanisms.
  2. Store configuration in a data-only format such as JSON and parse only explicitly permitted fields.
  3. Allowlist the required pricing keys:
    • PRICING_INPUT
    • PRICING_OUTPUT
    • PRICING_CACHE_READ
  4. Validate each pricing value as a finite, non-negative numeric value before use.
  5. Remove OWNER_PHONE from this skill's context because it is not needed for cost calculation.
  6. Place the configuration in a directory that is not writable by untrusted users or unrelated services.
  7. Require restrictive ownership and permissions, and reject the file if they are unsafe.
  8. If shell-compatible configuration is unavoidable, parse simple KEY=VALUE records as text without executing them; reject substitutions, command delimiters, functions, redirections, and unknown keys.
  9. Consider pinning and verifying the configuration file's expected path, owner, and integrity before parsing it.

A safer implementation should resemble:

python
import json
import math
import os
import stat

path = "/opt/ocana/openclaw/workspace/skills/usage-costs/context.json"
allowed = {"PRICING_INPUT", "PRICING_OUTPUT", "PRICING_CACHE_READ"}

info = os.stat(path, follow_symlinks=False)
if not stat.S_ISREG(info.st_mode):
    raise ValueError("Context path must be a regular file")
if info.st_mode & (stat.S_IWGRP | stat.S_IWOTH):
    raise PermissionError("Context file has unsafe write permissions")

with open(path, encoding="utf-8") as fh:
    raw = json.load(fh)

if set(raw) - allowed:
    raise ValueError("Unknown context fields")

pricing = {}
for key in allowed:
    value = float(raw[key])
    if not math.isfinite(value) or value < 0:
        raise ValueError(f"Invalid value for {key}")
    pricing[key] = value
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 (3)

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill is presented as a reporting/read-only utility, but it also instructs appending data to a persistent token-history file. That creates an unexpected state-changing side effect, which can overwrite the user's expectations of a passive query skill and may pollute billing/audit data if invoked repeatedly or automatically.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill persists daily usage data to disk without any user-facing notice, despite being described as a reporting tool. Silent persistence can surprise users, create unintended retention of operational metadata, and cause cumulative integrity issues in the history file.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

Broad trigger phrases such as 'show me costs' and 'usage report' increase the chance that this skill is invoked for loosely related requests. Because the skill can read sensitive operational usage data and includes a write path elsewhere in the document, overbroad activation expands unintended access and side effects.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.