Back to skill

Security audit

Token Tamer — AI API Cost Control

Security checks for vulnerabilities and agentic risk

Overview

This cost-control skill is purpose-aligned, but it needs Review because its budget controls can under-report spending and its local logs may expose usage details.

Review this carefully before relying on it as a hard spending limit. It may be useful for local cost visibility, but keep provider-side budgets or billing alerts enabled, protect the JSON usage file, avoid storing secrets or customer data in task/session/metadata fields, and treat its kill switch as advisory unless the accounting flaws are fixed.

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

T09 · Insecure Skill Coding Practices

Error
Location
token_tamer.py:83
Finding

Negative Token Counts Can Reduce Recorded Spending and Bypass Budget Enforcement

Content
View full analysis
float: """Calculate cost for a usage event.""" # Look up pricing key = f"{provider}/{model}" if key not in self.pricing: # Try provider wildcard key = f"{provider}/*" if key not in self.pricing: # Unknown model, return 0 and warn print(f"Warning: No pricing data for {provider}/{model}", file=sys.stderr) return 0.0 pricing = self.pricing[key] # Calculate cost (pricing is per million tokens) input_cost = (input_tokens / 1_000_000) * pricing['input'] output_cost = (output_tokens / 1_000_000) * pricing['output'] return input_cost + output_cost ``` ```python def log_usage(self, provider: str, model: str, input_tokens: int, output_tokens: int, task: Optional[str] = None, session: Optional[str] = None, metadata: Optional[Dict] = None) -> Tuple[float, str]: """Log API usage and return cost + status.""" # Calculate cost cost = self.calculator.calculate_cost(provider, model, input_tokens, output_tokens) # Create record record = UsageRecord(provider, model, input_tokens, output_tokens, cost, task, session, metadata) # Check budget before logging daily_cost = self.get_daily_cost() status, message = self.budget_tracker.check_budget('daily', daily_cost + cost) ``` ```python parser.add_argument('--input-tokens', type=int, help='Input tokens') parser.add_argument('--output-tokens', type=int, help='Output tokens') ``` ### Technical Analysis The CLI and public `log_usage()` API accept arbitrary integers without checking that token counts are non-negative. `calculate_cost()` directly multiplies thes ...[truncated 1611 chars]
Remediation
View remediation
None: if isinstance(value, bool) or not isinstance(value, int) or value < 0: raise ValueError(f"{name} must be a non-negative integer") validate_token_count("input_tokens", input_tokens) validate_token_count("output_tokens", output_tokens) ``` ]]>

T09 · Insecure Skill Coding Practices

Error
Location
token_tamer.py:146
Finding

Usage Ledger Failures Are Silently Treated as Successful Accounting

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
token_tamer.py:218
Finding

Threshold-Crossing Usage Is Not Recorded and Only the Daily Budget Is Enforced

Content
View full analysis
Tuple[float, str]: """Log API usage and return cost + status.""" # Calculate cost cost = self.calculator.calculate_cost(provider, model, input_tokens, output_tokens) # Create record record = UsageRecord(provider, model, input_tokens, output_tokens, cost, task, session, metadata) # Check budget before logging daily_cost = self.get_daily_cost() status, message = self.budget_tracker.check_budget('daily', daily_cost + cost) # Check kill switch if self.budget_tracker.should_kill('daily', daily_cost + cost): self.kill_switch_active = True print(f"🚨 KILL SWITCH ACTIVATED: {message}", file=sys.stderr) return cost, 'KILL' # Log the record self.storage.add_record(record) ``` ```python def check_before_call(self, estimated_cost: float = 0.10) -> bool: """Check if API call should proceed (return True = OK, False = blocked).""" if self.kill_switch_active: print("🚨 KILL SWITCH ACTIVE: API calls blocked", file=sys.stderr) return False daily = self.get_daily_cost() if self.budget_tracker.should_kill('daily', daily + estimated_cost): self.kill_switch_active = True print("🚨 KILL SWITCH ACTIVATED: Budget exceeded", file=sys.stderr) return False return True ``` ### Technical Analysis `log_usage()` is documented as being called after an API request. At that point the provider charge has already occurred. However, when that completed request takes the daily total to or above 100%, the function returns `KILL` b ...[truncated 1851 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • 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 (7)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The supplied code focuses narrowly on report generation from previously stored usage data. It aggregates call counts, token counts, and costs across time periods and categories and outputs summaries. While this supports the 'monitor' aspect of the description, it does not implement budget enforcement, waste detection, or optimization recommendation logic. It also does not itself track API calls; it relies on an external UsageStore. Therefore, the declared description overstates the capabilities of this specific code chunk, making it a mismatch.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
85% confidence
Finding

The skill documents Python code that reads configuration, writes usage data, and may interact with external provider contexts, but it does not declare any tool scope such as allowed-tools or permissions. In an agent ecosystem, undeclared file and network capabilities reduce reviewability and can let a seemingly simple budgeting skill access local files or make outbound requests without explicit operator approval.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The code persistently writes usage records to a local JSON file, including task, session, and arbitrary metadata, without any minimization, consent, redaction, or protection. In a cost-tracking skill, those fields can easily contain prompts, identifiers, customer data, API-related context, or other sensitive operational information, creating a privacy and data exposure risk if the file is read by other users, backed up, or exfiltrated.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
76% confidence
Finding

The natural-language policy check applies to all file types and includes locale-related constraints. Lines L073-L081 explicitly state 'Token Tamer assumes USD' and 'USD only' with no opt-in or documented regional justification, which can be interpreted as forcing a locale-specific convention.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

The README explicitly advertises persistent JSON-based storage of API usage data but does not warn that the stored metadata may include sensitive operational details such as model usage, task names, session identifiers, and spending patterns. In a cost-tracking skill, this omission can lead users to retain potentially sensitive telemetry on disk without considering access controls, retention limits, or sanitization.

Content

No source excerpt is available for this finding.

Scope Creep

Low
Category
Excessive Agency
Confidence
70% confidence
Finding

Skill's behavior or capabilities extend beyond its stated purpose. Scope creep allows an agent to perform actions unrelated to its documented functionality, increasing the attack surface.

Content

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

md
**USE AT YOUR OWN RISK.**

- The author(s) are NOT liable for any damages, losses, or consequences arising from 
  the use or misuse of this software — including but not limited to financial loss, 
  data loss, security breaches, business interruption, or any indirect/consequential damages.
- This software does NOT constitute financial, legal, trading, or professional advice.
- Users are solely responsible for evaluating whether this software is suitable for

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
81% confidence
Finding

This code prints detailed usage analytics, including task names and provider/model breakdowns, directly to stdout in text or JSON form. While reporting is the skill's purpose, there is no disclosure in this file that the generated output may contain sensitive operational metadata, which matters because the tool supports machine-readable JSON export and broad date-range reporting.

Content

No source excerpt is available for this finding.