T07 · Tool Hijacking and Spoofing
- Location
scripts/run_backtest.py:7- Finding
External Import Path Allows Local Module Substitution
- Content
View full analysis
Vulnerability Details
File Location:
scripts/run_backtest.py, lines 7-9
Vulnerability Type:T07: Tool Hijacking and Spoofing
Risk Level: Highpython import sys sys.path.insert(0, '/root/.openclaw/workspace/skills/akquant-backtest/scripts') from double_ma_strategy import run_double_ma_backtestTechnical Analysis
The launcher prepends a hardcoded external workspace directory to Python's module search path. Consequently,
double_ma_strategyis loaded from that external directory before Python considers the module bundled with the audited project.The security properties of the launcher therefore depend on a file outside the reviewed package. If another user, process, previously installed Skill, or compromised component can modify
/root/.openclaw/workspace/skills/akquant-backtest/scripts/double_ma_strategy.py, it can replace the expected implementation. Python also executes top-level statements during module import, so malicious code does not need to wait forrun_double_ma_backtestto be called.Attack Path
- An attacker or compromised local component obtains write access to the hardcoded external scripts directory.
- The attacker creates or modifies
double_ma_strategy.pyin that directory. - A user follows the documented instructions and runs
python3 scripts/run_backtest.py. - The launcher places the external directory at index zero of
sys.path. - Python imports and executes the substituted module instead of the audited project module.
- The malicious module executes with the same operating-system privileges and environment access as the user running the backtest.
Impact Assessment
Successful exploitation provides arbitrary Python execution in the context of the invoking user. The substituted module could read or alter files accessible to that user, access process environment variables, make network requests, falsify backtest results, or invoke operating-system fu ...[truncated 259 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove the hardcoded
sys.path.insertoperation. - Package the scripts as a Python module and use an explicit package-relative import, such as
from .double_ma_strategy import run_double_ma_backtest. - If direct script execution must remain supported, derive the trusted bundled directory from
Path(__file__).resolve().parentrather than referencing an external workspace. - Avoid importing modules from directories writable by unrelated users or components.
- Add an integration test that verifies the imported module's resolved path remains inside the installed Skill package.
- Remove the hardcoded
