Back to skill

Security audit

小果量化回测系统助手

Security checks for vulnerabilities and agentic risk

Overview

This Backtrader assistant is mostly coherent, but it bundles runnable examples that can execute command-line text as Python and recommends unpinned source installs for live-trading integrations.

Review this skill carefully before installing. Do not copy examples that parse arguments with eval(); replace them with typed argparse options or validated JSON/config parsing. Keep live broker integrations isolated from real credentials until reviewed, use paper-trading first, and pin any GitHub-sourced dependencies to audited commits in a virtual environment.

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

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:9540
Finding
Arbitrary Python Code Execution Through Unsafe Evaluation of Command-Line Arguments## Vulnerability Details **File Location**: `SKILL.md:9540-9552` and `SKILL.md:9571-9588` **Vulnerability Type**: Command injection through Python `eval()` **Risk Level**: High ### Vulnerable Code ```python # Broker cerebro.broker = bt.brokers.BackBroker(**eval('dict(' + args.broker + ')')) # Sizer cerebro.addsizer(bt.sizers.FixedSize, **eval('dict(' + args.sizer + ')')) # Strategy cerebro.addstrategy(St, **eval('dict(' + args.strat + ')')) # Execute cerebro.run(**eval('dict(' + args.cerebro + ')')) if args.plot: # Plot if requested to cerebro.plot(**eval('dict(' + args.plot + ')')) ``` The evaluated strings originate directly from command-line arguments: ```python parser.add_argument('--cerebro', required=False, default='', metavar='kwargs', help='kwargs in key=value format') parser.add_argument('--broker', required=False, default='', metavar='kwargs', help='kwargs in key=value format') parser.add_argument('--sizer', required=False, default='', metavar='kwargs', help='kwargs in key=value format') parser.add_argument('--strat', required=False, default='', metavar='kwargs', help='kwargs in key=value format') parser.add_argument('--plot', required=False, default='', nargs='?', const='{}', metavar='kwargs', help='kwargs in key=value format') ``` ### Technical Analysis The examples concatenate user-controlled command-line strings into Python expressions and pass the resulting expressions to `eval()`. Python `eval()` is not limited to parsing dictionaries or keyword arguments. It can evaluate function calls, attribute access, imports reached through built-ins, and other expressions with side effects. The surrounding `dict(...)` expression does not provide a security boundary. An attacker who can influence one of the affected arguments can construct an expression th ...[truncated 2442 chars]
Remediation
## Remediation Suggestions 1. Remove every use of `eval()` for parsing command-line or other externally supplied configuration. 2. Define explicit typed arguments with `argparse`, such as `type=int`, `type=float`, and constrained `choices`. 3. If flexible keyword arguments are required, use a non-executable format such as JSON: ```python import json broker_kwargs = json.loads(args.broker or '{}') ``` 4. Validate parsed objects before use: - Require the top-level value to be a dictionary. - Maintain an allowlist of accepted keys for each Backtrader component. - Reject nested objects unless specifically required. - Enforce expected types and safe numeric ranges. 5. Do not treat `ast.literal_eval()` as a complete fix. Although it prevents arbitrary expression execution, the resulting values still require schema, key, type, and range validation. 6. Update all duplicated examples in `SKILL.md`, `assets/`, and `references/` so the Skill cannot reproduce the vulnerable pattern from another source. 7. Add static-analysis checks that reject `eval()` and `exec()` in generated or bundled examples. 8. Add tests using malformed and adversarial argument values to verify that inputs are rejected without evaluation or side effects.

T08 · Insecure Dependencies

