T08 · Insecure Dependencies
Error
- Location
- scripts/track_express.py:15
- Finding
- External Import Path Allows Hijacking of express_codes Module<![CDATA[ ## Vulnerability Details **File Location**: `scripts/track_express.py`, lines 15–16 **Vulnerability Type**: Python module import hijacking through an externally controlled search path **Risk Level**: High ### Vulnerable Code ```python sys.path.insert(0, '/Users/junjian/.openclaw/workspace/skills/express-tracker/scripts') from express_codes import detect_express, get_express_name ``` ### Technical Analysis The script inserts a hardcoded directory outside the audited project into index zero of `sys.path`. Python searches this directory before normal module locations when resolving `express_codes`. If an attacker can create or modify `/Users/junjian/.openclaw/workspace/skills/express-tracker/scripts/express_codes.py`, Python will import that file instead of the reviewed local `scripts/express_codes.py`. Any top-level code in the substituted module executes immediately during import. This violates the integrity boundary of the audited package: the behavior of the Skill can be changed by an external, mutable component that is not included in the reviewed artifact. ### Attack Path 1. The attacker obtains write access to the hardcoded external directory, directly or through another compromised process running as the same user. 2. The attacker creates or replaces: ```text /Users/junjian/.openclaw/workspace/skills/express-tracker/scripts/express_codes.py ``` 3. A user invokes the documented command: ```bash python3 scripts/track_express.py --nu YT2538259220416 ``` 4. The script places the attacker-controlled directory first in `sys.path`. 5. Python imports the attacker's `express_codes.py`. 6. Malicious top-level code executes before normal tracking-number processing begins. ### Impact Assessment Successful exploitation provides arbitrary Python code execution with the privileges of the user running the Skill. The attacker could access files and environment variables available to that user, modify user-owned data, falsify tracking ...[truncated 280 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the hardcoded `sys.path.insert` statement. 2. Package the scripts as a proper Python package and use an explicit relative import: ```python from .express_codes import detect_express, get_express_name ``` 3. If direct script execution must remain supported, import from a path derived from the reviewed script location rather than a user-specific external directory: ```python from pathlib import Path import sys script_dir = Path(__file__).resolve().parent sys.path.insert(0, str(script_dir)) from express_codes import detect_express, get_express_name ``` 4. Prefer installation through a locked, reproducible package configuration so module resolution does not depend on mutable external directories. 5. Add an automated test that verifies `express_codes.__file__` resolves inside the installed Skill package. ]]>
