Back to skill

Security audit

Nex Expenses

Security checks for vulnerabilities and agentic risk

Overview

This is a coherent local Belgian expense tracker, but it warrants Review because sensitive receipts and accounting exports have under-disclosed local privacy and CSV safety risks.

Install only if you want a Belgium-specific local expense tracker and are comfortable storing receipts and accounting records on this machine. Review the setup dependency install, protect or periodically clean ~/.nex-expenses and temporary OCR files, verify tax categorization with a boekhouder, and sanitize CSV exports before sharing/opening them in spreadsheets.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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
Findings (3)

T08 · Insecure Dependencies

Warning
Location
setup.sh:80
Finding

Unpinned Third-Party Dependencies Create Supply-Chain Risk

Content
View full analysis

Vulnerability Details

File Location: setup.sh, lines 80-84
Vulnerability Type: Unpinned dependency installation without integrity verification
Risk Level: Medium

Vulnerable Code

bash
"$VENV_PIP" install --quiet --upgrade pip

# Core dependencies
"$VENV_PIP" install --quiet \
    "Pillow>=9.0"

Technical Analysis

The setup process downloads and installs mutable package versions from the active pip package index. The constraint Pillow>=9.0 permits any later compatible release, while the pip upgrade is also unconstrained. No lockfile, exact version pins, package hashes, or trusted-index restrictions are used.

Consequently, the code installed for the same audited project can change over time without any change to this repository. Exploitation would require compromise of a package release, maintainer account, configured package mirror, package index, or another dependency-resolution component. This is therefore a supply-chain exposure rather than evidence that the current Pillow or pip packages are malicious.

Attack Path

  1. An attacker compromises a permitted package release, package publishing account, configured pip mirror, or dependency-resolution source.
  2. The attacker publishes a version satisfying the loose version constraint or affects the unconstrained pip upgrade.
  3. A user runs bash setup.sh.
  4. pip resolves and installs the attacker-controlled or compromised distribution.
  5. Malicious installation or runtime code executes under the account running setup.

Impact Assessment

Exploited package code would run with the privileges of the installing user. It could access that user's files, including locally stored expense records and receipt images, modify the virtual environment or CLI behavior, and make network connections. The script does not itself request administrative privileges, so the direct scope is normally limited to the invoking user's permissions.

Remediation
View remediation

Remediation Suggestions

  • Pin every dependency to an exact, reviewed version.
  • Generate and commit a lockfile containing transitive dependency versions.
  • Record cryptographic hashes and install with pip's --require-hashes option.
  • Use an explicitly trusted package index rather than relying on ambient pip configuration.
  • Avoid automatically upgrading pip during normal application setup; manage the installer version through the reviewed lock or deployment process.
  • Add dependency vulnerability and provenance scanning to release workflows.
  • Periodically update pins through a controlled review and testing process.

T09 · Insecure Skill Coding Practices

Warning
Location
lib/ocr.py:164
Finding

Processed Receipt Images Persist in Temporary Storage

Content
View full analysis

Vulnerability Details

File Location: lib/ocr.py, lines 164-181
Vulnerability Type: Unsafe temporary-file lifecycle and file-descriptor leak
Risk Level: Medium

Vulnerable Code

python
try:
    img = Image.open(image_path)

    # Convert to grayscale
    img = img.convert("L")

    # Increase contrast
    enhancer = ImageEnhance.Contrast(img)
    img = enhancer.enhance(1.5)

    # Save to temp file
    temp_fd, temp_path = tempfile.mkstemp(suffix=".png")
    img.save(temp_path, "PNG")

    return temp_path

except Exception as e:
    logger.warning(f"Image preprocessing failed, using original: {e}")
    return image_path

Technical Analysis

tempfile.mkstemp() securely creates a uniquely named file and returns both an open file descriptor and its path. The implementation ignores temp_fd, so the descriptor remains open. It also returns only the path and never removes the processed image after Tesseract completes.

Receipt images may contain vendor details, transaction data, payment references, addresses, tax numbers, and other identifying or financial information. The residual image is stored outside the application's protected data directory and remains present until an external cleanup mechanism removes it. Repeated OCR operations also accumulate leaked descriptors and temporary files.

