T08 · Insecure Dependencies
Warning
- Location
- scripts/download.py:20
- Finding
- Automatic Installation of an Unpinned Third-Party Dependency## Vulnerability Details **File Location**: `scripts/download.py`, lines 20–27 **Vulnerability Type**: Supply-chain risk caused by automatic installation of an unpinned dependency **Risk Level**: Medium **Complete Code Snippet**: ```python def install_yt_dlp(): """Install yt-dlp.""" print("Installing yt-dlp...") try: subprocess.run(['pip', 'install', 'yt-dlp'], check=True) return True except: print("Error: Could not install yt-dlp") return False ``` ### Technical Analysis When `yt-dlp` is unavailable, the application automatically invokes `pip install yt-dlp`. The dependency has no pinned version or integrity hash, so the effective code installed and executed can change without any corresponding change to the audited project. Package installation may execute package-controlled build or installation logic under the privileges of the user running the application. The selected package and source also depend on the invoking environment's pip configuration. This creates exposure to a compromised package release, compromised or malicious package index, unsafe mirror configuration, or other software supply-chain failures. The use of an argument list rather than `shell=True` prevents direct shell metacharacter injection through this particular call. The issue is the uncontrolled dependency retrieval and execution, not shell-command construction. ### Attack Path 1. An attacker compromises a dependency release or a package source used by the victim's pip configuration. 2. The user runs `scripts/download.py` in an environment where the `yt-dlp` executable is unavailable. 3. `check_dependencies()` fails, causing `install_yt_dlp()` to run automatically. 4. The script invokes `pip install yt-dlp` without a reviewed version constraint or integrity hash. 5. Pip retrieves the attacker-controlled or compromised package content. 6. Package-controlled installation or runtime c ...[truncated 578 chars]
- Remediation
- ## Remediation Suggestions - Remove automatic package installation from normal application execution. If the dependency is missing, terminate safely and provide explicit setup instructions. - Declare `yt-dlp` in a dependency manifest or lock file and pin it to a reviewed version. - Use package hashes, such as pip's `--require-hashes`, to verify dependency integrity. - Install dependencies in an isolated virtual environment during a separate, explicit setup phase. - Use `sys.executable -m pip` rather than a bare `pip` executable when installation is explicitly requested, ensuring that the intended Python environment is targeted. - Restrict dependency retrieval to a trusted, authenticated package repository or approved internal mirror. - Add a controlled dependency-update process that reviews new versions before changing the pin and associated integrity hashes. - Document the dependency and installation behavior clearly in `SKILL.md`.