Warning
Location
references/44实盘.txt:10
Finding
Unpinned Executable Dependencies Installed Directly From Mutable GitHub Sources## Vulnerability Details **File Location**: `references/44实盘.txt:10-13` and `references/44实盘.txt:712-717` **Vulnerability Type**: Unsafe third-party dependency installation **Risk Level**: Medium ### Vulnerable Instructions ```text pip install git+https://github.com/blampe/IbPy.git ``` ```text pip install https://github.com/blampe/IbPy/archive/master.zip ``` The Visual Chart integration similarly recommends: ```text comtypes fork: https://github.com/mementum/comtypes pip install https://github.com/mementum/comtypes/archive/master.zip ``` These instructions are duplicated in the controlling Skill content at: ```text SKILL.md:13795-13798 SKILL.md:14502 ``` A further mutable-source installation appears at `SKILL.md:14330` and `references/44实盘.txt:545`: ```text pip install git+https://github.com/oanda/oandapy.git ``` ### Technical Analysis These commands instruct users to install executable Python packages directly from GitHub repositories or `master` branch archives. They do not pin a reviewed commit, identify a versioned release, or provide a cryptographic hash. Git branches are mutable references. The code retrieved when the audit was performed may therefore differ from the code installed later. In addition, Python package installation can execute build-backend or setup logic during installation. A compromised maintainer account, repository, dependency, or upstream branch could consequently turn these installation commands into a local code-execution channel. The dependencies are relevant to optional Interactive Brokers, Oanda, and Visual Chart live-trading integrations, so their functionality is within the declared scope. However, installing mutable and unverified source code is not the minimum-risk method required to provide those integrations. The concern is amplified in a live-trading environment because such systems may hold broker tokens, account configuration, and order-submission capabil ...[truncated 1462 chars]
Remediation
## Remediation Suggestions 1. Prefer maintained packages from a trusted package index and pin exact reviewed versions. 2. If a Git-hosted fork is unavoidable, pin an immutable full commit hash rather than a branch or `master.zip`. 3. Build a wheel from the reviewed commit in a controlled environment, inspect it, and distribute it through a trusted internal registry. 4. Record and verify cryptographic hashes with a hash-locked requirements file, for example through `pip --require-hashes`. 5. Avoid running pip as an administrator or root user. 6. Install optional broker integrations in a dedicated virtual environment or container with only the filesystem and network access they require. 7. Separate backtesting environments from live-trading environments and credentials. 8. Review repository ownership, maintenance status, release history, and dependency tree before recommending each package. 9. Add an explicit warning that source installations may run build code and should not be used without reviewing and pinning the retrieved revision. 10. Replace all duplicated mutable-source commands in `SKILL.md`, `assets/`, and `references/` to prevent the Skill from regenerating the unsafe instructions.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • YARA SignaturesMalware Match, Webshell Match, Cryptominer Match
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (167)

Context-Inappropriate Capability

Critical
Confidence
100% confidence
Finding
These examples repeatedly use eval('dict(' + user_input + ')') for broker, strategy, plot, and runtime parameters. That construct directly executes attacker-supplied Python expressions, so any copied example becomes an instant RCE sink if exposed to CLI input, config files, or agent-provided arguments.

Context-Inappropriate Capability

Critical
Confidence
100% confidence
Finding
This section shows additional runtime configuration using eval, preserving the same arbitrary code execution primitive. In skill context, users may trust tutorial examples and integrate them into wrappers, notebooks, or agent-executed scripts, magnifying the blast radius beyond a local demo.

Context-Inappropriate Capability

Critical
Confidence
100% confidence
Finding
The cheat-on-open sample evaluates external configuration strings before broker and strategy setup. Because these parameters are intended to come from command-line input, the example creates a straightforward pre-execution code injection path that can run arbitrary Python before trading logic even starts.

Context-Inappropriate Capability

Critical
Confidence
100% confidence
Finding
The partial plotting example executes user-supplied runtime parameters through eval, turning a harmless plotting helper into an arbitrary code execution vector. This is especially risky because plotting options often seem low-risk, which may reduce user suspicion and increase unsafe reuse.

Context-Inappropriate Capability

Critical
Confidence
100% confidence
Finding
The scheduled timer examples use eval across broker, sizer, strategy, cerebro, and plot configuration, exposing multiple RCE entry points. In an agent skill, examples like this are more dangerous because users may adapt them into automated workflows where untrusted inputs can reach those parameters without manual review.

Context-Inappropriate Capability

