T08 · Insecure Dependencies
- Location
scripts/jimeng_video.py:14- Finding
Unsafe Python Module Search-Path Override Enables Dependency Substitution
- Content
View full analysis
Vulnerability Details
File Location:
scripts/jimeng_video.py, lines 14–18
Vulnerability Type: Unsafe dependency resolution and Python module path manipulation
Risk Level: MediumVulnerable Code
python sys.path.insert(0, os.path.expanduser('~/.local/lib/python3.12/site-packages')) from volcenginesdkcore.configuration import Configuration from volcenginesdkcore.api_client import ApiClient from volcenginesdkcore.universal import UniversalApi, UniversalInfoTechnical Analysis
The script prepends a hard-coded, user-writable package directory to
sys.path. Python resolves imports in search-path order, so any package namedvolcenginesdkcorein this directory takes precedence over packages from the active interpreter environment.Consequently, a counterfeit or compromised
volcenginesdkcorepackage can execute arbitrary code as soon as the import statements run. Import execution occurs before credential validation or the main video-generation workflow.The path is also fixed to Python 3.12. If the script runs under a different interpreter version, it may load an unintended or incompatible package installation rather than the dependency selected by the active environment.
Attack Path
- An attacker or compromised package installer places a malicious package at
~/.local/lib/python3.12/site-packages/volcenginesdkcore. - The user invokes
scripts/jimeng_video.py. - The script inserts the attacker-influenced directory at index zero of
sys.path. - Python resolves the
volcenginesdkcoreimports from that directory. - Malicious package initialization code executes with the privileges of the user running the skill.
- The imported code can access the process environment, including
VOLC_ACCESS_KEYandVOLC_SECRET_KEY, and can read or modify files accessible to that user.
Exploitation requires the attacker to influence the specified package directory, such as through a compr ...[truncated 747 chars]
- An attacker or compromised package installer places a malicious package at
- Remediation
View remediation
Remediation Suggestions
-
Remove the manual search-path modification:
python # Remove this line: sys.path.insert(0, os.path.expanduser('~/.local/lib/python3.12/site-packages')) -
Install and execute the project in an isolated virtual environment so that standard Python import resolution selects only the environment's declared dependencies.
-
Add a dependency manifest that pins an approved
volcenginesdkcoreversion. Where supported, use a lock file or hash-verified installation, for example withpip --require-hashes. -
Install dependencies only from an explicitly configured, trusted package index. Disable unneeded fallback indexes to reduce dependency-confusion risk.
-
Run the script with the virtual environment's interpreter rather than relying on packages from a global or user-level site-packages directory.
-
In deployment environments, make the application and dependency directories non-writable to the runtime identity.
-