The use of mkstemp() mitigates predictable-name and symlink races; the confirmed problem is missing closure and cleanup, not predictable temporary-file creation.

Attack Path

  1. A user scans a sensitive receipt through the OCR command or expense-add workflow.
  2. Image preprocessing creates a grayscale PNG in the operating system's temporary directory.
  3. The open descriptor returned by mkstemp() is not closed.
  4. Tesseract processes the image, but no finally block deletes it.
  5. The image remains available on disk until operating-system cleanup.
  6. Another process running ...[truncated 658 chars]
Remediation
View remediation

Remediation Suggestions

  • Close the descriptor immediately after creation with os.close(temp_fd), or write through a managed file object.
  • Track whether preprocessing created a temporary file.
  • Wrap OCR execution in try/finally and delete the generated image with Path(temp_path).unlink(missing_ok=True).
  • Prefer tempfile.TemporaryDirectory() or another context-managed lifecycle that guarantees cleanup on success and failure.
  • Explicitly close the Pillow image using a context manager.
  • Retain restrictive owner-only permissions for temporary receipt files.
  • Add tests that verify temporary files and descriptors are released after successful OCR, Tesseract failure, timeout, and parsing exceptions.
  • Consider processing through a pipe or memory buffer if supported, avoiding an intermediate persistent file entirely.

T09 · Insecure Skill Coding Practices

Warning
Location
lib/storage.py:622
Finding

Spreadsheet Formula Injection in Accountant CSV Exports

Content
View full analysis

Vulnerability Details

File Location: lib/storage.py, lines 622-636
Vulnerability Type: CSV/spreadsheet formula injection
Risk Level: Medium

Vulnerable Code

python
result.append(
    {
        "Datum": row_dict["date"],
        "Leverancier": row_dict["vendor"],
        "Omschrijving": row_dict["description"],
        "Bedrag excl. BTW": row_dict["amount_excl"],
        "BTW %": row_dict["btw_rate"],
        "BTW Bedrag": row_dict["btw_amount"],
        "Bedrag incl. BTW": row_dict["amount_incl"],
        "Belastingcategorie": category_name,
        "Aftrekbaar %": row_dict["deduction_pct"],
        "Aftrekbaar Bedrag": row_dict["deductible_amount"],
        "Betaalmethode": row_dict["payment_method"],
        "Notities": row_dict["notes"],
        "Labels": row_dict["tags"],
    }
)

The affected records are subsequently serialized without formula neutralization in nex-expenses.py, lines 694-700:

python
if format_type == 'csv':
    import csv
    with open(filepath, 'w', newline='', encoding='utf-8-sig') as f:
        if data:
            fieldnames = data[0].keys()
            writer = csv.DictWriter(f, fieldnames=fieldnames)
            writer.writeheader()
            writer.writerows(data)

Technical Analysis

Text fields controlled through manual input or OCR—such as vendor, description, notes, and tags—are exported directly to CSV. Python's CSV writer correctly handles delimiters and quoting but does not prevent spreadsheet applications from interpreting a cell beginning with =, +, -, or @ as a formula.

A malicious value can therefore remain inert in SQLite and plain-text processing but become active when the accountant opens the exported file in Excel, LibreOffice Calc, or another formula-capable spreadsheet application. Exact behavior and available capabilities depend on the spreadsheet product, version, security settings, and wh ...[truncated 1308 chars]

Remediation
View remediation

Remediation Suggestions

  • Introduce a dedicated CSV-cell sanitizer for every textual field.
  • Detect values whose first non-whitespace character is =, +, -, or @.
  • Prefix dangerous values with an apostrophe or another spreadsheet-safe neutralization sequence compatible with supported accounting software.
  • Consider tab, carriage-return, newline, and Unicode-based bypasses when determining the effective first character.
  • Keep numeric fields as validated numeric types rather than converting them through untrusted strings.
  • Apply neutralization only to CSV output; retain original values in SQLite and JSON where appropriate.
  • Document the export behavior so accountants understand why a protective prefix may appear.
  • Add regression tests covering all formula markers, leading whitespace, embedded delimiters, quotes, and multiline values.
  • Where practical, prefer an export format that supports explicit text cell types rather than relying on CSV type inference.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (23)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

