T08 · Insecure Dependencies
- Location
requirements.txt:1- Finding
Ambiguous and Unpinned Python Dependencies
- Content
View full analysis
Vulnerability Details
File Location:
requirements.txt:1-5
Vulnerability Type: Dependency confusion and unconstrained dependency resolution
Risk Level: MediumVulnerable Code:
text dataclasses docx pdfplumber pypdf2 python-docxTechnical Analysis
The dependency manifest includes both
docxandpython-docx, although theDocumentimport used byscripts/main.pyis supplied bypython-docx. The separatedocxdistribution is unnecessary and creates package-name ambiguity. Thedataclassesbackport is also unnecessary for the documented Python 3.8 or later runtime.In addition, none of the dependencies are pinned to reviewed versions or protected by cryptographic hashes. Consequently, the documented
pip install -r requirements.txtoperation resolves mutable package releases from the configured package index. This exposes installation to dependency confusion, compromised package releases, unexpected upstream changes, and incompatible updates. Python packages may execute build or installation logic during installation, before the application itself is run.Attack Path
- A user follows the installation instructions and runs
pip install -r requirements.txt. - Pip resolves the unnecessary
docxdistribution and the latest available versions of all unconstrained dependencies. - An attacker compromises an upstream release, publishes a malicious package version through an applicable dependency-confusion scenario, or otherwise influences the package index used by the victim.
- Pip downloads the attacker-controlled distribution because the manifest does not constrain its version or verify its hash.
- Malicious build or installation logic executes with the operating-system privileges of the user running pip.
This path requires control or compromise of a resolved package source or release; the reviewed project itself does not contain evidence that the currently available depe ...[truncated 515 chars]
- A user follows the installation instructions and runs
- Remediation
View remediation
Remediation Suggestions
- Remove the unnecessary
docxdependency and retain onlypython-docx, which provides the importeddocxmodule. - Remove
dataclasseswhen Python 3.8 or later is enforced. - Pin every direct and transitive dependency to a reviewed version using a generated lock file.
- Record and verify package hashes, for example by installing with
pip --require-hashes. - Configure pip to use only an approved package index and disable unintended fallback indexes.
- Regularly scan locked dependencies for known vulnerabilities and review updates before regenerating the lock file.
- Perform dependency installation in an isolated virtual environment or build container under a non-privileged account.
- Remove the unnecessary
