T09 · Insecure Skill Coding Practices
- Location
analyze.py:6- Finding
Unsafe External Module Resolution Through a Hard-Coded Import Path
- Content
View full analysis
Vulnerability Details
File Location:
analyze.py:6-8
Vulnerability Type: Python module path hijacking through an untrusted external dependency
Risk Level: MediumVulnerable Code
python import sys sys.path.insert(0, '/Users/yangguangwei/.openclaw/workspace-front-door') from api_client import get_api_clientTechnical Analysis
The skill prepends a hard-coded directory outside the project to
sys.path. Because index0has the highest import priority, the subsequentapi_clientimport resolves from that external directory before normal package locations.Importing a Python module executes its top-level code immediately. The referenced
api_clientimplementation is not included in the audited project, is not version-pinned, and cannot be integrity-checked from this repository. Consequently, the effective behavior of importing this skill depends on mutable code outside the audited package.The same unsafe integration pattern is also recommended in
USAGE.md:44-46, increasing the likelihood that users reproduce it:python import sys sys.path.insert(0, '/Users/yangguangwei/.openclaw/workspace-front-door') from api_client import get_api_clientAttack Path
- An attacker obtains write access to
/Users/yangguangwei/.openclaw/workspace-front-door, or otherwise controls the directory at that path. - The attacker creates or replaces
api_client.pywith a malicious module. - A user or agent imports
analyze.py. - The
sys.path.insert(0, ...)call prioritizes the attacker-controlled directory. - Python imports the malicious
api_clientand executes its top-level code. - The payload runs with the same operating-system identity and privileges as the agent process.
Exploitation requires the attacker to control the referenced directory or its module file. The audited project itself does not download or install a payload into that location.
Impact Assessment
...[truncated 632 chars]
- An attacker obtains write access to
- Remediation
View remediation
Remediation Suggestions
-
Remove the runtime
sys.path.insert()modification. -
Bundle the API client within a trusted package and use an explicit relative import where appropriate, for example:
python from .api_client import get_api_client -
Alternatively, publish the client as a properly named dependency, pin its version and integrity hash, and install it through the project's controlled dependency-management process.
-
Do not use a user-specific absolute path in executable code or documentation.
-
If an external module location is operationally unavoidable:
- Obtain it from administrator-controlled configuration rather than user input.
- Restrict directory and file write permissions.
- Validate ownership and reject writable-by-untrusted-user locations.
- Verify the module against a trusted cryptographic digest before loading it.
- Load it by an explicit verified file path rather than changing global import precedence.
-
Update
USAGE.md:44-46to remove the unsafe example and document the secured dependency installation process. -
Add deployment tests that verify the imported
api_clientoriginates from the expected package and path.
-
