Back to skill

Security audit

PTRADE量化策略生成器

Security checks for vulnerabilities and agentic risk

Overview

This skill is for PTRADE strategy generation, but it includes live-trading automation guidance and unsafe templates that could place or liquidate real trades without enough safeguards.

Review before installing. Treat this as a financial automation skill, not an educational snippet generator: do not deploy generated or bundled strategies to live PTRADE accounts until they have been manually reviewed, corrected, backtested, paper-traded, and limited to an isolated account or strategy-owned positions. Avoid using fund-transfer or margin/futures APIs unless explicitly needed and independently verified.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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 (4)

T05 · Unauthorized Access and Privilege Escalation

Error
Location
templates/factor_strategy.py:64
Finding

Unscoped Liquidation of All Account Positions

Content
View full analysis
0: trade.close_long(symbol, volume, price=0, price_type="market") ``` ### Technical Analysis The rebalance procedure retrieves every position visible through the account API and closes every positive long position. It does not verify that a position: - Was opened by this strategy. - Belongs to the strategy's previous target portfolio. - Is part of the configured CSI 300 universe. - Belongs to an isolated strategy account or sub-portfolio. - Has been explicitly authorized for liquidation. This violates least-privilege and asset-ownership boundaries at the trading-account level. The strategy only needs to manage positions it owns, but it exercises its trading authority across the entire set of visible holdings. ### Attack Path 1. A user installs the Skill and copies or generates the bundled factor strategy. 2. The user enables the strategy on a live account that also contains manually managed positions or holdings owned by other strategies. 3. The strategy increments its trading-day counter on each invocation. 4. On the twentieth trading day, the rebalance branch executes. 5. `security.get_positions()` returns all positions visible to the strategy. 6. The loop submits market sell orders for every positive long position. 7. Unrelated holdings are liquidated before the strategy buys its newly selected target stocks. No external attacker is required; deploying the advertised template on a shared account is sufficient to trigger the unsafe behavior. ### Impact Assessment The code can use the strategy's existing trading permission to liquidate all long positions visible in the account. It does not ob ...[truncated 458 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
templates/dual_ma_strategy.py:147
Finding

Reversed Crossover Conditions Generate False Trading Signals

Content
View full analysis
long_ma) gold_cross = curr_crossed and not prev_crossed prev_dead = (prev_short_ma >= prev_long_ma) curr_dead = (short_ma < long_ma) dead_cross = curr_dead and not prev_dead ``` ### Technical Analysis The prior-period conditions are negated when constructing both crossover signals. A golden cross should be detected when the short average was less than or equal to the long average in the previous period and is greater in the current period: ```python prev_short_ma <= prev_long_ma and short_ma > long_ma ``` The implementation instead requires the prior golden-cross condition to be false. Consequently, a continued bullish state can be interpreted as a newly occurring golden cross. The death-cross condition has the corresponding defect. It negates the requirement that the previous short average was greater than or equal to the previous long average. A continued bearish state can therefore be interpreted as a new death cross. Because these booleans directly control market-order calls later in the function, the defect affects financial operations rather than merely diagnostic output. ### Attack Path 1. A user deploys the advertised dual-moving-average template. 2. Consecutive bars leave the short and long averages on the same side rather than producing a new crossover. 3. The negated prior-period condition evaluates as required by the faulty expression. 4. The strategy misclassifies the continuing trend as a new crossover. 5. If the position check permits it, the strategy submits a market buy or market sell order. 6. Live capital is exposed to a trade that does not satisfy the documented strategy. ### Impact Assessment The strategy may place unintended market orders based ...[truncated 420 chars]
Remediation
View remediation
long_ma ) dead_cross = ( prev_short_ma >= prev_long_ma and short_ma < long_ma ) ``` Also: 1. Add deterministic unit tests for no-cross, golden-cross, and death-cross cases. 2. Test equality at the crossover boundary. 3. Require a confirmed strategy-owned position before selling. 4. Confirm successful order execution before changing the stored purchase price. 5. Backtest the corrected implementation before presenting it as suitable for live operation. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
templates/ma_strategy.py:40
Finding

Previous Long Moving Average Is Calculated from a Single Price

Content
View full analysis
params["long_window"] else 0 ``` ### Technical Analysis The previous short moving average is correctly calculated from a slice. The previous long moving average, however, uses a single indexed value: ```python close[-params["long_window"]-1] ``` Calling `mean()` on that scalar does not calculate the average of the previous long window. The resulting crossover test compares a short-window average against one historical closing price. The same defective implementation exists in both the English-named and non-English-named copies of the template. Both templates then use this value to decide whether to submit market orders. The templates also attempt to close a fixed quantity without first confirming that the account has a sufficient strategy-owned and currently sellable position. This can produce rejected orders or interfere with a position whose ownership has not been established. ### Attack Path 1. A user deploys either basic moving-average template. 2. The strategy retrieves enough historical prices to execute the calculation. 3. `prev_long` is assigned one historical closing price rather than a long-window average. 4. The previous-period relationship between the short and long averages is misclassified. 5. A false golden-cross or death-cross condition is generated. 6. The strategy submits a market order based on the invalid signal. ### Impact Assessment The defective calculation can cause purchases or sales that do not correspond to a genuine moving-average crossover. It operates within the user's existing trading authority but can cause direct financial loss through incorrect live orders. P ...[truncated 256 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
SKILL.md:16
Finding

