Back to skill

Security audit

INVEST 投资决策系统

Security checks for vulnerabilities and agentic risk

Overview

This investment helper appears legitimate, but it needs review because it stores financial records and has unsafe report-writing/report-rendering behavior.

Install only if you are comfortable with a local skill keeping investment records and generating files. Treat its recommendations as decision support, not professional financial advice, avoid putting untrusted text into records before opening generated reports, and use only simple report filenames until the file-write boundary is 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 (4)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/report.py:367
Finding

Stored HTML and JavaScript Injection in Generated Reports

Content
View full analysis
= 7 else 'warning' if d['total_score'] >= 5 else 'danger' status_map = {'pending': '待执行', 'executed': '已执行', 'cancelled': '已取消', 'reviewed': '已复盘'} decision_rows += f""" {d.get('name', d['symbol'])} {d['decision_type']} {d['total_score']} {status_map.get(d['status'], d['status'])} {d.get('decision_date', '')} """ ``` ```python for h in portfolio['holdings']: mv = h['quantity'] * (h['current_price'] or h['avg_cost']) cost = h['quantity'] * h['avg_cost'] pnl = mv - cost pnl_pct = (pnl / cost * 100) if cost > 0 else 0 pnl_c = 'pnl-positive' if pnl >= 0 else 'pnl-negative' holdings_rows += f""" {h['symbol']} {h.get('name', '')} {h['asset_class']} {h['quantity']} ¥{h['avg_cost']:.2f} ¥{mv:,.2f} {pnl:+,.2f} ({pnl_pct:+.1f}%) """ ``` ```python for w in watchlist: watchlist_rows += f""" {w['symbol']} {w.get('name', '')} {w.get('reason', '')} {f"¥{w['target_price']:.2f}" if w['target_price'] else '-'} """ ``` ```python
{decision.get('outcome_notes', '')}
``` ```python

