Back to skill

Security audit

futu-trading-bot

Security checks for vulnerabilities and agentic risk

Overview

This is openly a Futu trading bot, but it needs review because it can control real-money trades and relies on reusable trading credentials stored in a local project config file.

Install only if you are comfortable giving an agent access to a local Futu OpenD session. Keep REAL trading disabled unless you explicitly confirm each exact order, protect json/config.json as a secret, prefer a dedicated low-risk/simulated account, use restrictive file permissions, avoid host/elevated mode unless necessary, and review any generated strategy process before starting it.

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

Warning
Location
json/config_example.json:2
Finding

Reusable Brokerage Credentials Stored in a Plaintext Configuration File

Content
View full analysis
str: """获取交易密码""" config = self.get_futu_config() return config.get('trade_password', '') def get_trade_password_md5(self) -> str: """获取交易密码MD5(32位小写)""" config = self.get_futu_config() return config.get('trade_password_md5', '') ``` `src/account_manager.py:312-324`: ```python if password_md5 is None: password_md5 = get_trade_password_md5() if password is None: password = get_trade_password() if not password and not password_md5: return { 'success': False, 'error_msg': "未配置交易密码,请在js ...[truncated 2718 chars]
Remediation
View remediation

T08 · Insecure Dependencies

Note
Location
requirements.txt:1
Finding

Python Dependencies Installed Without Artifact Integrity Verification

Content
View full analysis
=68", "wheel"] build-backend = "setuptools.build_meta" [project] name = "futu-trade-bot-skills" version = "1.0.9" description = "Futu Trade Bot Skills modules for account, trade, and quote services." readme = "README.md" requires-python = ">=3.10" dependencies = [ "futu-api==9.6.5608", "pydantic==2.12.5", ] ``` `README.md:51-57`: ```bash python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt pip install -e . ``` ### Technical Analysis The runtime dependencies are pinned to specific versions, which limits version drift, but the installation workflow does not verify package artifact hashes. Build requirements are also not pinned to exact versions: `setuptools>=68` and `wheel` may resolve to different artifacts over time. Python package installation can execute package build or installation code. The documented commands trust the configured package index, mirrors, publisher accounts, and all resolved artifacts. If any of these supply a substituted or compromised artifact matching the requested package and version, installation may execute attacker-controlled code. No evidence was found that the currently named packages are malicious. The issue is the absence of artifact-level integrity controls in a security-sensitive project that handles brokerage credentials and live trading operations. ### Attack Path 1. An attacker compromises a configured Python package index, mirror, package publisher account, DNS or proxy path, or artifact cache. 2. A modified artifact is made available for one of the requested dependencies or build requirements. 3 ...[truncated 1093 chars]
Remediation
View remediation
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (38)

Tp4

High
Category
MCP Tool Poisoning
Confidence
88% confidence
Finding

The description is broadly about account, quote, and trade workflows with real HK market data, and this code is related to that domain, so it is not entirely unrelated. However, the supplied chunk specifically performs sensitive account-control operations: it unlocks/locks trading permissions and can persist account metadata to disk. The declaration lists no permissions, which understates the code’s access to trading/account resources and local file writes. Also, the actual chunk does not cover quote retrieval or trade execution workflows; it is narrower and more specifically an account-management module. Therefore this is a description/behavior mismatch, primarily due to undeclared sensitive capabilities and resource access.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
90% confidence
Finding

This code chunk’s primary purpose is configuration loading and access, not running account, quote, or trade workflows with real HK market data. While it is related to the Futu ecosystem and could support such workflows elsewhere, the actual behavior here is limited to reading local config files, supplying defaults, and exposing sensitive connection/trading settings. That is a materially narrower and different function than the declared operational trading/market-data workflow capability, so this chunk does not accurately match the declared description.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The code clearly focuses on quote-market data operations for Hong Kong securities via OpenQuoteContext. It supports subscriptions, streaming callbacks, snapshots, basic info, market state, K-line, and ticker retrieval. There are no APIs for account info, positions, balances, order placement/cancellation, or other trade/account workflows. So the description overstates the skill’s capabilities in a material way. The HK real-market-data portion is accurate, but the declared primary scope includes account and trade workflows that this code chunk does not provide.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The declared description centers on trading functionality via Futu Trade Bot Skills, including account, quote, and trade workflows using real HK market data. However, the supplied code chunk contains no trading, account access, quote retrieval, market data handling, or Futu API integration. Its sole purpose is generic process lifecycle management for long-running strategy scripts. This is a materially different primary purpose from the declared description, so the description does not accurately represent the behavior of this code chunk.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The description claims broad 'account, quote, and trade workflows with real HK market data.' The supplied code chunk is primarily a trade service for HK stocks: it places live or simulated orders, modifies/cancels orders, and cancels all orders. It does call quote APIs, but only to validate instruments and retrieve lot size/snapshot data in support of trading, not to expose general quote workflows. There is no account-management or account-information workflow in this chunk. Additionally, the code depends on local Futu/OpenD connectivity and configuration access, while declared permissions are empty. Because the declared scope materially overstates the implemented capabilities and omits relevant resource access, this is a mismatch.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
70% confidence
Finding

Without declared permissions the skill's intent is opaque and cannot be validated.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · SKILL.md (reported line 13)May include surrounding context.

md
permissions:
      - local-network  # Futu OpenD (default 127.0.0.1:11111)
      - filesystem-read  # json/config.json and skill modules
      - filesystem-write  # optional account_info.json / strategy logs / PID files when user opts in
      - process  # optional background strategy only after explicit user confirmation
---

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · SKILL.md (reported line 73)May include surrounding context.

md
**Prerequisites / 前提条件:**
- Ensure Futu OpenD is running and HK quote entitlement is available.
- 确保富途OpenD正在运行且拥有港股行情权限。
- Futu OpenD must be reachable (default `127.0.0.1:11111`). The SDK may also need write access to `~/.com.futunn.FutuOpenD/Log`.
- If a restricted sandbox blocks OpenD/log access, **ask the user** whether to rerun in `host` / `elevated` mode. Do not silently escalate privileges.
- 若沙箱导致 OpenD/日志目录不可用,先告知用户再征得同意后使用 `host` / `elevated`,不要静默提权。

Session Persistence

Medium
Category
Rogue Agent
Confidence
73% confidence
Finding

The strategy template writes a PID file and log file for a long-running trading process, creating state that persists across the current session. In a trading context, stale PID files, world-readable logs, or predictable file locations can enable process confusion, unintended control over strategies, or leakage of operational/account-related activity, especially on shared systems.

Content

Scanner excerpt · SKILL.md (reported line 356)May include surrounding context.

md
signal.signal(signal.SIGTERM, handle_exit)
signal.signal(signal.SIGINT, handle_exit)

# Write PID file
with open(PID_FILE, "w") as f:
    f.write(str(os.getpid()))

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · docs/config.md (reported line 59)May include surrounding context.

md
## 安全建议
- `json/config.json` 不应入库,需加入 `.gitignore`。
- 使用最小权限:`chmod 600 json/config.json`。
- 不在日志中输出真实密码或 MD5 值。

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

SQP-3 applies to all file types and covers language or locale policy violations in natural-language content. This markdown file presents all instructions only in Chinese and does not indicate that the user opted into Chinese or that the skill is limited to a Chinese-speaking or region-specific context.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code file contains user-facing/documentation text in Chinese only, including the module description of the skill’s purpose. Under the stated policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale restriction is explicitly justified, which is not present here.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · src/preflight_check.py (reported line 149)May include surrounding context.

python
probe.unlink()
        return _check("futu_log_dir", True, f"Writable log directory: {log_dir}")
    except Exception as exc:
        return _check("futu_log_dir", False, f"Cannot write Futu OpenD log directory: {log_dir}: {exc}")


def detect_sandbox_risk(log_dir_check: Dict[str, Any], opend_check: Dict[str, Any]) -> Dict[str, Any]:

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This code's human-facing natural language is entirely Chinese, including the module docstring and the RuntimeError message shown to users. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale restriction is explicitly documented and justified, which is not present here.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

This code file contains the primary module docstring and CLI/help text in Chinese, establishing a Chinese-only user experience for the skill. The policy allows locale constraints only when documented and justified or when the user is given a choice; neither is present here.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module is presented as a Hong Kong trading tool, but the public API advertises US-only algorithmic order types such as TWAP/VWAP as available options. In an agent setting, this documentation/contract mismatch can cause unsafe order construction, user misunderstanding, or execution attempts with unsupported order semantics, increasing the risk of unintended live trading behavior or failed safeguards.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The command-line interface descriptions, help strings, and result presentation are written only in Chinese. This effectively forces a locale choice on users without any explicit selection mechanism or documented regional restriction.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
77% confidence
Finding

The skill description is presented in both Chinese and English, but it does not explicitly state whether users may interact in either language or choose their preferred locale. Under the language/locale policy rule, natural-language instructions should avoid implicit language constraints unless choice or justification is documented.

Content

No source excerpt is available for this finding.

Excessive Permissions

Low
Category
Privilege Escalation
Confidence
80% confidence
Finding

Skill requests more permissions than appear necessary for its stated functionality. Review if elevated access is justified.

Content

Scanner excerpt · SKILL.md (reported line 74)May include surrounding context.

md
- Ensure Futu OpenD is running and HK quote entitlement is available.
- 确保富途OpenD正在运行且拥有港股行情权限。
- Futu OpenD must be reachable (default `127.0.0.1:11111`). The SDK may also need write access to `~/.com.futunn.FutuOpenD/Log`.
- If a restricted sandbox blocks OpenD/log access, **ask the user** whether to rerun in `host` / `elevated` mode. Do not silently escalate privileges.
- 若沙箱导致 OpenD/日志目录不可用,先告知用户再征得同意后使用 `host` / `elevated`,不要静默提权。

**Setup Steps / 安装步骤:**

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

该 markdown 文件以“文档”为标题并通篇仅使用中文描述接口与安全提示,未说明这是特定区域合规要求,也未给出用户可选择其他语言的方式。按规则,强制特定语言且没有用户 opt-in 属于自然语言层面的 locale policy 风险。

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

该文档标题与全文说明均仅使用中文,未说明这是面向特定区域或用户群的限定文档,也未提供其他语言选项。根据语言/locale 政策,若技能默认强制单一语言而无用户选择或明确合理限定,可能构成自然语言策略违规。

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

The file title and all instructional content are written in Chinese, with no indication that this skill is intentionally limited to Chinese-speaking users or that alternative language support is available. Under the policy, a language-specific constraint should be justified or offered as an opt-in choice.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

The file is entirely written in Chinese and does not indicate that another language is available or that the locale restriction is intentional for a region-specific audience. Under the stated policy, forcing a specific language without user opt-in can be a natural-language policy violation.

Content

No source excerpt is available for this finding.

Unverifiable Dependency: setuptools has 10 known advisory(ies) (CVE-2013-1633 (Setuptools vulnerable to Man-in-the-middle attacks); CVE-2025-47273 (setuptools has a path traversal vulnerability in PackageIndex.download that lead); CVE-2024-6345 (setuptools vulnerable to Command Injection via package URL) +7 more), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
40% confidence
Finding

Dependency has known vulnerabilities (CVEs). Using packages with unpatched security flaws exposes the environment to known exploits.

Content

No source excerpt is available for this finding.

Unverifiable Dependency: wheel has 4 known advisory(ies) (CVE-2026-24049 (Wheel Affected by Arbitrary File Permission Modification via Path Traversal in w); CVE-2022-40898 (pypa/wheel vulnerable to Regular Expression denial of service (ReDoS)); CVE-2022-40898 (An issue discovered in Python Packaging Authority (PyPA) Wheel 0.37.1 and earlie) +1 more), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
40% confidence
Finding

Dependency has known vulnerabilities (CVEs). Using packages with unpatched security flaws exposes the environment to known exploits.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.