T07 · Tool Hijacking and Spoofing
- Location
scripts/generate_daily_report.py:3- Finding
External Configuration Import Enables Local Tool Hijacking
- Content
View full analysis
Vulnerability Details
File Location:
scripts/generate_daily_report.py, lines 3-7 and 28-32
Vulnerability Type: Untrusted external module and executable path resolution
Risk Level: HighRelevant Code:
python import sys sys.path.insert(0, r"C:\Users\qu669\.openclaw\workspace-yoyo") sys.stdout.reconfigure(encoding='utf-8') import os, datetime, subprocess, logging import configpython for label, rel_path in scripts: script = os.path.join(config.SKILLS_BASE, rel_path) log.info(f"\n{label}...") if not os.path.exists(script): log.error(f"Script does not exist: {script}"); continue result = subprocess.run([config.PYTHON, script])Technical Analysis
The script places a hard-coded directory outside the audited project at the beginning of
sys.pathand then importsconfig. Python executes the top-level code of a module during import, so a malicious or replacedconfig.pyin that directory can execute arbitrary code immediately.The imported configuration also controls
config.PYTHONandconfig.SKILLS_BASE. These values determine the executable and scripts passed tosubprocess.run. The code only checks whether each selected script exists; it does not verify that the executable and scripts are trusted, reside under an approved directory, or match expected files.The external
config.py, Python executable, and workflow scripts are absent from the audited project. Their integrity and behavior therefore cannot be established from this artifact.Attack Path
- An attacker obtains write access to
C:\Users\qu669\.openclaw\workspace-yoyo, or replaces a preexisting file in that directory through another local compromise. - The attacker creates or modifies
config.py. - The malicious module either executes its payload as top-level import code or assigns attacker-controlled paths to
PYTHONandSKILLS_BASE. - A user or Agent invokes the ...[truncated 758 chars]
- An attacker obtains write access to
- Remediation
View remediation
Remediation Suggestions
- Store configuration within the audited project and resolve it relative to
__file__. - Do not prepend a user-writable external directory to
sys.path. - Prefer explicit configuration parsing that does not execute Python code, such as a validated JSON or TOML file.
- Use
sys.executableor an administrator-approved absolute interpreter path instead of an externally controlledconfig.PYTHONvalue. - Resolve every workflow script to a canonical path and verify that it remains beneath an approved, read-only Skill directory.
- Reject symlinks, path traversal, unexpected executables, and scripts outside the allowlisted project root.
- Protect the Skill and configuration directories with restrictive filesystem permissions.
- Where feasible, verify script hashes or signed release manifests before execution.
- Store configuration within the audited project and resolve it relative to
