T08 · Insecure Dependencies
Warning
- Location
- scripts/main.py:12
- Finding
- Automatic Installation of an Unpinned Tencent Cloud SDK in the Main Workflow## Vulnerability Details **File Location**: `scripts/main.py`, lines 12-23 **Vulnerability Type**: Unpinned runtime dependency installation **Risk Level**: Medium ```python def ensure_dependencies(): try: import tencentcloud # noqa: F401 except ImportError: print("[INFO] tencentcloud-sdk-python not found. Installing...", file=sys.stderr) subprocess.check_call( [sys.executable, "-m", "pip", "install", "tencentcloud-sdk-python", "-q"], stdout=sys.stderr, stderr=sys.stderr, ) print("[INFO] tencentcloud-sdk-python installed successfully.", file=sys.stderr) ensure_dependencies() ``` ### Technical Analysis The main execution path automatically downloads and installs `tencentcloud-sdk-python` from the package index when the `tencentcloud` module is unavailable. The dependency has no exact version constraint or integrity hash. Consequently, the code executed by the Skill depends on mutable external package-registry content that may change after the Skill has been reviewed. Although the command uses an argument list rather than a shell and is therefore not directly vulnerable to command injection, it creates a supply-chain risk. A compromised upstream release, publisher account, package registry, or transitive dependency could introduce malicious code. The installed SDK is imported immediately afterward, causing malicious module-level code to run in the same process context as the Skill. Installation also modifies the active Python environment automatically and without a separate controlled setup or approval phase. ### Attack Path 1. The Skill runs in an environment where the `tencentcloud` module is not installed. 2. An attacker compromises the relevant package release, publisher account, registry distribution channel, or one of its unpinned transitive dependencies. 3. `ensure_dependencies()` invokes pip and installs the current ...[truncated 1010 chars]
- Remediation
- ## Remediation Suggestions 1. Remove runtime package installation from the executable workflow. 2. Declare an exact, reviewed SDK version in a dependency manifest or lock file, for example: ```text tencentcloud-sdk-python==<reviewed-version> ``` 3. Generate and verify cryptographic hashes for the package and all transitive dependencies. Install with pip's `--require-hashes` option. 4. Install dependencies during a controlled build or deployment stage rather than while processing a user request. 5. Use an isolated virtual environment or immutable container image. 6. If the dependency is missing at runtime, terminate with clear setup instructions instead of automatically modifying the environment. 7. Regularly scan and update the pinned dependency through a reviewed change-management process. 8. Run the Skill with least-privilege credentials and prefer temporary Tencent Cloud tokens with narrowly scoped permissions.
