T08 · Insecure Dependencies
- Location
scripts/query.py:13- Finding
Automatic Installation of Unpinned Third-Party Packages
- Content
View full analysis
Vulnerability Details
File Location:
scripts/query.py, lines 13–20
Vulnerability Type: Supply-chain exposure through automatic, unpinned dependency installation
Risk Level: MediumComplete Code Snippet:
python def ensure_akshare() -> None: clear_proxy_env() try: import akshare # noqa: F401 except ImportError: print("正在安装依赖 akshare pandas ...", file=sys.stderr) subprocess.check_call( [sys.executable, "-m", "pip", "install", "akshare", "pandas", "-q"] )Related dependency declarations in
requirements.txt, lines 1–2:text akshare>=1.14.0 pandas>=2.0.0Technical Analysis
When
aksharecannot be imported, the script automatically invokes pip to download and installakshareandpandas. This installation does not use the reviewedrequirements.txt, exact version pins, package hashes, a lockfile, or an explicitly trusted package index.The requirements file independently uses open-ended lower bounds, allowing any future compatible version to be selected. Consequently, the code actually executed by the Skill can change after review without changes to this repository.
There is no evidence that the current dependencies are malicious. The issue is the unsafe supply-chain mechanism: a compromised package release, compromised configured package index, dependency confusion condition, or malicious transitive dependency could introduce arbitrary code.
Attack Path
- An attacker compromises a permitted package release, a transitive dependency, or the package index configured for pip.
- The user invokes
scripts/query.pyin an environment whereakshareis absent. ensure_akshare()automatically executespython -m pip install akshare pandas -q.- Pip resolves packages without exact version or hash verification.
- Malicious installation hooks or imported package code execute under the invoking us ...[truncated 709 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove automatic package installation from runtime code. If dependencies are unavailable, exit with a clear setup instruction.
- Install dependencies through a separate, deliberate provisioning step.
- Pin every direct and transitive dependency to a reviewed exact version.
- Use a lockfile or a hash-verified requirements file and install with
pip install --require-hashes. - Configure an explicitly trusted package index or internally controlled package mirror.
- Perform dependency vulnerability and integrity scanning during release and deployment.
- Run the Skill in an isolated virtual environment with least-privilege filesystem and network access.
- Ensure runtime behavior uses the same reviewed dependency manifest rather than independently naming packages.