This second mismatch finding indicates the skill claims OCR receipt scanning, automatic field extraction, categorization, and export behavior that are not actually present, while also exposing undeclared capabilities such as budget tracking, recurring expenses, and search. Such misrepresentation expands the trust boundary: users and orchestrators may permit access based on declared purpose, while the real behavior differs materially.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

This second mismatch finding indicates the skill claims OCR receipt scanning, automatic field extraction, categorization, and export behavior that are not actually present, while also exposing undeclared capabilities such as budget tracking, recurring expenses, and search. Such misrepresentation expands the trust boundary: users and orchestrators may permit access based on declared purpose, while the real behavior differs materially.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill advertises and instructs use of shell commands, local file reads/writes, environment-dependent setup, and persistent storage, but it does not declare any explicit tool scope such as allowed tools or permissions. That omission weakens least-privilege controls and makes it easier for an agent runtime to grant broader capabilities than users expect, especially since the skill handles sensitive financial documents and receipt images.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
84% confidence
Finding

The skill is explicitly designed to persist accounting data, exports, and receipt-related information across sessions, which creates ongoing storage of sensitive financial records on disk. Persistence is expected for an expense tracker, but it still represents a real security and privacy concern if retention, protection, and deletion controls are not clearly documented and scoped.

Content

Scanner excerpt · SKILL.md (reported line 3)May include surrounding context.

md
---
name: nex-expenses
description: Track and categorize all business expenses with automatic Belgian tax deduction rules and VAT recovery optimization. Use optical character recognition (OCR) with Tesseract to scan receipt images and automatically extract vendor names, transaction amounts, dates, and BTW rates from physical receipt photographs. Intelligently categorize expenses into Belgian tax deduction categories (beroepskosten 100%, representatie 50%, autokosten with fuel/other subcategories, kantoorkosten 100%, kledij/werkkledij, verzekeringen, opleiding, telecom, huurkantoor, etc.) with automatic deductible portion calculation per category following Belgian tax regulations. Generate quarterly summaries organized by tax category with total amounts, deductible amounts, effective deduction percentages, and BTW collected for convenient filing with your boekhouder (accountant). Track input VAT (BTW inkomsten) separately by rate (21%, 12%, 6%, 0%) for quarterly aangifte submissions and maintain complete payment method records (cash, bank transfer, credit card, debit card, cheque). Create professional CSV/JSON exports with Belgian-friendly column headers for import into accounting software. Ideal for freelancers, eenmanszaken, and kleine ondernemingen who need to manage expenses, optimize tax deductions, prepare quarterly accounting documents, and stay compliant with Belgian tax law. All expense data remains local.
version: 1.0.0
metadata:
  clawdbot:

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The trigger phrase list includes broad everyday financial terms like 'business expense' and 'tax category', which can cause unintended invocation in unrelated conversations. In an agent environment with shell and file capabilities, accidental activation can lead to unnecessary access to local receipts, databases, or export files containing sensitive financial data.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The documentation notes that receipt images are stored under a local receipts directory, but the skill description does not clearly warn users that uploaded/scanned receipt images are copied and retained locally. Because receipts often contain sensitive financial and personal data, unclear retention and storage behavior creates a privacy and data-handling risk.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module hard-codes Belgian tax categories, deduction percentages, VAT handling, and defaults without any explicit locale selection or user confirmation. In a finance/accounting skill, this can cause users outside the intended jurisdiction—or Belgian users with special cases—to receive incorrect compliance guidance and exports, which may lead to filing errors or under/over-claimed deductions.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This configuration is explicitly tailored to Belgian tax categories and uses fixed OCR languages "nld+eng+fra", indicating a forced locale/language context. The file does not present this as user-selectable or opt-in, which matches the policy concern for locale constraints imposed without choice.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

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

md
# Check if tesseract is available
        if not check_tesseract():
            errors.append(
                "Tesseract not installed. Install: sudo apt-get install tesseract-ocr (Linux) "
                "or brew install tesseract (macOS)"
            )
            return result

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · SKILL.md (reported line 337)May include surrounding context.

