Back to skill

Security audit

Ptrade Skills

Security checks for vulnerabilities and agentic risk

Overview

This skill is not malicious, but it ships directly deployable live-trading strategies with material risk-control and order-state flaws that users should review before use.

Install only if you understand that these are automated live-trading scripts. Before using real funds, fix the black-swan data-window bug, add broker fill/rejection reconciliation, enforce aggregate exposure limits, and validate the documented schedule and scoring against the actual code.

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 (6)

T09 · Insecure Skill Coding Practices

Error
Location
ptrade_c31_momentum.py:87
Finding

Black-Swan Protection Cannot Execute Because Only One Index Observation Is Requested

Content
View full analysis
= 2: idx_today = idx_df["close"].iloc[-1] idx_yesterday = idx_df["close"].iloc[-2] idx_change = (idx_today - idx_yesterday) / idx_yesterday if idx_change <= BLACK_SWANG_5: logger.warning("指数跌幅{}%,清仓".format(idx_change * 100)) for stock in list(_context["positions"].keys()): sell_stock(context, data, stock) return elif idx_change <= BLACK_SWANG_3: logger.warning("指数跌幅{}%,减半仓".format(idx_change * 100)) ``` ### Technical Analysis The query uses the same previous trading date for both `start_date` and `end_date`. A daily-frequency query over a single trading day will normally return at most one observation. The subsequent `len(idx_df) >= 2` condition therefore prevents the daily index return from being calculated. As a result, both documented controls—the 3% decline position reduction and the 5% decline liquidation—are unreachable under normal API behavior. This is a fail-open design: insufficient risk data silently bypasses the protective action instead of preventing new exposure or taking a conservative fallback action. ### Attack Path 1. The strategy reaches `rebalance` on a scheduled trading day. 2. It requests CSI 300 data for only the immediately preceding trading date. 3. The API returns zero or one daily observation. 4. The `len(idx_df) >= 2` condition evaluates to false. 5. No index return is calculated, even if the market has fallen beyond the configured thresholds. 6. Existing posi ...[truncated 805 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
ptrade_sector_rotation.py:163
Finding

Sector Strategy Black-Swan Protection Is Unreachable

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
ptrade_c31_momentum.py:200
Finding

Aggregate Candidate Orders Can Exceed Available Capital

Content
View full analysis
Remediation
View remediation
1.0: weights = [weight / total for weight in raw_weights] else: weights = raw_weights remaining_cash = context.portfolio.available_cash for candidate, weight in zip(eligible, weights): target_value = min( context.portfolio.available_cash * weight, remaining_cash, ) # Reserve the requested amount until execution status is known. remaining_cash -= target_value buy_stock(context, data, candidate["stock"], target_value, candidate["atr"]) ``` ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
ptrade_smallcap_final.py:220
Finding

Small-Cap Strategy Records Positions Before Orders Are Filled

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
ptrade_c31_momentum.py:330
Finding

Momentum Strategy Records Full Positions Before Execution Confirmation

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
ptrade_sector_rotation.py:195
Finding

Sector Strategy Assumes Full ETF Execution Immediately After Submission

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • 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
  • 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
97% confidence
Finding

This markdown skill file presents all instructions, warnings, and operational details exclusively in Chinese, and nowhere indicates that the user may choose another language or that the skill is limited to a Chinese-speaking or China-specific audience. Under the stated policy, forcing a specific language without user opt-in is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The module docstring and all user-facing log messages are written only in Chinese, with no indication that the user can choose another language or locale. This creates a natural-language policy risk if organizational policy requires language choice rather than enforcing a single locale by default.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The function documentation at L218-L220 says it computes an 8-factor scoring system with a total score of 0-14. However, the code includes eight named factors plus an additional market-cap bonus block at L275-L279, and the point additions sum to a maximum of 13 rather than 14. This is an active contradiction in the code documentation about what the function does.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The top-level documentation describes a weekly Monday trading strategy, which implies rebalancing every Monday. However, the implemented logic in scheduled() requires both weekday == Monday and the calendar day to be in TRADE_DAYS [1, 15], making trading much less frequent than documented.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
78% confidence
Finding

The docstring presents the candidate-pool construction as three specific filters, implying those are the criteria used. The actual implementation adds an additional涨跌停 filter at L140-L146 that removes stocks with roughly ±9.5% daily moves. Because the documentation describes the main logic steps and omits an extra exclusion criterion, it misstates the actual decision logic.

Content

No source excerpt is available for this finding.