T08 · Insecure Dependencies
Warning
- Location
- transcribe.py:20
- Finding
- Unpinned Third-Party Package Installed at Runtime<![CDATA[ ## Vulnerability Details **File Location**: `transcribe.py`, lines 20–24 **Vulnerability Type**: Uncontrolled and unpinned runtime dependency installation **Risk Level**: Medium ### Vulnerable Code ```python try: from openai import OpenAI except ImportError: subprocess.run([sys.executable, "-m", "pip", "install", "--break-system-packages", "-q", "openai"], check=True) from openai import OpenAI ``` ### Technical Analysis When the `openai` module is unavailable, the program automatically invokes `pip` to install the latest package published under that name. The installation does not specify an exact version, package hash, lockfile, or explicitly trusted package repository. This makes the code executed by the application dependent on mutable external package-index content that was not part of the audited project. The effective dependency may change between executions without any corresponding change to this repository. The use of `--break-system-packages` is particularly unsafe because it permits pip to modify a system-managed Python environment. This can replace or conflict with operating-system-managed dependencies and affect applications other than this Skill. ### Attack Path 1. An attacker compromises the configured Python package index, DNS/network path, package publisher account, or an upstream package release. 2. Alternatively, the host is configured to use a malicious or untrusted pip index through environment variables or pip configuration. 3. The Skill is executed in an environment where `openai` is not already installed. 4. The `ImportError` handler invokes pip without a pinned version or verified hash. 5. Pip downloads and installs the attacker-controlled or compromised package. 6. Package installation hooks or imported module code execute with the privileges of the user running the Skill. ### Impact Assessment Successful exploitation can result in arbitrary code execution with the privileges of the Skill process. Depend ...[truncated 507 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove all automatic package installation from application runtime. 2. Declare the dependency in a reviewed dependency file and pin it to an exact version. 3. Generate a lockfile and require cryptographic hashes for downloaded distributions. 4. Install dependencies during a controlled deployment or setup phase. 5. Use an isolated virtual environment instead of `--break-system-packages`. 6. Restrict dependency installation to a trusted package repository. 7. If the dependency is missing at runtime, terminate with a clear error rather than modifying the host: ```python try: from openai import OpenAI except ImportError as exc: raise RuntimeError( "The pinned OpenAI dependency is not installed. " "Install the project's locked dependencies before running this command." ) from exc ``` 8. Perform dependency vulnerability and provenance checks as part of the build process. ]]>