md
# Check if tesseract is available
        if not check_tesseract():
            errors.append(
                "Tesseract not installed. Install: sudo apt-get install tesseract-ocr (Linux) "
                "or brew install tesseract (macOS)"
            )
            return result

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · lib/ocr.py (reported line 69)May include surrounding context.

python
# Check if tesseract is available
        if not check_tesseract():
            errors.append(
                "Tesseract not installed. Install: sudo apt-get install tesseract-ocr (Linux) "
                "or brew install tesseract (macOS)"
            )
            return result

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · lib/ocr.py (reported line 148)May include surrounding context.

python
# Check if tesseract is available
        if not check_tesseract():
            errors.append(
                "Tesseract not installed. Install: sudo apt-get install tesseract-ocr (Linux) "
                "or brew install tesseract (macOS)"
            )
            return result

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · setup.sh (reported line 129)May include surrounding context.

sh
# Check if tesseract is available
        if not check_tesseract():
            errors.append(
                "Tesseract not installed. Install: sudo apt-get install tesseract-ocr (Linux) "
                "or brew install tesseract (macOS)"
            )
            return result

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · setup.sh (reported line 130)May include surrounding context.

sh
# Check if tesseract is available
        if not check_tesseract():
            errors.append(
                "Tesseract not installed. Install: sudo apt-get install tesseract-ocr (Linux) "
                "or brew install tesseract (macOS)"
            )
            return result

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · lib/ocr.py (reported line 136)May include surrounding context.

python
if config.OCR_CONFIG:
            cmd.extend(config.OCR_CONFIG.split())

        result = subprocess.run(
            cmd, capture_output=True, text=True, timeout=30
        )

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · lib/ocr.py (reported line 492)May include surrounding context.

python
True if tesseract is available, False otherwise
    """
    try:
        result = subprocess.run(
            [config.TESSERACT_CMD, "--version"],
            capture_output=True,
            timeout=5,

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The delete_expense function permanently removes an expense record via SQL DELETE, which is an irreversible data-modifying action. In this code, there is no confirmation prompt, logging statement, or inline warning beyond a minimal docstring, so users or integrators may not be adequately alerted before invoking it.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The export_for_accountant function explicitly formats output with Dutch/Flemish column names such as 'Leverancier' and 'Bedrag excl. BTW' and is described as Belgian-specific. This imposes a fixed locale/language in user-facing output without any visible opt-in or configurability in the file.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module docstring states the tool is built specifically for Belgian tax workflows and mixes locale-specific Dutch/French terms such as 'boekhouder', 'BTW', 'aangifte', and 'eenmanszaken' without offering any language or locale choice. This creates a natural-language locale constraint that is imposed by default rather than presented as an explicit opt-in or selectable regional mode.

Content

No source excerpt is available for this finding.

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
85% confidence
Finding

Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Content

Scanner excerpt · nex-expenses.py (reported line 908)May include surrounding context.

python
# DELETE
    delete_parser = subparsers.add_parser('delete', help='Delete expense')
    delete_parser.add_argument('id', type=int, help='Expense ID')
    delete_parser.add_argument('--force', action='store_true', help='Skip confirmation')
    delete_parser.set_defaults(func=cmd_delete)

    # SEARCH

Session Persistence

Medium
Category
Rogue Agent
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.

Content

Scanner excerpt · setup.sh (reported line 48)May include surrounding context.

sh
PY_VERSION="$($PYTHON --version 2>&1)"
echo "  Found: $PY_VERSION"

# Step 2: Create data directory and subdirectories
echo "[2/6] Creating data directories..."
mkdir -p "$DATA_DIR"
mkdir -p "$DATA_DIR/receipts"

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · setup.sh (reported line 55)May include surrounding context.

sh
mkdir -p "$DATA_DIR/exports"

if [ "$PLATFORM" != "windows" ]; then
    chmod 700 "$DATA_DIR"
fi
echo "  Data directory: $DATA_DIR"

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The natural-language description repeatedly centers Belgian-specific tax handling and business context, which imposes a locale-specific scope. Under the policy rule, locale constraints should either be optional for users or clearly justified as a region-specific tool; here the README presents the locale as mandatory behavior without explicit opt-in language.

Content

No source excerpt is available for this finding.