T08 · Insecure Dependencies
- Location
analyze.py:11- Finding
Untrusted External Module Loaded Through Hard-Coded Import Path
- Content
View full analysis
Vulnerability Details
File Location:
analyze.py:11-12
Vulnerability Type: Unsafe external dependency resolution and import-path manipulation
Risk Level: HighComplete Code Snippet
python sys.path.insert(0, '/Users/yangguangwei/.openclaw/workspace-front-door') from api_client import get_shop_dataThe vulnerable import is also triggered when the package is imported through
__init__.py:7-15:python from .analyze import ( analyze, format_report, fetch_customer_list, analyze_customer_types, analyze_badge_match, analyze_trial_summary, CUSTOMER_TYPE_MAP )Technical Analysis
The Skill prepends a hard-coded directory outside the audited project to
sys.path, giving that directory priority during Python module resolution. It then importsapi_clientwithout a package-qualified or relative module name.Python executes module-level code during import. Consequently, the contents of the externally resolved
api_clientmodule execute as soon asanalyze.pyis loaded. Because that module is neither included in the audited project nor pinned or integrity-verified, its implementation, version, network destinations, credential handling, and future modifications cannot be assessed.The package initializer imports
analyze.pyimmediately, so exploitation does not require the user to invoke an analysis function. Merely importing the package can execute a substituted module. This is an unsafe supply-chain boundary and can also facilitate local module spoofing where an attacker can write to the hard-coded directory.The implementation path also conflicts with the portable dependency path documented in
SKILL.md, increasing the likelihood of environment-specific, unmanaged dependency resolution.Attack Path
- An attacker obtains write access to
/Users/yangguangwei/.openclaw/workspace-front-door, or compromises the process or deployment mechanism that suppliesapi_client.py. - The attacker cr ...[truncated 1439 chars]
- An attacker obtains write access to
- Remediation
View remediation
Remediation Suggestions
-
Remove the
sys.path.insertcall and avoid resolving dependencies from hard-coded, user-specific external directories. -
Package the reviewed API client within the project and import it through an explicit relative path, for example:
python from .api_client import get_shop_data -
If the client must remain a third-party dependency, install it through standard Python dependency management. Pin an exact reviewed version and verify package hashes in a lock file or requirements file.
-
Restrict package sources to an approved private registry or trusted index to reduce dependency-confusion risk.
-
Use dependency injection where practical, accepting an initialized and approved API client from the host application rather than importing an unmanaged implementation at module load time.
-
Avoid executing external dependency code merely by importing the package. Keep package initialization minimal and defer client initialization until the relevant operation is explicitly invoked.
-
Configure and validate the API base URL through trusted configuration. Apply an allowlist for permitted schemes, hosts, and endpoints.
-
Ensure the external dependency directory and deployment artifacts are not writable by untrusted users or lower-privileged processes.
-
Review the actual
api_clientimplementation separately, including authentication, TLS verification, timeout behavior, redirect handling, logging, and treatment of sensitive customer data.
-
