T09 · Insecure Skill Coding Practices
- Location
analyze.py:7- Finding
Unsafe External Module Loading Through a Hard-Coded Import Path
- Content
View full analysis
Vulnerability Details
File Location:
analyze.py, lines 7-9
Vulnerability Type: Python module search-path manipulation and untrusted external dependency loading
Risk Level: MediumVulnerable Code
python import sys sys.path.insert(0, '/Users/yangguangwei/.openclaw/workspace-front-door') from api_client import get_copilot_dataTechnical Analysis
The script prepends a hard-coded directory outside the audited skill package to
sys.path. Because this directory is inserted at index zero, Python gives a module namedapi_clientin that location precedence over modules available from other locations.Importing
api_clientexecutes its top-level Python code immediately. The referenced module is not included in the project, so its implementation, API destination, authentication behavior, TLS configuration, and side effects cannot be verified by this audit. The security of the skill therefore depends on the integrity and permissions of an unaudited external directory.The documentation also shows a different path,
~/.openclaw/skills/traffic-analysis. Python does not automatically expand~when it appears as asys.pathentry, and that documented path is inconsistent with the developer-specific absolute path in the implementation.Attack Path
- An attacker gains the ability to create or replace
api_client.py, or an equivalentapi_clientpackage, under/Users/yangguangwei/.openclaw/workspace-front-door. - A user or agent imports or executes
analyze.py. - The script places the external directory first in Python's module search path.
- Python resolves
from api_client import get_copilot_datato the attacker-controlled module. - The malicious module's initialization code executes with the same operating-system permissions as the agent process.
- The substituted function can intercept store identifiers and date ranges, falsify funnel data, redirect requests, or perform other ...[truncated 903 chars]
- An attacker gains the ability to create or replace
- Remediation
View remediation
Remediation Suggestions
-
Remove the runtime modification of
sys.path. -
Bundle the API client inside the skill package and use an explicit package-relative import, for example:
python from .api_client import get_copilot_data -
Package the skill through a standard Python package configuration so module resolution does not depend on machine-specific absolute paths.
-
If the API client must remain external, inject a validated client object into
analyze()rather than dynamically selecting a module through the search path. -
Restrict ownership and write permissions on all executable dependency locations.
-
Pin dependency versions and use integrity verification for distributed components.
-
Define and enforce an HTTPS API base URL and an allowed-host policy in the client.
-
Update
SKILL.mdso its import instructions match the secured package layout; usepathlib.Path.expanduser()if user-home expansion is genuinely necessary. -
Add tests that verify the imported client resolves to the expected package file and that unexpected local modules cannot shadow it.
-
