Back to skill

Security audit

QMT Strategy Autopilot

Security checks for vulnerabilities and agentic risk

Overview

This skill is a disclosed QMT trading autopilot, but it can run live trading workflows and load external Python code with too little scoping or safety disclosure.

Review this carefully before installing. Use only in simulation unless you intentionally want live brokerage automation, and install it only in an environment where QMT credentials and account permissions are tightly limited. Do not set STRATEGY_PLANNER_PATH to untrusted files, and prefer a version-pinned, reviewed planner dependency before allowing live trading.

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

Error
Location
scripts/qmt_autopilot.py:9
Finding
Environment-Controlled Arbitrary Python Module Execution## Vulnerability Details **File Location**: `scripts/qmt_autopilot.py`, lines 9–19 and 27 **Vulnerability Type**: Untrusted dynamic module loading **Risk Level**: High ### Vulnerable Code ```python PLANNER_PATH = os.getenv( "STRATEGY_PLANNER_PATH", "/opt/production_ready_skills/qmt-strategy-planner-skill/scripts/strategy_planner.py" ) def load_planner(): spec = importlib.util.spec_from_file_location( "qmt_strategy_planner_cli", PLANNER_PATH ) if spec is None or spec.loader is None: raise RuntimeError(f"无法加载策略规划器: {PLANNER_PATH}") mod = importlib.util.module_from_spec(spec) sys.modules[spec.name] = mod spec.loader.exec_module(mod) return mod ``` ```python planner = load_planner() ``` ### Technical Analysis The script obtains `PLANNER_PATH` directly from the `STRATEGY_PLANNER_PATH` environment variable and executes the specified Python file through `exec_module()`. It does not constrain the path to a trusted directory, resolve and validate symlinks, verify file ownership or permissions, or authenticate the module with a pinned cryptographic hash. Python module initialization executes top-level statements. Consequently, loading the configured file is itself a code-execution operation, regardless of which `plan`, `clarify`, or `run` command is requested. The module is also loaded before command validation and dispatch. The default external planner dependency is documented, but the environment-controlled override is not disclosed in the project documentation. Because the referenced planner is outside this artifact, its behavior could not be audited here. ### Attack Path 1. An attacker gains the ability to set or influence environment variables for the Skill process. 2. The attacker creates or identifies a malicious Python file readable by that process. 3. The attacker sets `STRATEGY_PLANNER_PATH` to the malicious file's path. 4. A user or automation invokes `qmt_autopilot.py` with any supported o ...[truncated 1176 chars]
Remediation
## Remediation Suggestions 1. Remove the `STRATEGY_PLANNER_PATH` environment override and import a packaged, version-pinned planner dependency from a fixed trusted location. 2. If runtime path configuration is essential: - Maintain an explicit allowlist of approved canonical paths. - Resolve the path with `realpath()` before validation. - Reject paths outside a dedicated trusted root. - Reject symlinks or verify their resolved targets. - Verify that the file and parent directories are owned by an expected privileged account and are not writable by untrusted users. - Verify the module against a pinned cryptographic hash or signed manifest before loading it. 3. Validate the command before loading the planner so invalid commands cannot trigger external module execution. 4. Run the Skill under a dedicated least-privileged account with only the brokerage and filesystem permissions required for its task. 5. Separate simulated and live execution credentials and require an explicit, independently validated authorization step for live trading. 6. Document every executable external dependency and configuration override so the deployed execution boundary can be reviewed. 7. Fail closed when any path, ownership, permission, or integrity check fails.
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (6)

Lp3

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding
The skill declares environment-variable requirements and invokes local Python scripts, but it does not define any explicit tool scope or permission boundary. In a trading automation context, missing scope declarations can cause the agent to access sensitive broker/account configuration or execute capabilities broader than the user expects.

Missing User Warnings

Medium
Confidence
94% confidence
Finding
The skill explicitly automates generation and execution of QMT trading strategies but provides no prominent warning that actions may place simulated or real trades with financial consequences. In this context, an agent or user could invoke execution flows without appreciating that the skill can trigger orders and materially affect account positions.

Missing User Warnings

Medium
Confidence
96% confidence
Finding
Documenting `BROKER_ENV=sim|live` without an explicit caution makes live-account execution appear like a routine mode switch rather than a high-risk operation. Because this skill is designed for automated strategy execution, exposing a live mode without strong warnings and safeguards increases the risk of accidental real-money trades.

Missing User Warnings

Medium
Confidence
97% confidence
Finding
The script loads and executes Python code from a path controlled by the STRATEGY_PLANNER_PATH environment variable via importlib, with no allowlist, signature check, or path validation. If an attacker can influence the environment or deployment configuration, they can cause arbitrary code execution under the privileges of this skill, which is especially dangerous in a trading automation context.

Natural-Language Policy Violations

Medium
Confidence
91% confidence
Finding
Several user-visible error and usage strings are written only in Chinese, including load failures, usage guidance, and unknown-command responses. The file provides no opt-in, locale selection, or documented justification for requiring Chinese, which conflicts with the language/locale policy criteria.

Natural-Language Policy Violations

Low
Confidence
77% confidence
Finding
The description field forces a Chinese-language description and the rest of the operational examples are also Chinese-centric, without offering an alternative language or stating that the skill is intentionally limited to Chinese-speaking users. This can conflict with a language-choice policy when no user opt-in or documented locale justification is provided.