Back to skill

Security audit

Quant Full Stack

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent quantitative-trading wrapper, but it runs unaudited local trading scripts from the user's home directory without clear safety gates or integrity checks.

Install only if you trust and control the local ~/quant_trading project it will execute. Before using trading or rebalancing tasks, inspect those downstream scripts, confirm they are simulated-only if that is your intent, and avoid providing live brokerage credentials unless the skill adds explicit confirmation, dry-run defaults, and integrity checks.

Vulnerability Patterns
  • Tool Hijacking and SpoofingModifies or replaces tools so legitimate-looking calls execute attacker logic
  • 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)

T07 · Tool Hijacking and Spoofing

Error
Location
runner.py:12
Finding

Unverified External Interpreter and Task Scripts Can Be Hijacked

Content
View full analysis

Vulnerability Details

File Location: runner.py, lines 12–30
Vulnerability Type: Local tool and executable hijacking
Risk Level: High

Vulnerable Code

python
HOME_DIR = os.path.expanduser("~")
VENV_PYTHON = os.path.join(HOME_DIR, "quant_trading", "venv", "bin", "python3")
PROJECT_DIR = os.path.join(HOME_DIR, "quant_trading")

def run_quant_script(task_num, script_name, args):
    """Execute a quantitative module script."""
    try:
        script_path = os.path.join(PROJECT_DIR, task_num, script_name)
        if not os.path.exists(script_path):
            return {"status": "error", "error": f"Script does not exist: {script_path}"}
        
        # Construct the execution command
        cmd = [VENV_PYTHON, script_path] + args
        # Execute with a two-minute timeout
        result = subprocess.run(
            cmd,
            capture_output=True,
            text=True,
            timeout=120,
            cwd=PROJECT_DIR
        )

Technical Analysis

The runner executes a Python interpreter and task scripts located under the external, user-home directory ~/quant_trading. These executable components are not included in the audited package.

Before execution, the code only verifies that the selected task-script path exists. It does not verify the canonical path, file type, ownership, permissions, symlink status, cryptographic hash, or signature of either the script or the virtual-environment interpreter. The package therefore cannot guarantee that the invoked files are the intended quantitative-trading components.

Although subprocess.run receives an argument array and does not use a shell, preventing direct shell metacharacter injection through forwarded arguments, that safeguard does not prevent replacement or spoofing of the executable files themselves.

Attack Path

  1. An attacker obtains the ability to write to the Agent user's ~/quant_trading dir ...[truncated 1555 chars]
Remediation
View remediation

Remediation Suggestions

  1. Bundle the task scripts within the Skill package and resolve their locations relative to the trusted runner.py file rather than the user's home directory.
  2. Use a trusted Python interpreter supplied by the execution environment instead of an interpreter located in a mutable project directory.
  3. If external components are required, maintain an explicit allowlist of expected canonical paths and verify that every resolved path remains within the approved root.
  4. Reject symbolic links and require regular files for both the interpreter and task scripts.
  5. Verify trusted ownership and restrictive permissions. Refuse execution when files or parent directories are writable by unauthorized users or groups.
  6. Validate task scripts and executable components against pinned cryptographic hashes or trusted digital signatures immediately before execution.
  7. Keep the existing fixed task-to-script mapping and argument-array invocation; do not introduce shell-based command construction.
  8. Execute quantitative modules in a sandbox with minimal filesystem, credential, network, and operating-system permissions.
  9. Include all security-relevant task implementations in the review and release process so that the distributed package accurately represents the code executed at runtime.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (5)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The skill advertises capabilities such as data collection, backtesting, and especially simulated rebalancing/trade execution without any warning about side effects, external API usage, rate limits, data integrity, or the possibility of changing system or account state. In an agent setting, omission of these guardrails can cause unintended actions, excessive API calls, or mistaken assumptions that execution is read-only, making unsafe use more likely.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
84% confidence
Finding

The runner executes another Python script via subprocess using user-controlled task selection and arbitrary additional arguments, with no authentication, allowlist for arguments, or safety gating beyond the script filename map. Although shell injection is avoided by passing a list to subprocess.run, this still creates a code-execution boundary into downstream scripts that may perform sensitive actions such as trading, file access, or network operations, making the wrapper a meaningful execution-risk surface.

Content

Scanner excerpt · runner.py (reported line 26)May include surrounding context.

python
# 构造执行命令
        cmd = [VENV_PYTHON, script_path] + args
        # 执行命令,超时2分钟,避免卡死
        result = subprocess.run(
            cmd,
            capture_output=True,
            text=True,

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill launches secondary scripts without any user-facing warning, confirmation, or transparency about what code will run. In this context, the invoked modules correspond to quantitative trading workflow stages, including trade execution, so silent delegation increases the chance of unintended sensitive actions and makes misuse harder for users to detect.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
81% confidence
Finding

自然语言内容全部以中文表述,且围绕“A股股票量化”任务展开,但没有说明这是面向特定中文用户群或区域场景的限定,也未提供语言/locale 选择。根据规则,若技能强制特定语言而无用户选择或明确、合理的限定说明,可构成语言/locale 政策问题。

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

The package and skill descriptions are written only in Chinese and explicitly target 'A股' stock workflows, which imposes a language/locale constraint in the natural-language metadata. The file does not indicate that users can choose another language or that the Chinese-only scope is an explicit opt-in constraint.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.