Back to skill

Security audit

vibetrading-ai-trading-code-generator

Security checks for vulnerabilities and agentic risk

Overview

This skill is a crypto trading code generator, but it needs review because it can lead users to run live trading code with real credentials and includes unsafe execution and unreliable API behavior.

Review this skill carefully before use. Do not run generated strategies with real exchange keys until the code and API wrapper are manually audited. Use testnet or paper trading first, use restricted no-withdrawal API keys with small limits, and treat every generated or downloaded strategy file as untrusted executable Python. Avoid running the validator or backtester on untrusted strategy files outside a sandbox, and be careful with the documented cleanup command because it permanently deletes local logs, sessions, and simulation results.

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

T09 · Insecure Skill Coding Practices

Error
Location
scripts/code_validator.py:119
Finding
Strategy Validation Executes Untrusted Python Code<![CDATA[ ## Vulnerability Details **File Location**: `scripts/code_validator.py:119-151` **Vulnerability Type**: Unrestricted execution of untrusted code during validation **Risk Level**: High ### Vulnerable Code ```python def _check_imports(self, filepath: Path): """Check for import errors""" try: # Create a temporary test script with tempfile.NamedTemporaryFile(mode='w', suffix='.py', delete=False) as f: test_script = """ import sys import os # Try to add common paths script_dir = os.path.dirname(os.path.abspath(__file__)) parent_dir = os.path.dirname(script_dir) sys.path.insert(0, parent_dir) sys.path.insert(0, os.path.join(parent_dir, 'api_wrappers')) try: import {module_name} print("SUCCESS: Import successful") except ImportError as e: print("IMPORT_ERROR: " + str(e)) except SyntaxError as e: print("SYNTAX_ERROR: " + str(e)) except Exception as e: print("OTHER_ERROR: " + str(e)) """.format(module_name=filepath.stem) f.write(test_script) temp_file = f.name # Run the test script result = subprocess.run( [self.python_executable, temp_file], capture_output=True, text=True, cwd=filepath.parent, timeout=10 ) ``` ### Technical Analysis The validator checks imports by launching a Python subprocess that imports the target strategy module. Python imports execute all top-level statements in the imported file. Consequently, this operation is not a passive validation step: it gives the strategy file the ability to execute arbitrary Python code. The subprocess inherits the validator's user identity, environment variables, filesystem access, and network access. There is no sandbox, environment sanitization, privilege reduction, read-only filesystem, or network restriction. The timeout only limits execution duration and does not prevent immediate actions such as reading environment credentials, modify ...[truncated 1939 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove runtime imports from the default validation workflow. 2. Use non-executing checks such as: - `ast.parse()` for syntax and structural analysis. - `python -m py_compile` for compilation checks. - Static import discovery and allowlist-based module resolution. 3. Treat generated and user-supplied strategies as untrusted executable code. 4. If runtime verification is indispensable, run it in a dedicated sandbox or disposable container with: - No API keys, tokens, or other secrets in the environment. - Network access disabled by default. - A read-only project mount and isolated temporary output directory. - A non-privileged user and no additional Linux capabilities. - CPU, memory, process-count, and execution-time limits. - No access to host sockets, home directories, or sensitive configuration. 5. Require explicit user confirmation before executing a strategy and clearly state that import validation runs strategy code. 6. Generate the temporary helper securely, ensure cleanup in a `finally` block, and avoid module-name interpolation where possible. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/backtest_runner.py:23
Finding
Backtest Interfaces Execute Strategy Files Without Isolation<![CDATA[ ## Vulnerability Details **File Location**: `scripts/backtest_runner.py:23-43`; related instances at `backtest_engine/strategy_adapter.py:276-284` and `backtest_engine/historical_backtest.py:70-72` **Vulnerability Type**: Unrestricted dynamic module execution **Risk Level**: Medium ### Vulnerable Code Primary backtest loader: ```python def load_strategy(self, strategy_path): """Load strategy from file""" strategy_path = Path(strategy_path) if not strategy_path.exists(): raise FileNotFoundError(f"Strategy file not found: {strategy_path}") # Extract strategy name from filename strategy_name = strategy_path.stem # Load the strategy module spec = importlib.util.spec_from_file_location(strategy_name, strategy_path) strategy_module = importlib.util.module_from_spec(spec) try: spec.loader.exec_module(strategy_module) return strategy_module, strategy_name except Exception as e: raise ImportError(f"Failed to load strategy: {e}") ``` Related strategy-adapter loader: ```python else: # Generic strategy - try to import and wrap spec = importlib.util.spec_from_file_location(strategy_path.stem, strategy_path) strategy_module = importlib.util.module_from_spec(spec) spec.loader.exec_module(strategy_module) # Look for strategy class strategy_class = None for attr_name in dir(strategy_module): attr = getattr(strategy_module, attr_name) if isinstance(attr, type) and "Strategy" in attr_name: strategy_class = attr break ``` ### Technical Analysis `importlib.util.spec_from_file_location()` followed by `exec_module()` executes the selected Python file in the current process. This is necessary for a Python strategy runner to invoke strategy logic, but the project does not establish a trust boundary or isolate generated and externally supplied strategy files. The command-line interface accepts user-selected paths, and the doc ...[truncated 1899 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Explicitly classify strategy files as untrusted executable code and display a warning before execution. 2. Run each strategy in a separate, disposable worker or container rather than importing it into the controller process. 3. Remove all trading keys, bot tokens, cloud credentials, and unrelated environment variables from the worker environment. 4. Disable outbound network access during historical backtesting unless a narrowly scoped data source is explicitly required. 5. Mount only the strategy and required market data as read-only inputs. 6. Provide a dedicated writable output directory and validate reports before moving them into the project. 7. Run the worker as a non-privileged account with resource and process limits. 8. Define a constrained strategy interface or declarative strategy format where possible, avoiding arbitrary Python execution. 9. Apply static analysis before execution, while recognizing that static checks are not a substitute for sandboxing. 10. Use the same hardened loading mechanism consistently in `backtest_runner.py`, `strategy_adapter.py`, and `historical_backtest.py`. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
api_wrappers/hyperliquid_api.py:82
Finding
Live API Errors Silently Fall Back to Fabricated Market Data<![CDATA[ ## Vulnerability Details **File Location**: `api_wrappers/hyperliquid_api.py:82-96`; related unsupported cancellation path at `api_wrappers/hyperliquid_api.py:306-313` **Vulnerability Type**: Fail-open trading API behavior and unsafe simulation fallback **Risk Level**: Medium ### Vulnerable Code Request handling: ```python try: if method == 'GET': response = self.session.get(url, params=params) elif method == 'POST': response = self.session.post(url, json=data, params=params) else: raise ValueError(f"Unsupported method: {method}") response.raise_for_status() return response.json() except Exception as e: print(f"API request failed: {e}") # Fall back to simulated data return self._simulate_api_response(endpoint, params) ``` Cancellation invokes an unsupported HTTP method: ```python def cancel_order(self, symbol: str, order_id: str): """Cancel an order (requires authentication).""" if not self.api_key: print("API key required for canceling orders") return None return self._make_request('DELETE', f'/order', params={ 'symbol': symbol, 'orderId': order_id }, signed=True) ``` ### Technical Analysis The request wrapper catches every exception and replaces the failed live response with simulated data. This includes authentication failures, endpoint incompatibility, rate limits, connectivity failures, malformed responses, and unsupported HTTP methods. The fallback response is returned through the same interface as a live response, without a mandatory type-level distinction or explicit simulation state. Downstream strategy code can therefore interpret fabricated values as genuine exchange state. The cancellation path demonstrates a deterministic failure: `cancel_order()` requests `DELETE`, while `_make_request()` only supports `GET` and `POST`. The resulting `ValueError` is caught and converted into a simulated response rather than being surfaced ...[truncated 2093 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Fail closed in live mode by raising typed exceptions for: - Authentication and authorization failures. - Network and timeout failures. - Rate limiting. - Invalid or unexpected responses. - Unsupported HTTP methods. 2. Require an explicit constructor option such as `simulation=True`; never switch from live mode to simulation automatically after an error. 3. Return simulation responses through a distinct type containing an unambiguous simulation marker. 4. Prevent live trading methods from accepting simulated market or account data. 5. Implement the `DELETE` method correctly or change cancellation to the exchange's documented API operation. 6. Add explicit connection and read timeouts to every request. 7. Avoid mutating persistent session headers with request-specific signatures; construct per-request headers instead. 8. Log failures with sufficient context while excluding API keys, signatures, and sensitive order information. 9. Add reconciliation logic that verifies order placement and cancellation against authoritative exchange state. 10. Halt trading and alert the operator when exchange state cannot be confirmed. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (61)

Tool Parameter Abuse

High
Category
Tool Misuse
Content
### 清理临时文件
```bash
# 清理日志和临时文件
rm -rf logs/* simulation_results/* sessions/*
```

### 保留的文件
Confidence
94% confidence
Finding
The rm -rf logs/* simulation_results/* sessions/* command is a destructive shell instruction that can be abused or misused, especially if executed from an unexpected directory or modified by users. In a skill that encourages command copying from documentation, destructive commands deserve heightened scrutiny because users may run them without understanding the data-loss implications.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
This finding describes the most dangerous mismatch: a skill framed as code generation may actually execute a live trading strategy, place/cancel orders, monitor markets continuously, read API credentials from environment variables, and write logs/status files. In the context of cryptocurrency trading, unexpected live order execution can directly cause financial loss, credential misuse, or unauthorized market activity, making the mismatch especially severe.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
This finding describes the most dangerous mismatch: a skill framed as code generation may actually execute a live trading strategy, place/cancel orders, monitor markets continuously, read API credentials from environment variables, and write logs/status files. In the context of cryptocurrency trading, unexpected live order execution can directly cause financial loss, credential misuse, or unauthorized market activity, making the mismatch especially severe.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
This finding describes the most dangerous mismatch: a skill framed as code generation may actually execute a live trading strategy, place/cancel orders, monitor markets continuously, read API credentials from environment variables, and write logs/status files. In the context of cryptocurrency trading, unexpected live order execution can directly cause financial loss, credential misuse, or unauthorized market activity, making the mismatch especially severe.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
This finding describes the most dangerous mismatch: a skill framed as code generation may actually execute a live trading strategy, place/cancel orders, monitor markets continuously, read API credentials from environment variables, and write logs/status files. In the context of cryptocurrency trading, unexpected live order execution can directly cause financial loss, credential misuse, or unauthorized market activity, making the mismatch especially severe.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
This finding describes the most dangerous mismatch: a skill framed as code generation may actually execute a live trading strategy, place/cancel orders, monitor markets continuously, read API credentials from environment variables, and write logs/status files. In the context of cryptocurrency trading, unexpected live order execution can directly cause financial loss, credential misuse, or unauthorized market activity, making the mismatch especially severe.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
This finding describes the most dangerous mismatch: a skill framed as code generation may actually execute a live trading strategy, place/cancel orders, monitor markets continuously, read API credentials from environment variables, and write logs/status files. In the context of cryptocurrency trading, unexpected live order execution can directly cause financial loss, credential misuse, or unauthorized market activity, making the mismatch especially severe.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
This finding describes the most dangerous mismatch: a skill framed as code generation may actually execute a live trading strategy, place/cancel orders, monitor markets continuously, read API credentials from environment variables, and write logs/status files. In the context of cryptocurrency trading, unexpected live order execution can directly cause financial loss, credential misuse, or unauthorized market activity, making the mismatch especially severe.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
This finding describes the most dangerous mismatch: a skill framed as code generation may actually execute a live trading strategy, place/cancel orders, monitor markets continuously, read API credentials from environment variables, and write logs/status files. In the context of cryptocurrency trading, unexpected live order execution can directly cause financial loss, credential misuse, or unauthorized market activity, making the mismatch especially severe.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
This finding describes the most dangerous mismatch: a skill framed as code generation may actually execute a live trading strategy, place/cancel orders, monitor markets continuously, read API credentials from environment variables, and write logs/status files. In the context of cryptocurrency trading, unexpected live order execution can directly cause financial loss, credential misuse, or unauthorized market activity, making the mismatch especially severe.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
This finding describes the most dangerous mismatch: a skill framed as code generation may actually execute a live trading strategy, place/cancel orders, monitor markets continuously, read API credentials from environment variables, and write logs/status files. In the context of cryptocurrency trading, unexpected live order execution can directly cause financial loss, credential misuse, or unauthorized market activity, making the mismatch especially severe.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
This finding describes the most dangerous mismatch: a skill framed as code generation may actually execute a live trading strategy, place/cancel orders, monitor markets continuously, read API credentials from environment variables, and write logs/status files. In the context of cryptocurrency trading, unexpected live order execution can directly cause financial loss, credential misuse, or unauthorized market activity, making the mismatch especially severe.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
This finding describes the most dangerous mismatch: a skill framed as code generation may actually execute a live trading strategy, place/cancel orders, monitor markets continuously, read API credentials from environment variables, and write logs/status files. In the context of cryptocurrency trading, unexpected live order execution can directly cause financial loss, credential misuse, or unauthorized market activity, making the mismatch especially severe.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
This finding describes the most dangerous mismatch: a skill framed as code generation may actually execute a live trading strategy, place/cancel orders, monitor markets continuously, read API credentials from environment variables, and write logs/status files. In the context of cryptocurrency trading, unexpected live order execution can directly cause financial loss, credential misuse, or unauthorized market activity, making the mismatch especially severe.

Intent-Code Divergence

High
Confidence
95% confidence
Finding
The file-level documentation claims this is a Hyperliquid API wrapper, but the implemented authenticated trading behavior follows another exchange’s model. That discrepancy can mislead downstream agents or users into generating and running production trading code under false assumptions, which is especially risky in an automated trading skill where trust in API semantics directly affects fund safety.

Description-Behavior Mismatch

High
Confidence
98% confidence
Finding
This wrapper advertises Hyperliquid support but implements Binance-style authentication headers and request-signing conventions for account and trading operations. In a code-generation skill for live trading bots, this mismatch is dangerous because users may believe orders and account actions are correctly integrated when they are not, leading to failed trades, undefined behavior, or accidental execution against an unintended API pattern.

Context-Inappropriate Capability

High
Confidence
98% confidence
Finding
The engine loads and executes an arbitrary Python file via importlib.util.spec_from_file_location(...).exec_module(), which gives the supplied strategy full code execution with the privileges of the running process. In this skill context, that is especially dangerous because the manifest presents the skill as code generation for trading strategies, not as a general-purpose executor for untrusted Python, so users may not expect arbitrary local code execution.

Context-Inappropriate Capability

High
Confidence
99% confidence
Finding
The function dynamically loads a Python file using importlib and executes it with spec.loader.exec_module(strategy_module), which runs top-level code from the supplied file. If an attacker can influence strategy_file, they can achieve arbitrary code execution on the host, which is especially dangerous in a code-generation/trading skill where users may supply or generate strategy code.

Context-Inappropriate Capability

High
Confidence
98% confidence
Finding
The runner dynamically imports and executes any Python file supplied as a strategy, which means arbitrary code in that file runs with the permissions of the user invoking the backtester. In this skill's context, strategies are generated from natural-language prompts and may be treated as data, so users could be tricked into executing malicious payloads disguised as trading logic.

Direct Prompt Extraction

High
Category
System Prompt Leakage
Content
for key, value in params.items():
                instructions += "- **{key}**: {value}\n"
        
        return instructions
Confidence
85% confidence
Finding
Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Context-Inappropriate Capability

High
Confidence
99% confidence
Finding
The import-check routine dynamically imports the user-supplied strategy module in a subprocess, which executes module-level Python code. Because generated strategy files are effectively untrusted input in this skill, a crafted file can trigger arbitrary code execution, network access, filesystem changes, or secret exfiltration during 'validation', defeating the expectation of passive analysis.

Missing User Warnings

High
Confidence
99% confidence
Finding
The temporary test script imports the target module solely to detect import errors, but importing Python modules executes top-level code. In a code-generation skill for trading strategies, the produced file may contain arbitrary logic, so this check can unintentionally execute attacker-controlled code with the validator's privileges and environment.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The README explicitly instructs users to execute generated trading bot code, but provides no warning that the code may place real orders, use live API credentials, or cause financial loss. In the context of an automated trading code generator, this omission is especially risky because users may treat generated strategies as safe to run directly on a live exchange.

Missing User Warnings

Medium
Confidence
92% confidence
Finding
The README provides a destructive cleanup command using rm -rf against multiple directories without warning users about irreversible deletion or advising them to verify the target paths. Even though the paths appear scoped to project subdirectories, copy-paste use and directory confusion could still lead to accidental loss of logs, session data, or simulation outputs.

Lp3

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding
The skill advertises and documents capabilities that involve environment-variable access, filesystem reads/writes, shell execution, and network/API interaction, but it does not declare any explicit tool scope or permission boundaries. In a trading-oriented skill that can touch credentials and potentially execute generated or auxiliary scripts, missing scope declarations increase the risk of unintended high-impact actions and make review, enforcement, and least-privilege controls much harder.

Static analysis

No suspicious patterns detected.