T08 · Insecure Dependencies
- Location
scripts/stock_filter.py:10- Finding
Unpinned Third-Party Dependency Installation Guidance
- Content
View full analysis
pd.DataFrame: """根据商品关键词筛选相关上市公司""" try: import akshare as ak except ImportError: print("akshare not installed. Run: pip install akshare") return pd.DataFrame() ``` ### Technical Analysis The script instructs users to install `akshare` directly from pip without specifying an audited version, package hashes, a lockfile, or an explicitly trusted package index. The version ultimately installed therefore depends on the current state and configuration of the Python package registry. Python package installation can execute package-controlled build or installation logic. In addition, importing the installed package executes its module initialization code. If the package distribution, an account used to publish it, the configured package index, or the dependency resolution process is compromised, attacker-controlled code could execute in the user's environment. The exposure is conditional: the project does not itself download or install the package automatically, and no evidence shows that `akshare` is malicious. The risk arises when a user follows the installation instruction without dependency pinning or integrity verification. The dependency is also imported before the predefined stock map is used. Consequently, even operations that only require local hard-coded data unnecessarily depend on the third-party package being installed and imported. ### Attack Path 1. An attacker compromises a package release, publishing account, configured package index, or transitive dependency selected by pip. 2. A user runs `scripts/stock_filter.py` without `akshare` installed. 3. The script displays `pip insta ...[truncated 1035 chars]- Remediation
View remediation