High
Confidence
99% confidence
Finding
This example converts user-controlled strings into Python objects with eval, which enables arbitrary code execution if those strings are attacker-controlled. In the context of an agent skill that may generate or adapt code for users, normalizing eval-based patterns is dangerous because users may copy unsafe code into automation or CLIs.

Context-Inappropriate Capability

High
Confidence
99% confidence
Finding
The sample repeatedly uses eval on CLI kwargs, making arbitrary code execution possible through crafted command-line input. This goes beyond the stated purpose of a backtesting helper and teaches an unsafe implementation pattern likely to be reused verbatim.

Context-Inappropriate Capability

High
Confidence
99% confidence
Finding
The order execution sample evaluates broker, strategy, and plot arguments directly from user input, which can execute arbitrary Python expressions. Because this is presented as runnable sample code, it materially increases the chance that downstream users will introduce RCE into local tools or services.

Context-Inappropriate Capability

High
Confidence
99% confidence
Finding
This bracket-order example evaluates untrusted CLI strings for runtime configuration, enabling arbitrary code execution. In a skill centered on strategy examples, such code is especially risky because users are likely to reuse it in local automation or notebook environments with access to credentials and files.

Context-Inappropriate Capability

High
Confidence
99% confidence
Finding
The stop-trail sample uses eval on CLI-supplied strings for multiple configuration areas, which directly exposes arbitrary code execution. The skill context makes this more dangerous because trading and research environments often contain API tokens, brokerage settings, and valuable local data.

Context-Inappropriate Capability

High
Confidence
99% confidence
Finding
The timer scheduling examples again evaluate user-controlled strings as Python code for broker, sizer, strategy, plot, and cerebro options. This creates a generic code-execution primitive unrelated to scheduling and is dangerous if copied into tools that accept external input.

Context-Inappropriate Capability

High
Confidence
99% confidence
Finding
The trading-calendar examples directly eval CLI kwargs, enabling arbitrary execution under the guise of configuration. Because calendars and plotting are ancillary features, there is no legitimate need for unrestricted Python evaluation here.

Ae5

High
Category
analysis-evasion
Confidence
100% confidence
Finding
Instruction-capable artifact exceeds whole-file semantic analysis limits

Context-Inappropriate Capability

High
Confidence
97% confidence
Finding
The skill's stated purpose is a backtesting assistant, but the bundled runner accepts user-specified module paths, loads them as Python source, discovers functions/classes, and executes them inside the process. This is effectively arbitrary code execution capability and is not a necessary or justified implementation detail for a typical assistant skill unless explicitly declared as a trusted developer extensibility feature.

Context-Inappropriate Capability

High
Confidence
99% confidence
Finding
The backtesting runner evaluates raw user-controlled strings for Cerebro kwargs, writer kwargs, plotting kwargs, and object kwargs, turning configuration input into executable Python. For a skill framed as a quant backtesting assistant, this is an unjustified code execution primitive rather than a benign parsing mechanism.

Description-Behavior Mismatch

High
Confidence
99% confidence
Finding
The file content is unrelated to the advertised Backtrader quantitative backtesting capability and instead contains a large N-Queens mixed-integer optimization solver. This mismatch is dangerous because users or downstream agents may trust the skill metadata and invoke or install code that performs unexpected computation, enabling deceptive packaging, wasted resources, and concealment of unauthorized functionality.

Context-Inappropriate Capability

High
Confidence
99% confidence
Finding
The script passes user-controlled CLI arguments into eval to build kwargs for broker, sizer, strategy, cerebro, and plot configuration. This enables arbitrary Python code execution if an attacker can influence those arguments, which goes well beyond the stated purpose of accepting simple key=value backtesting options.

Intent-Code Divergence

High
Confidence
97% confidence
Finding
The CLI help text tells users these options are simple kwargs in key=value format, but the implementation actually evaluates full Python expressions. This mismatch is dangerous because it obscures the code-execution behavior and may cause operators to treat untrusted input as harmless configuration when it is executable code.

Context-Inappropriate Capability

High
Confidence
99% confidence
Finding
The tutorial includes code that passes user-controlled strings into Python eval for runtime configuration parsing. If a user copies these examples into a real tool or automation flow, an attacker can supply crafted arguments that execute arbitrary Python code on the host, leading to full code execution under the user's privileges.