{decision.get(' ...[truncated 2367 chars]

Remediation
View remediation
{html_text(d.get('name', d['symbol']))}

{html_text(decision.get('thesis'), 'Not recorded')}

``` 3. Prefer a template engine configured with automatic HTML escaping rather than manually constructing documents with f-strings. 4. Keep numeric formatting separate from text escaping and validate that expected numeric fields are finite numbers. 5. Add a restrictive Content Security Policy to generated documents as defense in depth, for example by disallowing scripts and remote connections where interactivity does not require them. 6. Add regression tests covering `

T09 · Insecure Skill Coding Practices

Error
Location
scripts/report.py:794
Finding

Output Path Traversal Allows Arbitrary File Writes

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/db.py:297
Finding

Non-Atomic and Insufficiently Validated Trade Recording Causes Portfolio Inconsistency

Content
View full analysis
= quantity: new_qty = holding['quantity'] - quantity if new_qty <= 0.001: conn.execute("DELETE FROM holdings WHERE id = ?", (holding['id'],)) else: conn.execute("UPDATE holdings SET quantity = ?, updated_at = ? WHERE id ...[truncated 1849 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/decision.py:148
Finding

Missing Bounds and Numeric Validation in Decision and Position Calculations

Content
View full analysis
max_value: shares_by_risk = int(max_value / entry_price) position_value = shares_by_risk * entry_price position_pct = position_value / capital * 100 # Risk/reward (assuming take profit at 2x risk by default) take_profit_price = entry_price + (entry_price - stop_loss_price) * 2 risk_reward = 2.0 return { 'shares': max(shares_by_risk, 0), 'position_value': round(position_value, 2), 'position_pct': round(position_pct, 1), 'risk_amount': round(risk_amount, 2), 'risk_per_share': round(risk_per_share, 2), 'entry_price': entry_price, 'stop_loss_price': stop_loss_price, 'suggested_take_profit': round(tak ...[truncated 2292 chars]
Remediation
View remediation
maximum: raise ValueError(f"{name} must be at most {maximum}") return value ``` 2. Enforce a score range of 0–10 in `evaluate_decision()`, `create_decision()`, and `update_decision()`. 3. Require: - `capital > 0` - `entry_price > 0` - `stop_loss_price > 0` - an explicitly bounded `risk_per_trade_pct` - `0 < max_position_pct <= 100` 4. Validate stop-loss direction according to decision type. For a long position, require the stop loss below entry; for a short position, use a separate direction-aware formula. 5. Reject non-finite values before arithmetic or database storage. 6. Add database `CHECK` constraints for scores and percentage fields as defense in depth. 7. Add tests for zero, negative, extremely large, Boolean, `NaN`, and infinite inputs. ]]>
Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • 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 (31)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
94% confidence
Finding

The skill performs file-writing behavior by generating and saving HTML reports to an outputs directory, but it does not declare any tool scope, permissions, or allowed-tools boundary. This creates an authorization gap: an agent may write files without explicit user-visible constraints, increasing the risk of unintended filesystem access or overbroad execution in hosts that rely on manifest-level permission declarations.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The skill’s natural-language description, examples, and operating instructions are entirely in Chinese, and the description presents the system as a general-purpose investment decision skill rather than a region-specific or Chinese-only tool. There is no opt-in or note that users may choose another language, which can violate language/locale policy requirements.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The trigger phrases are broad and overlap with ordinary investing conversation, so the skill may activate in situations where the user did not intend to invoke portfolio management, decision logging, or report generation. In a finance context, accidental invocation is more sensitive because it can lead to persistence of financial data or overly authoritative outputs in routine chats.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The document claims it does not provide investment advice, yet it defines recommendation outputs such as STRONG_CONFIDENCE, CAUTIOUS, WAIT, and AVOID. That contradiction can mislead users and downstream systems about the skill's actual function, causing regulated advice-like behavior to be presented as neutral analysis and reducing the likelihood that appropriate safety gating or disclaimers are applied.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The workflow instructs the agent to assess whether to buy, compute position size, save the decision, and present a decision report, despite later claiming the system does not provide investment advice. In context, this is operationally equivalent to actionable trading guidance, which may bypass policy, compliance, or user-expectation safeguards if treated as merely educational tooling.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This Python file contains multiple natural-language strings and comments in Chinese, including table annotations and default rule descriptions. Because the skill does not provide any user opt-in, language selection, or justification for a Chinese-only locale, it can violate the policy against forcing a specific language without user choice.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This Python skill embeds its user-facing framework labels, questions, scoring guides, error messages, and report output almost entirely in Chinese, which effectively constrains the interaction language. The file does not offer any language choice or explain a justified region-specific requirement, so it conflicts with the policy against forcing a specific language without opt-in.

Content

No source excerpt is available for this finding.

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Confidence
75% confidence
Finding

Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

Content

Scanner excerpt · scripts/report.py (reported line 242)May include surrounding context.

python
for i in range(n):
            angle = -90 + i * 360 / n
            rad = angle * 3.14159 / 180
            x = cx + r * __import__('math').cos(rad)
            y = cy + r * __import__('math').sin(rad)
            points.append(f"{x:.1f},{y:.1f}")
        svg_parts.append(f'<polygon points="{" ".join(points)}" fill="none" stroke="#e2e8f0" stroke-width="1"/>')

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Confidence
75% confidence
Finding

Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

Content

Scanner excerpt · scripts/report.py (reported line 271)May include surrounding context.

python
for i in range(n):
            angle = -90 + i * 360 / n
            rad = angle * 3.14159 / 180
            x = cx + r * __import__('math').cos(rad)
            y = cy + r * __import__('math').sin(rad)
            points.append(f"{x:.1f},{y:.1f}")
        svg_parts.append(f'<polygon points="{" ".join(points)}" fill="none" stroke="#e2e8f0" stroke-width="1"/>')

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Confidence
75% confidence
Finding

Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

Content

Scanner excerpt · scripts/report.py (reported line 281)May include surrounding context.

python
for i in range(n):
            angle = -90 + i * 360 / n
            rad = angle * 3.14159 / 180
            x = cx + r * __import__('math').cos(rad)
            y = cy + r * __import__('math').sin(rad)
            points.append(f"{x:.1f},{y:.1f}")
        svg_parts.append(f'<polygon points="{" ".join(points)}" fill="none" stroke="#e2e8f0" stroke-width="1"/>')

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Confidence
75% confidence
Finding

Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

Content

Scanner excerpt · scripts/report.py (reported line 243)May include surrounding context.

python
angle = -90 + i * 360 / n
            rad = angle * 3.14159 / 180
            x = cx + r * __import__('math').cos(rad)
            y = cy + r * __import__('math').sin(rad)
            points.append(f"{x:.1f},{y:.1f}")
        svg_parts.append(f'<polygon points="{" ".join(points)}" fill="none" stroke="#e2e8f0" stroke-width="1"/>')

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Confidence
75% confidence
Finding

Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

Content

Scanner excerpt · scripts/report.py (reported line 272)May include surrounding context.

python
angle = -90 + i * 360 / n
            rad = angle * 3.14159 / 180
            x = cx + r * __import__('math').cos(rad)
            y = cy + r * __import__('math').sin(rad)
            points.append(f"{x:.1f},{y:.1f}")
        svg_parts.append(f'<polygon points="{" ".join(points)}" fill="none" stroke="#e2e8f0" stroke-width="1"/>')

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Confidence
75% confidence
Finding

Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

Content

Scanner excerpt · scripts/report.py (reported line 282)May include surrounding context.

python
angle = -90 + i * 360 / n
            rad = angle * 3.14159 / 180
            x = cx + r * __import__('math').cos(rad)
            y = cy + r * __import__('math').sin(rad)
            points.append(f"{x:.1f},{y:.1f}")
        svg_parts.append(f'<polygon points="{" ".join(points)}" fill="none" stroke="#e2e8f0" stroke-width="1"/>')

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Confidence
75% confidence
Finding

Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

Content

Scanner excerpt · scripts/report.py (reported line 251)May include surrounding context.

python
for i in range(n):
        angle = -90 + i * 360 / n
        rad = angle * 3.14159 / 180
        x = cx + max_r * __import__('math').cos(rad)
        y = cy + max_r * __import__('math').sin(rad)
        svg_parts.append(f'<line x1="{cx}" y1="{cy}" x2="{x:.1f}" y2="{y:.1f}" stroke="#e2e8f0" stroke-width="1"/>')

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Confidence
75% confidence
Finding

Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

Content

Scanner excerpt · scripts/report.py (reported line 252)May include surrounding context.

python
angle = -90 + i * 360 / n
        rad = angle * 3.14159 / 180
        x = cx + max_r * __import__('math').cos(rad)
        y = cy + max_r * __import__('math').sin(rad)
        svg_parts.append(f'<line x1="{cx}" y1="{cy}" x2="{x:.1f}" y2="{y:.1f}" stroke="#e2e8f0" stroke-width="1"/>')

        # Label

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Confidence
75% confidence
Finding

Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

Content

Scanner excerpt · scripts/report.py (reported line 256)May include surrounding context.

python
svg_parts.append(f'<line x1="{cx}" y1="{cy}" x2="{x:.1f}" y2="{y:.1f}" stroke="#e2e8f0" stroke-width="1"/>')

        # Label
        lx = cx + (max_r + 25) * __import__('math').cos(rad)
        ly = cy + (max_r + 25) * __import__('math').sin(rad)
        svg_parts.append(f'<text x="{lx:.1f}" y="{ly:.1f}" text-anchor="middle" dominant-baseline="middle" font-size="13" fill="#475569" font-weight="600">{labels[i]}</text>')

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Confidence
75% confidence
Finding

Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

Content

Scanner excerpt · scripts/report.py (reported line 257)May include surrounding context.

python
# Label
        lx = cx + (max_r + 25) * __import__('math').cos(rad)
        ly = cy + (max_r + 25) * __import__('math').sin(rad)
        svg_parts.append(f'<text x="{lx:.1f}" y="{ly:.1f}" text-anchor="middle" dominant-baseline="middle" font-size="13" fill="#475569" font-weight="600">{labels[i]}</text>')

        # Score label

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Confidence
75% confidence
Finding

Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

Content

Scanner excerpt · scripts/report.py (reported line 262)May include surrounding context.

python
# Score label
        score_r = (max_r - 20) * 0
        sx = cx + score_r * __import__('math').cos(rad)
        sy = cy + score_r * __import__('math').sin(rad)

    # Data polygon

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Confidence
75% confidence
Finding

Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

Content

Scanner excerpt · scripts/report.py (reported line 263)May include surrounding context.

python
# Score label
        score_r = (max_r - 20) * 0
        sx = cx + score_r * __import__('math').cos(rad)
        sy = cy + score_r * __import__('math').sin(rad)

    # Data polygon
    data_points = []

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Confidence
75% confidence
Finding

Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

Content

Scanner excerpt · scripts/report.py (reported line 318)May include surrounding context.

python
start_rad = start_angle * 3.14159 / 180
            end_rad = (start_angle + sweep) * 3.14159 / 180

            x1 = cx + r * __import__('math').cos(start_rad)
            y1 = cy + r * __import__('math').sin(start_rad)
            x2 = cx + r * __import__('math').cos(end_rad)
            y2 = cy + r * __import__('math').sin(end_rad)

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Confidence
75% confidence
Finding

Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

Content

Scanner excerpt · scripts/report.py (reported line 319)May include surrounding context.

python
end_rad = (start_angle + sweep) * 3.14159 / 180

            x1 = cx + r * __import__('math').cos(start_rad)
            y1 = cy + r * __import__('math').sin(start_rad)
            x2 = cx + r * __import__('math').cos(end_rad)
            y2 = cy + r * __import__('math').sin(end_rad)
            ix1 = cx + ir * __import__('math').cos(start_rad)

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Confidence
75% confidence
Finding

Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

Content

Scanner excerpt · scripts/report.py (reported line 320)May include surrounding context.

python
x1 = cx + r * __import__('math').cos(start_rad)
            y1 = cy + r * __import__('math').sin(start_rad)
            x2 = cx + r * __import__('math').cos(end_rad)
            y2 = cy + r * __import__('math').sin(end_rad)
            ix1 = cx + ir * __import__('math').cos(start_rad)
            iy1 = cy + ir * __import__('math').sin(start_rad)

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Confidence
75% confidence
Finding

Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

Content

Scanner excerpt · scripts/report.py (reported line 321)May include surrounding context.

python
x1 = cx + r * __import__('math').cos(start_rad)
            y1 = cy + r * __import__('math').sin(start_rad)
            x2 = cx + r * __import__('math').cos(end_rad)
            y2 = cy + r * __import__('math').sin(end_rad)
            ix1 = cx + ir * __import__('math').cos(start_rad)
            iy1 = cy + ir * __import__('math').sin(start_rad)
            ix2 = cx + ir * __import__('math').cos(end_rad)

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Confidence
75% confidence
Finding

Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

Content

Scanner excerpt · scripts/report.py (reported line 322)May include surrounding context.

python
y1 = cy + r * __import__('math').sin(start_rad)
            x2 = cx + r * __import__('math').cos(end_rad)
            y2 = cy + r * __import__('math').sin(end_rad)
            ix1 = cx + ir * __import__('math').cos(start_rad)
            iy1 = cy + ir * __import__('math').sin(start_rad)
            ix2 = cx + ir * __import__('math').cos(end_rad)
            iy2 = cy + ir * __import__('math').sin(end_rad)

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Confidence
75% confidence
Finding

Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

Content

Scanner excerpt · scripts/report.py (reported line 323)May include surrounding context.

python
x2 = cx + r * __import__('math').cos(end_rad)
            y2 = cy + r * __import__('math').sin(end_rad)
            ix1 = cx + ir * __import__('math').cos(start_rad)
            iy1 = cy + ir * __import__('math').sin(start_rad)
            ix2 = cx + ir * __import__('math').cos(end_rad)
            iy2 = cy + ir * __import__('math').sin(end_rad)