T08 · Insecure Dependencies
- Location
scripts/tushare_cli.py:11- Finding
Unpinned Third-Party Dependency Installation Guidance
- Content
View full analysis
Vulnerability Details
File Location:
scripts/tushare_cli.py:11-16
Vulnerability Type: Unpinned third-party dependency
Risk Level: LowVulnerable Code
python # 尝试导入 tushare try: import tushare as ts except ImportError: print("❌ 未安装 tushare,请运行:pip install tushare") sys.exit(1)Technical Analysis
When the
tusharemodule is unavailable, the program instructs users to executepip install tusharewithout specifying a reviewed version, package hash, lock file, or trusted package index. The project also lacks a Python dependency manifest that constrains the package to a known version.The CLI does not automatically execute the installation command, so exploitation requires a user or automation system to follow the displayed guidance. Nevertheless, installing an unconstrained package allows the selected artifact to change over time. A compromised future release, compromised package repository, or manipulated package index could therefore introduce malicious installation or runtime code.
Attack Path
- The CLI is executed in an environment where
tushareis not installed. - The import fails, and the CLI displays the unconstrained
pip install tusharecommand. - A user or deployment process follows that instruction.
pipresolves the dependency from its configured package index without a version or hash constraint.- If the selected package artifact or configured index is compromised, package installation or subsequent import executes attacker-controlled code.
Impact Assessment
Malicious package code would run with the privileges of the user performing the installation or invoking the CLI. Depending on those privileges, it could read accessible files and environment variables, including
TUSHARE_TOKEN, alter user-owned files, establish network connections, or execute arbitrary commands. The scope is limited by the installing user's operating-system perm ...[truncated 59 chars]- The CLI is executed in an environment where
- Remediation
View remediation
Remediation Suggestions
- Declare
tusharein a dedicated dependency manifest and pin it to a reviewed version. - Generate a lock file or hash-verified requirements file, for example using
pip-tools. - Require hashes during deployment with
pip install --require-hashes -r requirements.txt. - Direct users to install dependencies from the reviewed manifest rather than displaying an unconstrained package installation command.
- Use a trusted, explicitly configured package index in automated deployment environments.
- Review and update pinned dependencies through a controlled dependency-update process.
- Avoid installing dependencies with administrator or root privileges.
- Declare