YARA rule 'agent_skill_remote_bootstrap_execution': Remote script or code download followed by execution/bootstrap installation [agent_skills]

High
Category
YARA Match
Content
�,但代码(像任何其他软件一样)可能包含错误。在进入生产环境之前,请使用纸面交易账户或 TWS 演示帐户彻底测试任何策略。

注意:与互动经纪商的交互是通过使用 IbPy 模块进行的,该模块在使用前必须安装。目前在 Pypi 中没有该模块的包(撰写本文时),但可以使用以下命令通过 pip 安装:

pip install git+https://github.com/blampe/IbPy.git
如果您的系统中没有 git(例如在 Windows 上安装),以下命令也可以正常工作:

pip install https://github.com/blampe/IbPy/archive/master.zip
示例代码#
源码包含一个完整的示例,位于:

samples/ibtest/ibtest.py

该示例无法涵盖所有可能的用例,但它试图提供广泛的见解,并应强调在使用回测模块或实时数据模块时没有实际差异。

需要注意的一点是:

示例在任何交易活动开始之前,都会等待 data.LIVE 数据状态通知。这可
Confidence
85% confidence
Finding
YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).

YARA rule 'agent_skill_remote_bootstrap_execution': Remote script or code download followed by execution/bootstrap installation [agent_skills]

High
Category
YARA Match
Content
�,但代码(像任何其他软件一样)可能包含错误。在进入生产环境之前,请使用纸面交易账户或 TWS 演示帐户彻底测试任何策略。

注意:与互动经纪商的交互是通过使用 IbPy 模块进行的,该模块在使用前必须安装。目前在 Pypi 中没有该模块的包(撰写本文时),但可以使用以下命令通过 pip 安装:

pip install git+https://github.com/blampe/IbPy.git
如果您的系统中没有 git(例如在 Windows 上安装),以下命令也可以正常工作:

pip install https://github.com/blampe/IbPy/archive/master.zip
示例代码#
源码包含一个完整的示例,位于:

samples/ibtest/ibtest.py

该示例无法涵盖所有可能的用例,但它试图提供广泛的见解,并应强调在使用回测模块或实时数据模块时没有实际差异。

需要注意的一点是:

示例在任何交易活动开始之前,都会等待 data.LIVE 数据状态通知。这可
Confidence
85% confidence
Finding
YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).

Context-Inappropriate Capability

High
Confidence
98% confidence
Finding
This is a real code-injection risk: the example parses user-controlled CLI input for --plot and executes it with eval('dict(' + args.plot + ')'). An attacker who can influence that argument can run arbitrary Python code in the user's environment, which can lead to command execution, data theft, or full compromise. In the context of a quant/backtesting assistant, users are likely to copy-paste example code and run it locally with external parameters, which makes the pattern more dangerous rather than less.

Context-Inappropriate Capability

High
Confidence
99% confidence
Finding
The sample code builds a Python expression from user-controlled plotting arguments and executes it with eval, which enables arbitrary code execution if the example is copied into a real tool or notebook and run with untrusted input. In the context of a backtesting skill, this is especially risky because users are likely to treat examples as ready-to-run code, so a plotting convenience becomes an unexpected code-execution sink.

Context-Inappropriate Capability

High
Confidence
99% confidence
Finding
This TA-Lib example repeats the same unsafe pattern by passing user-provided plotting text into eval, allowing arbitrary Python execution. Because this appears in reference documentation, it can propagate into production scripts by copy/paste, expanding the blast radius beyond the example itself.

Context-Inappropriate Capability

High
Confidence
99% confidence
Finding
This sample parses user-controlled CLI strings such as --broker, --sizer, --strat, --cerebro, and --plot with eval('dict(' + args... + ')'). Any attacker who can influence those arguments can execute arbitrary Python code in the local process, not just supply configuration values. In a trading/backtesting assistant context, users are likely to run sample code directly, which makes this more dangerous because the file presents the pattern as normal runtime configuration handling.

Static analysis

No suspicious patterns detected.