T08 · Insecure Dependencies
- Location
scripts/setup_env.py:24- Finding
Automatic Installation of Unpinned Third-Party Dependencies
- Content
View full analysis
Vulnerability Details
File Location:
scripts/setup_env.py:24-47
Vulnerability Type: Unpinned dependency installation and mutable supply-chain execution
Risk Level: MediumVulnerable Code
python REQUIRED_PACKAGES: List[str] = [ "akshare", "pandas", ] def is_package_installed(package: str) -> bool: """Use `python -m pip show` to determine whether a package is installed.""" try: subprocess.check_output( [sys.executable, "-m", "pip", "show", package], stderr=subprocess.DEVNULL, ) return True except subprocess.CalledProcessError: return False def install_package(package: str) -> None: """Install a package through pip associated with the current interpreter.""" print(f"[INFO] Installing dependency: {package} ...") subprocess.check_call([sys.executable, "-m", "pip", "install", package])Technical Analysis
The setup script automatically invokes pip for packages specified only by name. It does not constrain dependency versions, verify package hashes, use a reviewed lockfile, disable installation scripts, or explicitly select a trusted package index.
Consequently, the code installed by the Skill can change without any change to the audited repository. Pip may also resolve and install mutable transitive dependencies. Installation can execute package build backends or setup logic with the privileges of the user running the setup script.
The subprocess call uses an argument list rather than a shell and the package names are hardcoded, so this is not command injection or direct dependency confusion through attacker-controlled package names. Exploitation instead requires compromise of an upstream package or dependency, malicious publication through a configured package index, or manipulation of the user's pip index configuration.
Attack Path
- The user runs `python3 scripts/setup_e ...[truncated 1173 chars]
- Remediation
View remediation
Remediation Suggestions
- Pin every direct dependency to a reviewed version rather than installing by package name alone.
- Generate a lockfile that includes all transitive dependencies.
- Require cryptographic hashes during installation, for example with a hash-locked requirements file and
pip install --require-hashes -r requirements.txt. - Configure an explicitly approved HTTPS package index instead of silently inheriting arbitrary user or environment-level pip index settings.
- Review dependency updates before changing pinned versions, including transitive dependency changes and published artifacts.
- Do not install dependencies automatically without explicit user confirmation. Prefer printing a reproducible installation command or documented environment setup procedure.
- Install dependencies in an isolated virtual environment with only the permissions required for market-data analysis.
- Where operationally feasible, use prebuilt, reviewed wheels and prevent unexpected source builds.
