Back to skill

Security audit

TokenBooks Cross-Provider AI Spend Dashboard

Security checks for vulnerabilities and agentic risk

Overview

This is a coherent local AI spending dashboard, but unsafe HTML report generation means a malicious or tampered billing file could run browser code when the report is opened.

Install only if you are comfortable reviewing and controlling the billing files used as input. Do not generate or open dashboards from billing exports you did not create or trust until the HTML escaping issue is fixed, and treat exported JSON and generated dashboards as sensitive financial and operational records.

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

Error
Location
token_report.py:251
Finding
Stored HTML and Script Injection in Generated Dashboard<![CDATA[ ## Vulnerability Details **File Location**: `token_report.py:251-254`, `token_report.py:289-292`, `token_report.py:319`, and `token_report.py:344-347` **Vulnerability Type**: Stored HTML injection / cross-site scripting in a generated local report **Risk Level**: High ### Vulnerable Code Provider names are inserted directly into HTML: ```python bars_html += f""" <div class="bar-item"> <div class="bar-label"> <span><strong>{provider}</strong></span> <span>${breakdown.total_cost:.2f} ({percentage:.1f}%)</span> </div> <div class="bar-bg"> <div class="bar-fill" style="width: {percentage}%"></div> </div> </div> """ ``` Model names are also inserted directly: ```python bars_html += f""" <div class="bar-item"> <div class="bar-label"> <span><strong>{model}</strong></span> <span>${breakdown.total_cost:.2f} ({breakdown.request_count} requests)</span> </div> <div class="bar-bg"> <div class="bar-fill" style="width: {percentage}%"></div> </div> </div> """ ``` Dates derived from imported timestamps are placed inside an HTML attribute: ```python bars_html += f'<div class="line-bar" style="height: {height_percent}%" title="{point.date}: ${point.cost:.2f}"></div>' ``` Waste alerts embed the unescaped model name: ```python alerts_html += f""" <div class="waste-alert"> <strong>⚠️ {case['model']}</strong><br> Cost: ${case['total_cost']:.2f} across {case['request_count']} requests<br> <em>{case['suggestion']}</em> </div> """ ``` The affected values originate from imported, potentially attacker-controlled CSV or JSON records. Relevant source assignments include: ```python timestamp = row.get('Timestamp') or row.get('timestamp') or row.get('Date') model = row.get('Model') or row.get('model') ``` and: ```python timestamp = item.get('timestamp') or item.get('created_at') model = item.get('model') ``` No HTML escaping or contextual output encoding is applied before these ...[truncated 2968 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Import Python's standard HTML-escaping function: ```python from html import escape ``` 2. Escape every untrusted string at the final output boundary. Use quote escaping for values that may appear in attributes: ```python safe_provider = escape(str(provider), quote=True) safe_model = escape(str(model), quote=True) safe_date = escape(str(point.date), quote=True) safe_suggestion = escape(str(case['suggestion']), quote=True) ``` 3. Use only escaped variables in HTML: ```python <span><strong>{safe_provider}</strong></span> ``` ```python <span><strong>{safe_model}</strong></span> ``` ```python bars_html += ( f'<div class="line-bar" ' f'style="height: {height_percent:.2f}%" ' f'title="{safe_date}: ${point.cost:.2f}"></div>' ) ``` 4. Validate imported records before report generation: - Require provider and model fields to be strings. - Set reasonable maximum lengths. - Reject control characters. - Parse timestamps into a strict accepted format and regenerate their display representation from the parsed date. - Reject non-finite or negative numeric values where they are not meaningful. 5. Prefer a template engine with automatic HTML escaping if external dependencies become acceptable. Keep auto-escaping enabled and avoid marking imported content as safe. 6. Add a restrictive Content Security Policy to provide defense in depth. For example: ```html <meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src 'none'; script-src 'none'; connect-src 'none'; base-uri 'none'; form-action 'none'"> ``` Output encoding remains necessary because a policy does not prevent all HTML-based report spoofing. 7. Add regression tests using payloads in every imported text field, including: - `<script>alert(1)</script>` - `<img src=x onerror=alert(1)>` - `" onmouseover="aler ...[truncated 218 chars]
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (11)

Hidden Instructions

High
Category
Prompt Injection
Content
---
name: "TokenBooks Cross-Provider AI Spend Dashboard"
description: "See where your AI money goes. Track spending across OpenAI, Anthropic, Google, and more. Per-provider breakdowns, per-model costs, budget tracking, waste detection."
author: "@TheShadowRose"
Confidence
60% confidence
Finding
Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Hidden Instructions

High
Category
Prompt Injection
Content
---
name: "TokenBooks Cross-Provider AI Spend Dashboard"
description: "See where your AI money goes. Track spending across OpenAI, Anthropic, Google, and more. Per-provider breakdowns, per-model costs, budget tracking, waste detection."
author: "@TheShadowRose"
Confidence
60% confidence
Finding
Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Natural-Language Policy Violations

Medium
Confidence
86% confidence
Finding
The text states that all costs are assumed to be in USD and instructs users to convert their data beforehand. This imposes a specific currency/locale convention on all users without offering a choice or clearly justifying the restriction as a region-specific tool.

Missing User Warnings

Medium
Confidence
84% confidence
Finding
This code writes detailed provider usage records, including timestamps, models, task labels, token counts, and costs, to an output file. Although the operation is implemented and later acknowledged with a success message, there is no prior disclosure or caution that the export may persist sensitive billing or usage metadata to disk.

Missing User Warnings

Low
Confidence
87% confidence
Finding
This markdown file documents handling billing exports from OpenAI, Anthropic, Google Cloud, and custom sources, which can contain potentially sensitive operational or financial metadata. While the README states that processing is local, it does not give a user-facing warning to review, protect, or sanitize imported/exported data files before sharing or storing generated outputs.

Intent-Code Divergence

Low
Confidence
51% confidence
Finding
The FAQ says the tool 'analyzes exported billing data, not live API usage,' which sets an expectation that inputs are local exports only. Later, the Python API example uses `manager.import_openai('openai.csv')`; while this may still read a local CSV, the naming creates mild intent ambiguity against the earlier documentation and could mislead readers about the actual import model.

Scope Creep

Low
Category
Excessive Agency
Content
**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
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.

Scope Creep

Low
Category
Excessive Agency
Content
**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
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.

Intent-Code Divergence

Low
Confidence
81% confidence
Finding
The skill description emphasizes that everything is local and explicitly states there are no network calls. However, the same file contains numerous outbound web links later in the document, which contradicts the absolute wording in the documentation, even though the contradiction is in documentation content rather than executable code.

Intent-Code Divergence

Low
Confidence
88% confidence
Finding
This is a direct contradiction within the skill documentation: one section makes an absolute statement that there are no network calls, while later content provides web links to external services. While the core scripts may still be local-only, the documentation as written overstates the absence of network use.

Intent-Code Divergence

Low
Confidence
82% confidence
Finding
The top-level docstring frames the module as an import parser for provider billing data. However, the code also implements `export_json` and CLI `--output` behavior that writes aggregated records back out to disk, which is additional behavior not reflected in the documentation.

Static analysis

No suspicious patterns detected.