T08 · Insecure Dependencies
- Location
README.md:23- Finding
Unpinned Third-Party Dependencies Create a Supply-Chain Risk
- Content
View full analysis
Vulnerability Details
File Location:
README.md:23-24;scripts/portfolio_risk.py:34-42
Vulnerability Type: Unpinned and integrity-unverified package installation
Risk Level: MediumVulnerable Code
README.md:23-24:bash # Install dependencies pip install yfinance numpy pandas scipyscripts/portfolio_risk.py:34-42:python try: import yfinance as yf except ImportError: print("ERROR: yfinance not installed. Run: pip install yfinance numpy pandas scipy") sys.exit(1) try: from scipy import stats except ImportError: print("ERROR: scipy not installed. Run: pip install scipy") sys.exit(1)Technical Analysis
The project instructs users to install third-party packages without exact version constraints, cryptographic hashes, a lockfile, or an isolated environment. Consequently, the code that users install and execute may differ from the dependency versions originally tested or audited.
Python packages can execute code during installation and whenever imported. If a dependency release, maintainer account, package distribution channel, or transitive dependency is compromised, following the documented installation command could introduce attacker-controlled code. Even without malicious interference, unconstrained dependency upgrades may alter APIs or numerical behavior and undermine the integrity of financial calculations.
The package names shown are established packages rather than apparent typosquatting attempts, and no malicious dependency is present in the audited repository. The vulnerability is the absence of version and integrity controls.
Attack Path
- An attacker compromises a listed dependency, one of its transitive dependencies, or its package-publishing account.
- The attacker publishes a malicious version under the legitimate package name.
- A user follows the documented unconstrained
pip installcommand. - Package ...[truncated 703 chars]
- Remediation
View remediation
Remediation Suggestions
-
Add a reviewed dependency manifest with exact versions, such as
requirements.txtorpyproject.tomlwith a generated lockfile. -
Pin direct and transitive dependencies to tested versions.
-
Record cryptographic hashes and install with integrity enforcement, for example:
bash python3 -m pip install --require-hashes -r requirements.txt -
Recommend installation inside a dedicated virtual environment rather than into the system Python environment.
-
Use automated dependency vulnerability and provenance scanning in continuous integration.
-
Review and deliberately update the lockfile instead of resolving unrestricted latest versions during installation.
-
Remove ad hoc installation commands from runtime error messages and direct users to the locked installation procedure.
-
