T08 · Insecure Dependencies
- Location
scripts/purevocals.py:22- Finding
Automatic Unpinned Dependency Installation in the Invoking Python Environment
- Content
View full analysis
Vulnerability Details
File Location:
scripts/purevocals.py:22-24;scripts/ensure_package.py:35-47, 131-160
Vulnerability Type: Runtime dependency installation with unpinned versions and import-time side effects
Risk Level: HighVulnerable Code
python ensure_package.pip("pydub", "pydub","AudioSegment") ensure_package.pip("ffmpeg-downloader") ensure_package.pip("audio-separator")python def fix_setuptools_for_legacy_packages(): try: subprocess.check_call([ sys.executable, "-m", "pip", "install", "--verbose", "--ignore-installed", "--no-deps", "packaging==26.1" ]) subprocess.check_call([ sys.executable, "-m", "pip", "install", "--verbose", "--force-reinstall", "setuptools<=81.2.0", "wheel" ]) except Exception as e: logger.info(f"setuptools repair failed: {e}") fix_setuptools_for_legacy_packages()python cmd = [ sys.executable, "-m", "pip", "install", "--upgrade", spec, "--verbose" ] if any(keyword in spec.lower() for keyword in ["git+", "://", ".zip", ".whl"]): extra_flags = ["--no-build-isolation", "--no-deps", "--use-pep517"] try: install_idx = cmd.index("install") cmd[install_idx+1:install_idx+1] = extra_flags except ValueError: cmd.extend(extra_flags) else: cmd.extend(["-i", "https://pypi.tuna.tsinghua.edu.cn/simple"]) subprocess.check_call(cmd)Technical Analysis
Importing
ensure_packageimmediately invokesfix_setuptools_for_legacy_packages(), which modifies the active Python installation by reinstallingpackaging,setuptools, andwheel. The main script then installspydub,ffmpeg-downloader, andaudio-separatorbeforeenv_manager.setup_venv()creates or switches to the intended virtual environment.Consequently, these package operations run ...[truncated 2282 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove all package installation and environment modification side effects from module imports.
- Create a skill-private virtual environment before importing optional third-party dependencies.
- Restart the script inside that environment and perform all subsequent package operations using the environment's Python executable.
- Replace ad hoc runtime installation with a reviewed lockfile containing exact versions and cryptographic hashes.
- Install with hash enforcement, such as
pip install --require-hashes -r requirements.txt. - Avoid
--upgrade,--ignore-installed, and--force-reinstallduring normal skill execution. - Use a trusted, explicitly configured package repository. If a mirror is required, validate its governance and integrity controls.
- Review and pin transitive dependencies rather than pinning only direct packages.
- Fail safely when dependency verification fails instead of continuing with a partially modified environment.
- Keep the virtual environment inside a skill-specific directory instead of sharing it with unrelated skills.
