T08 · Insecure Dependencies
- Location
references/cos_api.md:5- Finding
Unpinned Dependency Installation with Forced Upgrade
- Content
View full analysis
Vulnerability Details
File Locations:
references/cos_api.md:5scripts/cos_ops.py:7
Vulnerability Type: Unpinned third-party dependency installation
Risk Level: MediumVulnerable Code
From
references/cos_api.md:3-6:bash ## Installation ```bash pip install -U cos-python-sdk-v5text From `scripts/cos_ops.py:7`: ```python Dependencies: pip install -U cos-python-sdk-v5Technical Analysis
The project instructs users to install
cos-python-sdk-v5with the-Uoption and without an exact version constraint, dependency lock file, or package integrity hash. As a result, installation resolves the latest package version and its transitive dependencies at installation time.The audited project does not contain evidence that this package is currently malicious. However, the mutable installation process creates a supply-chain risk: a future compromised, malicious, or unexpectedly incompatible release could be installed without undergoing the same review as the source code in this project. The forced-upgrade option can also replace a previously reviewed version with a newer unreviewed version.
Python package installation and import may execute package-controlled code. The COS client also operates in a process that has access to
COS_SECRET_ID,COS_SECRET_KEY,COS_REGION, andCOS_BUCKET, making dependency integrity especially important.Attack Path
- An attacker compromises the referenced package, one of its transitive dependencies, or the relevant package publishing account.
- The attacker publishes a malicious release that satisfies the unrestricted dependency request.
- A user follows the documented command:
bash pip install -U cos-python-sdk-v5 pipretrieves and installs the malicious or compromised release instead of a previously reviewed version.- Package-controlled code executes during installation or when
qcloud_cosis imported and used. - The malicious code runs with the pr ...[truncated 956 chars]
- Remediation
View remediation
Remediation Suggestions
-
Replace the unrestricted installation command with an exact, reviewed version:
bash pip install cos-python-sdk-v5==<reviewed-version> -
Remove
-Ufrom normal installation instructions so that installation does not silently replace a reviewed dependency with the latest release. -
Maintain a lock file that pins all transitive dependencies, using a tool such as
pip-tools, Poetry, or an equivalent reproducible dependency-management system. -
Require package hashes during installation. For example, generate a hash-locked requirements file and install it with:
bash pip install --require-hashes -r requirements.txt -
Review dependency changes before updating pinned versions, including release provenance, maintainership changes, transitive dependency changes, and known vulnerability reports.
-
Perform installations in an isolated virtual environment and avoid exposing production COS credentials during dependency installation.
-
Restrict the COS identity according to least privilege, limiting it to required buckets and operations so that a compromised runtime dependency has a reduced impact.
-
