Back to skill

Security audit

Agent Budget Controller

Security checks for vulnerabilities and agentic risk

Overview

This appears to be a local budget-tracking tool, but its blocking and protection claims are stronger than the implementation reliably supports.

Install only if you treat this as a local reporting helper, not a hard spending cap. To use it as an enforcement gate, wrap every paid call with `budget check`, protect the budget data directory from untrusted writers, and fix numeric validation so negative, zero, NaN, or infinite values cannot affect limits, prices, or usage logs.

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
scripts/budget.py:261
Finding
Unvalidated Numeric Inputs Permit Budget Enforcement Bypass<![CDATA[ ## Vulnerability Details **File Location**: - `scripts/budget.py:43-63` - `scripts/budget.py:78-81` - `scripts/budget.py:261-276` - `scripts/budget.py:299-304` - `lib/pricing.py:47-67` - `lib/tracker.py:17-33` - `lib/alerts.py:27-45` **Vulnerability Type**: Improper numeric input validation and business-logic bypass **Risk Level**: Medium ### Vulnerable Code ```python # scripts/budget.py:43-63 if args.daily is not None: config.set_global_limit("daily", args.daily) print(f"✅ Set global daily limit: ${args.daily:.2f}") if args.weekly is not None: config.set_global_limit("weekly", args.weekly) print(f"✅ Set global weekly limit: ${args.weekly:.2f}") if args.monthly is not None: config.set_global_limit("monthly", args.monthly) print(f"✅ Set global monthly limit: ${args.monthly:.2f}") ``` ```python # scripts/budget.py:78-81 cost = pricing.get_cost(args.model, args.input_tokens, args.output_tokens) # Log usage tracker.log_usage( args.agent, args.model, args.input_tokens, args.output_tokens, cost ) ``` ```python # scripts/budget.py:261-276 set_parser.add_argument('--daily', type=float, help='Daily limit (USD)') set_parser.add_argument('--weekly', type=float, help='Weekly limit (USD)') set_parser.add_argument('--monthly', type=float, help='Monthly limit (USD)') log_parser.add_argument('--agent', required=True, help='Agent name') log_parser.add_argument('--model', required=True, help='Model name') log_parser.add_argument( '--input-tokens', type=int, required=True, help='Input tokens' ) log_parser.add_argument( '--output-tokens', type=int, required=True, help='Output tokens' ) ``` ```python # scripts/budget.py:299-304 pricing_parser.add_argument('--update', action='store_true', help='Update model pricing') pricing_parser.add_argument('--model', help='Model name') pricing_parser.add_argument('--input-price', type=float, help='I ...[truncated 4440 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Require all budget limits and model prices to be finite and strictly greater than zero: ```python import math def validate_positive_finite(value: float, field: str) -> float: if not math.isfinite(value) or value <= 0: raise ValueError(f"{field} must be finite and greater than zero") return value ``` 2. Require token counts to be non-negative integers: ```python def validate_token_count(value: int, field: str) -> int: if isinstance(value, bool) or not isinstance(value, int) or value < 0: raise ValueError(f"{field} must be a non-negative integer") return value ``` 3. Apply validation inside `BudgetConfig.set_global_limit()`, `BudgetConfig.set_agent_limit()`, `PricingTable.update_model()`, `PricingTable.get_cost()`, and `UsageTracker.log_usage()`. Library-level validation is necessary because these classes may be called without the CLI. 4. Verify that every calculated and supplied cost is finite and non-negative before persisting it. 5. Treat malformed or non-finite values in existing configuration and ledger records as errors rather than silently using them in calculations. Consider failing closed for budget checks when accounting data cannot be validated. 6. Serialize standards-compliant JSON by using `json.dump(..., allow_nan=False)` and `json.dumps(..., allow_nan=False)`. 7. Add regression tests covering negative token counts, negative limits and prices, zero or non-finite limits, `NaN`, positive and negative infinity, malformed ledger records, and direct library invocation. ]]>
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • 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
Findings (9)

External Model or Provider Selection

High
Category
Excessive Agency
Content
✅ Initialized budget tracking at /Users/you/.openclaw/budget
Next steps:
  1. Set limits: budget set --daily 3.00 --weekly 15.00 --monthly 50.00
  2. Log usage: budget log --agent my-agent --model gpt-4o --input-tokens 1000 --output-tokens 500
  3. Check status: budget status

# Set global limits
Confidence
90% confidence
Finding
Skill selects an external model or provider that may use a different account or billing plan than the operator expects. Undisclosed model switches can cause unexpected cost or quota consumption.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding
The skill presents itself as a preventive control that can block calls at 100% usage, yet the examples indicate this behavior depends on external wrapper integration and manual invocation rather than intrinsic enforcement. In context, a budget-control skill is more dangerous when overstated because users may trust it as a financial guardrail and discover too late that it only supports retrospective checks.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The skill presents itself as a preventive control that can block calls at 100% usage, yet the examples indicate this behavior depends on external wrapper integration and manual invocation rather than intrinsic enforcement. In context, a budget-control skill is more dangerous when overstated because users may trust it as a financial guardrail and discover too late that it only supports retrospective checks.

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding
The skill presents itself as a preventive control that can block calls at 100% usage, yet the examples indicate this behavior depends on external wrapper integration and manual invocation rather than intrinsic enforcement. In context, a budget-control skill is more dangerous when overstated because users may trust it as a financial guardrail and discover too late that it only supports retrospective checks.

Session Persistence

Medium
Category
Rogue Agent
Content
PATH: "${PATH}:${HOME}/ubik-collective/systems/ubik-pm/skills/agent-budget-controller/scripts"
```

Or create a wrapper script in OpenClaw's bin directory:
```bash
mkdir -p ~/.openclaw/bin
cat > ~/.openclaw/bin/budget <<'EOF'
Confidence
60% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Unrestricted Tool Access

Medium
Category
Excessive Agency
Content
## The Problem

- 🔥 Agent loops → $100/hour API bills
- 🎯 Malicious skills → unlimited API calls
- 🤷 No visibility → surprise invoices
- 😱 Manual tracking → error-prone
Confidence
85% confidence
Finding
Skill grants unrestricted tool access without appropriate constraints. An agent with unfettered tool access can perform arbitrary actions including file modification, network requests, and code execution.

Unbounded Resource Access

Medium
Category
Excessive Agency
Content
## The Problem

- 🔥 Agent loops → $100/hour API bills
- 🎯 Malicious skills → unlimited API calls
- 🤷 No visibility → surprise invoices
- 😱 Manual tracking → error-prone
Confidence
80% confidence
Finding
Skill allows unbounded resource consumption (API calls, storage, compute). Without rate limits or quotas, a compromised or misbehaving agent can cause denial-of-service or cost overruns.

Lp3

Medium
Category
MCP Least Privilege
Confidence
78% confidence
Finding
The skill advertises local persistence under ~/.openclaw/budget/ and therefore has file read/write capability, but it does not declare any explicit tool scope such as permissions or allowed-tools. Undeclared file access weakens reviewability and least-privilege controls, making it easier for an agent to gain broader filesystem access than operators expect.

Missing User Warnings

Low
Confidence
95% confidence
Finding
The troubleshooting guidance tells users to delete `~/.openclaw/budget/usage.jsonl` to reset counters, but it does not clearly warn that this permanently erases historical usage/audit data. In a budgeting and monitoring tool, loss of usage history can impair oversight, hide overspend patterns, and weaken forensic review after misuse.

Static analysis

No suspicious patterns detected.