Back to skill

Security audit

Fund Buying Decision Pro

Security checks for vulnerabilities and agentic risk

Overview

This is a disclosed local Chinese mutual-fund strategy helper that stores strategy state in SQLite and fetches Eastmoney data, with no evidence of hidden execution, credential use, or exfiltration.

Install only if you are comfortable storing fund strategy state, balances, holdings, and trade history in a local plaintext SQLite database. Keep the database in a private user directory, avoid shared or synced locations unless protected, and treat generated buy/sell actions as local strategy records rather than broker-executed trades.

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/strategy_engine.py:179
Finding

Local Financial Records Are Stored Without Explicit Restrictive Filesystem Permissions

Content
View full analysis

Vulnerability Details

File Location: scripts/strategy_engine.py:179-184; related sensitive schema in scripts/import_eastmoney_pingzhongdata.py:336-379
Vulnerability Type: Insecure permissions for locally stored sensitive financial data
Risk Level: Medium

Vulnerable Code

python
def connect_db(db_path: Path = DEFAULT_DB_PATH) -> sqlite3.Connection:
    db_path.parent.mkdir(parents=True, exist_ok=True)
    connection = sqlite3.connect(db_path)
    connection.row_factory = sqlite3.Row
    importer.init_db(connection)
    return connection

The resulting database contains financial account state and transaction history:

sql
CREATE TABLE IF NOT EXISTS strategy_accounts (
    account_id TEXT NOT NULL,
    fund_code TEXT NOT NULL,
    fund_type TEXT NOT NULL DEFAULT 'equity_fund',
    cash_pool REAL NOT NULL DEFAULT 0,
    position_units REAL NOT NULL DEFAULT 0,
    avg_cost_price REAL,
    note TEXT,
    created_at TEXT NOT NULL,
    updated_at TEXT NOT NULL,
    PRIMARY KEY (account_id, fund_code)
);

CREATE TABLE IF NOT EXISTS strategy_trades (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    account_id TEXT NOT NULL,
    fund_code TEXT NOT NULL,
    trade_date TEXT NOT NULL,
    trade_time_local TEXT,
    trade_type TEXT NOT NULL,
    direction TEXT NOT NULL,
    gross_amount REAL NOT NULL DEFAULT 0,
    price REAL,
    units REAL NOT NULL DEFAULT 0,
    fee_rate_pct REAL,
    fee_amount REAL NOT NULL DEFAULT 0,
    cash_delta REAL NOT NULL,
    units_delta REAL NOT NULL,
    note TEXT,
    created_at TEXT NOT NULL
);

Technical Analysis

The Skill creates the database directory using Path.mkdir() and opens or creates the SQLite database through sqlite3.connect(), but it does not explicitly enforce restrictive permissions on either resource.

Consequently, access permissions are inherited from the process umask. Under a permis ...[truncated 2338 chars]

Remediation
View remediation

Remediation Suggestions

  1. Create the default storage directory with owner-only permissions:

    python
    db_path.parent.mkdir(mode=0o700, parents=True, exist_ok=True)
    db_path.parent.chmod(0o700)
    
  2. Create a new database atomically with mode 0600, or immediately enforce that mode after creation:

    python
    import os
    
    if not db_path.exists():
        fd = os.open(db_path, os.O_CREAT | os.O_EXCL | os.O_RDWR, 0o600)
        os.close(fd)
    
    db_path.chmod(0o600)
    connection = sqlite3.connect(db_path)
    
  3. Before opening an existing database, verify that it is a regular file, is owned by the expected user, and is not a symbolic link.

  4. Reject databases in world-writable or untrusted shared directories unless the user explicitly acknowledges the risk.

  5. Detect and repair group or world access on existing databases. If safe remediation is not possible, stop with a clear error rather than silently processing sensitive records.

  6. Avoid printing an unnecessary absolute database path in routine output, particularly in shared logs.

  7. Document that the SQLite database contains sensitive financial information and should not be committed to source control, placed in shared storage, or backed up without appropriate access controls and encryption.

Vulnerability Patterns
  • 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
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (13)

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
Treat `SKILL.md` as strategy configuration only. Do not store live account state in this file.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
Treat `SKILL.md` as strategy configuration only. Do not store live account state in this file.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
Treat `SKILL.md` as strategy configuration only. Do not store live account state in this file.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
Treat `SKILL.md` as strategy configuration only. Do not store live account state in this file.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
Treat `SKILL.md` as strategy configuration only. Do not store live account state in this file.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
95% confidence
Finding

The skill instructs the agent to read local reference files and run data-refresh/reporting commands that imply network and file access, but it does not declare any explicit tool scope such as allowed-tools or permissions. That mismatch weakens least-privilege controls and can let the skill be used with broader capabilities than reviewers or orchestrators expect, increasing the chance of unintended file access or network fetches.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
73% confidence
Finding

The skill explicitly persists live account state and trade history in SQLite, including cash balances, holdings, and account identifiers. While persistence is functionally appropriate for a trading workflow, it creates retention of sensitive financial state across sessions; if the database location, access controls, or downstream scripts are unsafe, that state can be exposed, tampered with, or reused without clear consent.

Content

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

md
`python {baseDir}/scripts/record_strategy_trade.py ...`
  `python {baseDir}/scripts/confirm_strategy_action.py ...`
- Do not edit `capital.initial_cash` in `SKILL.md` to reflect a new live balance.
  If the user adds cash or changes holdings, write that change to SQLite instead.

## Required Inputs

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

Multiple user-visible strings are fixed in Chinese, including labels such as 无, 基金代码, and 是否触发. This imposes a specific language on users without opt-in or documented justification, which matches the language/locale policy violation criteria.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code renders the user-facing report with fixed Chinese labels and values such as '无', '基金代码', and other section headings. That enforces a specific locale for all users without opt-in or configuration, which matches the language/locale policy violation criteria.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

apply_strategy_decision directly persists trades and updates account state whenever the computed action is one of the trade actions, with no confirmation gate, authorization check, dry-run default, or explicit safety interlock in this file. In the context of an agent skill for fund trading decisions, this increases the chance of unintended or unauthorized portfolio changes if an upstream caller invokes the function automatically or on stale/manipulated inputs.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

This code file exposes a --refresh flag that causes fund data to be refreshed from Eastmoney, implying an outbound network request. Although the help text names the data source, there is no explicit warning or disclosure about the network call or possible transmission of request metadata when the option is used.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

The script emits multiple user-facing status and error messages only in Chinese, including normal execution, no-op, and mismatch cases. Because there is no visible user opt-in or documented justification for a Chinese-only locale in this file, this appears to violate the language/locale policy category.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
96% confidence
Finding

The format_account_summary function returns all end-user summary text in Chinese, hard-coding a specific language regardless of user preference or locale. This is a natural-language policy issue because the file does not provide opt-in, localization support, or documented justification for requiring Chinese.

Content

No source excerpt is available for this finding.