T08 · Insecure Dependencies
- Location
compare.py:7- Finding
Unverified Local Dependency Loaded with Import Precedence
- Content
View full analysis
Vulnerability Details
File Location:
compare.py, lines 7-11
Vulnerability Type: Unsafe local dependency loading and Python module hijacking
Risk Level: MediumVulnerable Code:
python import sys import os # 使用绝对路径导入 clerk-performance-analysis perf_analysis_path = os.path.expanduser('~/.openclaw/skills/clerk-performance-analysis') sys.path.insert(0, perf_analysis_path) from analyze import analyzeTechnical Analysis
The code prepends a mutable directory beneath the current user's home directory to Python's module search path and then imports the generic module name
analyze. Becausesys.path.insert(0, ...)grants this location the highest import precedence, Python will load and executeanalyze.pyor a corresponding package from that directory before considering other installed modules.Python executes module-level statements during import. The implementation does not verify the dependency's cryptographic digest, signature, version, ownership, permissions, or canonical path. Consequently, a party able to create or replace the dependency in
~/.openclaw/skills/clerk-performance-analysiscan cause arbitrary Python code to execute whencompare.pyis imported or run.The audited project does not itself contain a malicious
analyzemodule. The issue is an unsafe trust boundary around an external, mutable dependency.Attack Path
- An attacker gains write access to
~/.openclaw/skills/clerk-performance-analysis, such as through another compromised skill, an insecure installer, overly permissive filesystem permissions, or the same user account. - The attacker creates or replaces
analyze.pyin that directory. - The malicious file includes attacker-controlled module-level statements or a malicious
analyzefunction. - A user or agent imports or directly executes
compare.py. compare.pyplaces the attacker-controlled directory at index zero ofsys.path.- The stat ...[truncated 1002 chars]
- An attacker gains write access to
- Remediation
View remediation
Remediation Suggestions
- Package
clerk-performance-analysisas an explicitly and uniquely named Python package, and import it through the normal package mechanism rather than mutatingsys.path. - Pin the dependency to an audited version and verify its cryptographic hash or publisher signature during installation.
- Install dependencies into a dedicated virtual environment from an authenticated, approved source.
- Ensure dependency directories are owned by the intended service account and are not writable by less-trusted users or processes.
- If local path loading is unavoidable:
- Resolve the path with
Path.resolve(). - Confirm that the canonical path is within an approved directory.
- Validate ownership and restrictive permissions.
- Verify the expected module against a trusted digest before importing it.
- Avoid generic top-level module names such as
analyze.
- Resolve the path with
- Perform dependency installation as a separate controlled deployment step rather than discovering and trusting mutable code at runtime.
- Run the skill with least privilege and prevent the process from accessing credentials or files unnecessary for retail performance analysis.
- Package