Conflicting PTRADE API Contracts Can Cause Partial or Failed Trading Execution

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (12)

Missing User Warnings

High
Category
Not specified by scanner
Confidence
94% confidence
Finding

The README instructs users to enable live mode and auto-execution for generated strategies without a clear warning about real financial loss, broker-side effects, or the need for staged validation. In this context, generated code may be imperfect or misapplied, so presenting a straightforward path from code generation to automated live trading materially increases the risk of harmful real-world actions.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
95% confidence
Finding

The Chinese instructions explicitly describe subscribing a strategy and enabling automatic order placement in live trading, but do not include an equivalent explicit risk warning or operational safety guidance. In a financial automation skill, this omission is especially dangerous because users may treat generated code as production-ready and enable real-money execution prematurely.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The skill documents numerous live-trading and fund-movement APIs, including order placement, cancellation, margin trading, and fund transfer functions, but does not prominently warn users that generated code may execute real trades or move assets. In this context, omission of a safety warning is dangerous because users may treat generated strategies as educational snippets when they are actually ready to operate against a live brokerage environment.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The trigger keywords are broad enough that the skill may activate on generic requests about trading or strategy generation, increasing the chance of unsolicited code generation in a financial domain. In a skill that can produce live-trading automation guidance, unintended activation raises the risk of users receiving or applying trading logic without clearly intending to invoke this specific tool.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The Chinese trigger description uses general phrases like '量化策略' and '生成策略', which can match broad user intents unrelated to this exact platform or readiness for execution. Because the skill is tied to code generation for automated trading, ambiguous activation increases the chance of accidental invocation and unsafe downstream use.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The trigger keywords include broad, common terms such as '量化策略', '量化交易', '生成策略', and '写策略代码', which can cause the skill to activate in general trading or coding conversations outside a clearly intended PTRADE context. Because this skill can generate executable trading code using live-trading APIs, accidental invocation increases the chance of unsafe or unauthorized strategy generation.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The document discloses a concrete external API base URL and the exact authentication header names used to access the knowledge base. While header names are not secrets by themselves, exposing operational integration details unrelated to the skill’s user-facing purpose broadens the attack surface and can assist unauthorized API probing, credential phishing, or misuse if paired with leaked keys elsewhere.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

Listing authentication header names without any warning about credential sensitivity normalizes unsafe handling of API auth material and may encourage downstream reproduction in prompts, logs, or generated examples. In an LLM skill context, this is more dangerous because the model may surface or reuse these details in responses despite the skill’s unrelated purpose.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

This strategy file is explicitly designed to generate executable PTRADE trading code and its usage instructions lead directly from paste/save to backtest and live operation. The code contains market buy/sell actions and encourages real trading without embedding an explicit warning, dry-run default, or user confirmation guard, which increases the chance of accidental real-money execution and financial loss.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
83% confidence
Finding

The natural-language content in the docstring and comments is entirely Chinese and presents the strategy as a fixed-language skill. Under the stated policy, forcing a specific language without offering a user choice or documenting a justified region-specific constraint is a locale-policy issue.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module docstring at L05 states the strategy is applicable to 'A股股票', but the initialized default security at L09 is '000001.XSHG', which denotes the Shanghai Composite Index rather than an A-share stock. This is an active contradiction between the documented intended target instrument and the code's actual default behavior.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

The file content is presented exclusively in Chinese and does not indicate that the language is optional, user-selected, or required for a region-specific purpose. Under the language/locale policy rule, forcing a single language without opt-in can be a natural-language policy violation.

Content

No source excerpt is available for this finding.