T08 · Insecure Dependencies
- Location
scripts/setup.sh:9- Finding
Unpinned Third-Party Dependency Installation
- Content
View full analysis
Vulnerability Details
File Location:
scripts/setup.sh, lines 9–12
Vulnerability Type: Unpinned and unverified dependency installation
Risk Level: MediumVulnerable Code
bash if ! python3 -c "import requests" 2>/dev/null; then echo "📦 安装 requests..." pip install requests fiTechnical Analysis
The setup script installs
requestswithout a version constraint, lockfile, package hash verification, isolated environment, or explicit package-index policy. It also invokes the ambientpipexecutable rather than binding installation to the checked interpreter withpython3 -m pip.Consequently, the installed package and transitive dependency versions can change over time. Package resolution may also use indexes or mirrors supplied through the invoking user's pip configuration or environment. If such a source is compromised or attacker-controlled, package installation can execute attacker-supplied build or installation logic.
The audit found no evidence that this project intentionally selects a malicious package or package source. The finding concerns the unsafe dependency acquisition process.
Attack Path
- A user runs
scripts/setup.shon a system wherepython3 -c "import requests"fails. - The script invokes the ambient
pip install requestscommand. - Pip resolves the package and its dependencies using uncontrolled version selection and the environment's configured indexes or mirrors.
- A compromised repository, malicious mirror, or manipulated pip configuration supplies an attacker-controlled distribution or dependency.
- Pip downloads and installs that distribution.
- Malicious build or installation code executes with the privileges of the user running the setup script.
Impact Assessment
Successful exploitation could permit arbitrary code execution with the setup user's privileges. This could expose files, credentials, environment variables, and network access available to that user, and could mo ...[truncated 241 chars]
- A user runs
- Remediation
View remediation
Remediation Suggestions
- Declare dependencies in a version-controlled requirements or lock file using audited, exact versions.
- Generate and verify cryptographic hashes for every package and transitive dependency, then install with:
bash python3 -m pip install --require-hashes -r requirements.txt - Use
python3 -m pipinstead of the ambientpipexecutable so the dependency is installed for the same interpreter used by the import check. - Install into an isolated virtual environment rather than modifying a global or unrelated user environment.
- Configure an approved HTTPS package index and prevent unexpected fallback to untrusted indexes or mirrors.
- Use automated dependency scanning and a controlled process for reviewing and updating pinned versions.
