T08 · Insecure Dependencies
Warning
- Location
- install.sh:17
- Finding
- Unpinned Third-Party Dependency Installation<![CDATA[ ## Vulnerability Details **File Location**: `install.sh:17-18` **Vulnerability Type**: Uncontrolled third-party package version **Risk Level**: Medium ### Vulnerable Code ```bash echo "📦 正在安装 Pillow..." pip install Pillow ``` ### Technical Analysis The installation script retrieves Pillow without pinning an exact, reviewed version or verifying a package integrity hash. Consequently, the installed code depends on whichever release the configured package index resolves at installation time. Although Pillow is a legitimate package, an unpinned installation is not reproducible and unnecessarily exposes users to compromised releases, package-index interference, or an incompatible future version. Python packages and their installation hooks can execute code with the privileges of the user running `pip`. The script checks for `python3` but invokes the standalone `pip` executable. That executable may belong to a different Python installation, causing the dependency to be installed into an unintended environment. ### Attack Path 1. An attacker compromises a future dependency release or interferes with the package source configured for `pip`. 2. A user executes `install.sh`. 3. `pip install Pillow` resolves and downloads the uncontrolled package version from that source. 4. Package installation code executes with the privileges of the user running the installer. 5. The malicious or compromised dependency can access files, environment variables, credentials, and other resources available to that user. ### Impact Assessment Successful exploitation would permit code execution with the installer user's privileges. The affected scope includes that user's files, credentials available in the environment, Python environments, and network access. Running the installer with elevated privileges would increase the impact, although the script does not itself request elevation. ]]>
- Remediation
- <![CDATA[ ## Remediation Suggestions - Pin Pillow to an exact, reviewed version rather than resolving the latest available release. - Store dependencies in a lock file or hashed requirements file. - Require integrity verification during installation, for example: ```bash python3 -m pip install --require-hashes -r requirements.txt ``` - Generate and review package hashes using a trusted dependency-locking workflow rather than manually inserting unverified hashes. - Use `python3 -m pip` so that the package is installed for the same interpreter validated by the script. - Install into an isolated virtual environment and avoid running the installer with administrative privileges. - Regularly review and update the pinned version after security testing. ]]>
