T08 · Insecure Dependencies
Error
- Location
- scripts/mps_auto_upgrade.py:106
- Finding
- Automatic Installation and Upgrade of Unpinned Runtime Dependencies<![CDATA[ ## Vulnerability Details **File Location**: `scripts/mps_auto_upgrade.py:106-119, 131-154`; `scripts/requirements.txt:21-23` **Vulnerability Type**: Runtime supply-chain exposure through mutable dependencies **Risk Level**: High ### Vulnerable Code ```python def _pip_install(specs): """Execute python3 -m pip install to install or upgrade dependencies.""" cmd = [sys.executable, "-m", "pip", "install", "--upgrade", "--quiet"] + specs print(f"Installing or upgrading dependencies: {', '.join(specs)}", file=sys.stderr) result = subprocess.run(cmd, capture_output=True, text=True) if result.returncode != 0: print( f"Automatic installation failed. Run manually:\n" f" python3 -m pip install --upgrade {' '.join(repr(s) for s in specs)}\n" f" Error: {result.stderr.strip()}", file=sys.stderr, ) sys.exit(1) ``` ```python def check_sdk_version(): to_install = [] for pkg_name, min_ver in _DEPENDENCIES: min_ver_str = ".".join(map(str, min_ver)) if min_ver else None spec = f"{pkg_name}>={min_ver_str}" if min_ver_str else pkg_name try: installed_ver = _pkg_version(pkg_name) except PackageNotFoundError: to_install.append(spec) continue if min_ver and _ver_tuple(installed_ver) < min_ver: to_install.append(spec) if to_install: _pip_install(to_install) ``` ```text tencentcloud-sdk-python>=3.1.139 cos-python-sdk-v5>=1.9.30 python-dotenv>=1.0.0 ``` ### Technical Analysis Normal Skill execution calls `check_sdk_version()` before importing the Tencent Cloud, COS, and dotenv libraries. If a package is missing or below the minimum version, the process automatically invokes pip and installs the newest version satisfying an open-ended lower-bound constraint. The dependencies are not pinned to reviewed versions and are not protected with package hashes. Consequently, the ...[truncated 1791 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove dependency installation and upgrades from normal runtime execution. 2. Require dependencies to be installed during an explicit, user-approved setup or deployment stage. 3. Pin every direct and transitive dependency to an exact reviewed version. 4. Generate a lock file containing cryptographic hashes and install with pip's `--require-hashes` option. 5. Use a dedicated virtual environment or immutable container image rather than modifying the Agent's active Python environment. 6. Restrict installation to an explicitly configured trusted package index. 7. Perform dependency vulnerability and provenance scanning during release preparation. 8. If runtime checks remain necessary, make them diagnostic only and terminate with safe installation instructions instead of invoking pip. ]]>
