Back to skill

Security audit

expense-note

Security checks for vulnerabilities and agentic risk

Overview

This is a straightforward local Chinese-language expense tracker; it writes and exports local JSON expense records but shows no hidden network access, credential use, or persistence beyond those files.

Install only if you are comfortable with a Chinese-language local expense tracker that stores personal financial records under the skill's data directory. Back up expenses.json before relying on it, and avoid malformed amounts or unusual category names until validation is improved.

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

Warning
Location
expense-tracker.js:66
Finding

Unvalidated monetary input permits persistent financial data corruption

Content
View full analysis

Vulnerability Details

File Location: expense-tracker.js, lines 66-73
Vulnerability Type: Improper numeric input validation
Risk Level: Medium

js
const expense = {
  id: Date.now(),
  description,
  amount: parseFloat(amount),
  category,
  notes,
  date: new Date().toISOString()
};

data.expenses.push(expense);

Technical Analysis

The application converts the supplied amount with parseFloat() but does not verify that the result is finite, positive, within an acceptable range, or represented by a strictly numeric input string.

Consequently:

  • Inputs such as abc produce NaN.
  • Inputs such as Infinity produce a non-finite value.
  • Inputs such as 12abc are silently interpreted as 12.
  • Negative values are accepted and reduce calculated expense totals.
  • When serialized with JSON.stringify(), NaN and Infinity become null.

The malformed value is added to the expense collection and subsequently persisted by saveData(). A persisted null amount can also cause runtime failures in display operations that call expense.amount.toFixed(2).

Attack Path

  1. An attacker or untrusted caller invokes the expense command with a crafted amount, such as abc, Infinity, -500, or 12abc.
  2. parseFloat() produces NaN, a non-finite number, a negative number, or a partially parsed number.
  3. The application adds the resulting record without validation.
  4. saveData() serializes and writes the malformed record to data/expenses.json.
  5. Later statistics, exports, or record-display operations produce inaccurate results or encounter a runtime exception.

Impact Assessment

Exploitation does not grant additional operating-system privileges or access outside the Skill directory. Its scope is the integrity and availability of the local expense-tracking data. An attacker able to supply expense commands can persist malformed records, man ...[truncated 124 chars]

Remediation
View remediation

Remediation Suggestions

Parse and validate the amount before constructing or saving an expense:

js
const normalizedAmount = String(amount).trim();

if (!/^(?:0|[1-9]\d*)(?:\.\d{1,2})?$/.test(normalizedAmount)) {
  throw new Error('Amount must be a valid non-negative number with at most two decimal places');
}

const parsedAmount = Number(normalizedAmount);

if (!Number.isFinite(parsedAmount) || parsedAmount <= 0 || parsedAmount > 1_000_000_000) {
  throw new Error('Amount is outside the permitted range');
}

Store parsedAmount only after validation. The precise minimum, maximum, decimal precision, and policy for refunds or negative adjustments should be explicitly defined. The application should also validate every record loaded from expenses.json so that preexisting or externally modified malformed data cannot reach arithmetic or formatting operations.

T09 · Insecure Skill Coding Practices

Note
Location
expense-tracker.js:119
Finding

User-controlled category names enable in-process prototype mutation

Content
View full analysis

Vulnerability Details

File Location: expense-tracker.js, lines 119-125 and 170-176
Vulnerability Type: Prototype pollution through unsafe aggregation keys
Risk Level: Low

js
const stats = {};
data.expenses.forEach(expense => {
  if (!stats[expense.category]) {
    stats[expense.category] = { total: 0, count: 0 };
  }
  stats[expense.category].total += expense.amount;
  stats[expense.category].count++;
});

The monthly aggregation repeats the same unsafe pattern:

js
const monthlyStats = {};
expenses.forEach(expense => {
  if (!monthlyStats[expense.category]) {
    monthlyStats[expense.category] = { total: 0, count: 0 };
  }
  monthlyStats[expense.category].total += expense.amount;
  monthlyStats[expense.category].count++;
});

Technical Analysis

The category is supplied by the user and is not restricted to the documented category list. Both statistics functions use that value as a key on a normal JavaScript object.

For a category such as __proto__, property lookup resolves to Object.prototype. Because that inherited value is truthy, the initialization branch is skipped. The subsequent writes to total and count then place properties on Object.prototype in the current Node.js process.

The issue affects both global category statistics and monthly statistics. Categories such as constructor can also collide with inherited object properties and cause unexpected behavior.

Attack Path

  1. An attacker records an expense whose category is __proto__.
  2. The malicious category is persisted in data/expenses.json.
  3. A user subsequently runs category or monthly statistics.
  4. The aggregation code resolves stats["__proto__"] or monthlyStats["__proto__"] to Object.prototype.
  5. The total and count assignments mutate inherited prototype state for the remainder of that Node.js process.
  6. Other code executing in the sa ...[truncated 592 chars]
Remediation
View remediation

Remediation Suggestions

Prefer a Map for user-controlled aggregation keys:

js
const stats = new Map();

for (const expense of data.expenses) {
  const current = stats.get(expense.category) || { total: 0, count: 0 };
  current.total += expense.amount;
  current.count += 1;
  stats.set(expense.category, current);
}

Alternatively, create a dictionary without a prototype and use explicit own-property checks:

js
const stats = Object.create(null);

if (!Object.hasOwn(stats, expense.category)) {
  stats[expense.category] = { total: 0, count: 0 };
}

Because the application already defines DEFAULT_CATEGORIES, it should also reject unknown categories unless custom categories are an intentional feature. Apply the same validation when loading existing JSON data, and update both category and monthly aggregation implementations.

Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (5)

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The natural-language description, title, and trigger phrases are entirely in Chinese, which implies the skill is intended to be invoked and used in a specific language without any opt-in or alternative. The policy requires flagging language or locale constraints unless the skill offers a language choice or clearly documents and justifies the restriction.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

This JSON file contains natural-language values such as category names and expense descriptions entirely in Chinese, but it provides no indication that the skill or dataset is intentionally locale-specific or that users can choose their preferred language. Under the policy, forcing a specific language without opt-in or justification is a natural-language locale violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill description and command interface are entirely Chinese, and later code hard-codes the zh-CN locale for date/time formatting. This creates a natural-language/locale policy issue because users are not offered any language or locale choice, and no region-specific justification is documented.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

This markdown file describes that expense data is stored in data/expenses.json, and elsewhere mentions CRUD operations, but it does not explicitly warn users that using the skill will create and modify a local file containing potentially sensitive personal financial information. For markdown files, user-facing descriptions should disclose behaviors that can affect user data or privacy.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

This JSON file stores user-facing values such as expense descriptions and category labels entirely in Chinese (e.g. "午餐", "餐饮"). For a manifest/config-style file, this constitutes a locale choice embedded in natural-language content, but the file provides no indication that Chinese is user-selected or that the skill is region-specific.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.