T08 · Insecure Dependencies
Warning
- Location
- scripts/transcribe.py:61
- Finding
- Unpinned Dependency Installation at Runtime<![CDATA[ ## Vulnerability Details **File Location**: `scripts/transcribe.py:61-68` **Mirrored Location**: `transcription/scripts/transcribe.py:61-68` **Related Documentation**: `SKILL.md:34-42`, `transcription/SKILL.md:34-42` **Vulnerability Type**: Unpinned and automatic third-party dependency installation **Risk Level**: Medium ### Vulnerable Code ```python def ensure_openai(api_key): """Import openai and set the API key.""" try: import openai as _openai except ImportError: print("Installing openai...", flush=True) subprocess.check_call([sys.executable, "-m", "pip", "install", "openai", "--break-system-packages", "-q"]) import openai as _openai ``` The Skill documentation additionally instructs users to execute: ```bash pip install openai pydub --break-system-packages -q ``` ### Technical Analysis When the `openai` module is unavailable, the script automatically invokes `pip` and installs the latest package version available from the configured Python package index. No version constraint, lockfile, package hash, trusted index restriction, or artifact signature is used. Consequently, the code reviewed during the audit does not fully determine the code that will execute at runtime. The installed package and its transitive dependencies can change after the Skill has been reviewed. The use of `--break-system-packages` further allows pip to modify a Python environment managed by the operating system or another package manager. The documentation also installs `pydub`, although the audited scripts do not import or otherwise use that package. This unnecessarily expands the dependency and supply-chain attack surface. Exploitation requires compromise of a package release, a transitive dependency, the configured package index, or package-resolution infrastructure. No evidence was found that this project deliberately points pip to a malicious package or repository. ### Attack Path ...[truncated 1663 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove automatic package installation from application runtime. Fail with a clear dependency error instead. 2. Declare dependencies in a reviewed dependency file and pin exact versions, including transitive dependencies. 3. Use a lockfile and require package hashes, such as: ```text openai==<reviewed-version> --hash=sha256:<reviewed-hash> ``` 4. Install dependencies during a controlled build or setup phase rather than when processing user media. 5. Use an isolated virtual environment or container and remove `--break-system-packages`. 6. Restrict installation to a trusted package index and validate the configured pip index. 7. Generate and review a software bill of materials and periodically scan dependencies for known vulnerabilities. 8. Remove `pydub` from the installation instructions unless the implementation actually requires it. 9. Apply least privilege and prevent the transcription process from writing to shared package or system directories. ]]>
