T08 · Insecure Dependencies
- Location
requirements.txt:1- Finding
Unpinned Third-Party Dependencies Installed Without Integrity Verification
- Content
View full analysis
=4.0.0 # 维基百科搜索(可选) wikipedia>=1.4.0 # HTTP请求 requests>=2.31.0 ``` ### Technical Analysis The installation script invokes `pip` against the environment's configured package index and installs dependencies constrained only by minimum versions. No exact versions, lock file, package hashes, or trusted index are enforced. Constraints such as `duckduckgo-search>=4.0.0` permit any later release selected by the resolver. Consequently, the reviewed source tree does not uniquely determine the code that will be installed. A future compromised release, compromised package index, or malicious package supplied through a misconfigured index could be installed without integrity verification. Python packages may execute build backend or setup logic during installation, and their imported runtime code executes when `web_search.py` loads them. There is no evidence in the reviewed project that the currently published dependencies are malicious; the vulnerability is the absence of dependency provenance and reproducibility controls. ### Attack Path 1. An attacker compromises a permitted future release of one of the listed packages, its distribution account, or a package source configured in the victim's pip environment. 2. The victim runs `install.sh`. 3. `pip install -r requirements.txt` resolves a version satisfying the unrestricted lower-bound constraint. 4. Because no expected artifact hash or exact reviewed version is required, pip accepts and installs the attacker-controlled distribution. 5. Malicious code executes during package installation or later whe ...[truncated 570 chars]- Remediation
View remediation
wikipedia== requests== ``` 2. Generate a lock file containing hashes for all direct and transitive dependencies using a tool such as `pip-tools`. 3. Install with mandatory hash verification: ```bash python3 -m pip install --require-hashes -r requirements.lock ``` 4. Invoke pip through the selected interpreter (`python3 -m pip` or `venv/bin/python -m pip`) rather than relying on whichever `pip` executable appears first in `PATH`. 5. Configure and enforce a trusted package index instead of inheriting arbitrary user or system pip index settings. 6. Run dependency vulnerability and provenance checks in CI, review dependency updates before changing the lock file, and avoid running installation with administrative privileges. ]]>
