T08 · Insecure Dependencies
Warning
- Location
- send_email.py:9
- Finding
- Unpinned Third-Party Dependencies Are Installed and Executed at Runtime## Vulnerability Details **File Location**: `send_email.py:9-13` and `send_email.py:50-53` **Vulnerability Type**: Runtime installation of unpinned dependencies **Risk Level**: Medium ### Vulnerable Code ```python try: import requests except ImportError: os.system(f"{sys.executable} -m pip install requests -q") import requests ``` ```python try: from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes # type: ignore except ImportError: os.system(f"{sys.executable} -m pip install cryptography -q") from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes # type: ignore ``` ### Technical Analysis When either dependency is unavailable, the Skill invokes `pip` automatically and installs the latest package version selected by the active package-index configuration. No version constraint, package hash, lockfile, trusted repository restriction, or explicit user approval is applied. Python package installation can execute package build and installation logic. Consequently, runtime dependency installation introduces a mutable remote supply-chain execution path that is not necessary for the Skill's core email-sending operation. Although the package names shown are legitimate, compromise of the package repository, configured index, dependency chain, network path, or selected package release could cause attacker-controlled code to execute. The use of `os.system` does not create a direct command-injection issue here because `sys.executable` is not derived from a command-line argument. The primary issue is automatic installation and execution of unpinned remote dependencies. ### Attack Path 1. The Skill runs in an environment where `requests` or `cryptography` is missing. 2. An attacker compromises a selected package release, a transitive dependency, the configured Python package index, or the package-resolution path. 3. The exception handler automatic ...[truncated 956 chars]
- Remediation
- ## Remediation Suggestions 1. Remove all runtime `pip install` calls from `send_email.py`. 2. Declare dependencies in a dedicated manifest and lock them to reviewed versions. 3. Require hash verification, such as a fully pinned requirements file installed with `pip --require-hashes`. 4. Install dependencies during an explicit, trusted deployment phase rather than during Skill execution. 5. Use an isolated virtual environment with only the packages required by this Skill. 6. Configure a trusted package repository and retain dependency provenance or integrity metadata. 7. If a dependency is unavailable at runtime, terminate with a clear error instead of downloading executable code automatically.
