T08 · Insecure Dependencies
Error
- Location
- xtrade_futu_skill.py:56
- Finding
- Automatic Installation of Unpinned Third-Party Dependencies## Vulnerability Details **File Location**: `xtrade_futu_skill.py:56-81`, `requirements.txt:1-2` **Vulnerability Type**: Supply-chain exposure through automatic installation of mutable dependency versions **Risk Level**: High **Vulnerable code (`xtrade_futu_skill.py:56-81`):** ```python def ensure_venv(): if os.environ.get("FUTU_SKILL_VENV") == "1": return base_dir = Path(__file__).resolve().parent venv_dir = base_dir / ".venv" python_path = venv_dir / "bin" / "python" pip_path = venv_dir / "bin" / "pip" if sys.platform.startswith("win"): python_path = venv_dir / "Scripts" / "python.exe" pip_path = venv_dir / "Scripts" / "pip.exe" python_cmd = select_python() if python_path.exists(): venv_version = get_python_version(str(python_path)) if not is_compatible_python(venv_version): shutil.rmtree(venv_dir, ignore_errors=True) if not python_path.exists(): subprocess.check_call([python_cmd, "-m", "venv", str(venv_dir)]) if not pip_path.exists(): raise RuntimeError("虚拟环境创建失败") requirements = base_dir / "requirements.txt" subprocess.check_call([str(pip_path), "install", "-r", str(requirements)]) env = os.environ.copy() env["FUTU_SKILL_VENV"] = "1" subprocess.check_call([str(python_path), str(Path(__file__).resolve()), *sys.argv[1:]], env=env) sys.exit(0) ``` **Mutable dependency declarations (`requirements.txt:1-2`):** ```text futu-api>=1.0.0 akshare>=1.18.0 ``` ### Technical Analysis The Skill automatically invokes `pip install` whenever it starts outside the managed virtual environment. Both dependencies use lower-bound constraints rather than exact, reviewed versions. No lockfile, package hashes, or trusted-index enforcement is present. Consequently, the effective code executed by the Skill can change without any modification to the audited repository. A new ...[truncated 1709 chars]
- Remediation
- ## Remediation Suggestions 1. Pin every direct and transitive dependency to an exact, reviewed version. 2. Generate a reproducible lockfile containing cryptographic hashes for all supported platforms. 3. Install with hash verification, such as `pip install --require-hashes -r requirements.lock`. 4. Configure an explicitly trusted package index instead of silently accepting the user's ambient pip index configuration. 5. Do not run dependency installation on every invocation. Separate installation from normal Skill execution and require explicit user approval before downloading packages. 6. Record and verify the expected dependency manifest before launching the installed interpreter. 7. Add automated dependency vulnerability scanning and controlled update review to the release process. 8. Execute the Skill under a minimally privileged account with a restricted environment so a dependency compromise cannot access unrelated secrets.
