T08 · Insecure Dependencies
- Location
scripts/web_scraper.py:20- Finding
Unpinned Dependencies Are Installed Automatically at Runtime
- Content
View full analysis
Vulnerability Details
File Location:
scripts/web_scraper.py:20-23
Vulnerability Type: Supply-chain exposure through unpinned runtime package installation
Risk Level: Mediumpython # ── 自动安装依赖 ────────────────────────────────────────────────────────── for pkg in ['websockets', 'openpyxl']: if importlib.util.find_spec(pkg) is None: subprocess.check_call([sys.executable, '-m', 'pip', 'install', pkg, '-q'])The same insecure installation pattern is also presented as recommended behavior in
SKILL.md:127-130.Technical Analysis
When either dependency is unavailable, the script invokes
pipand installs the package using only its unversioned package name. It does not use exact version constraints, integrity hashes, a lock file, a verified package source, or an isolated environment.Consequently, the code installed during a future invocation may differ from the code that existed at audit time. The selected package and its transitive dependencies are determined by the active Python and pip configuration, including any configured package index or mirror. Python packages may execute code during installation or later when imported.
This finding does not establish that
websocketsoropenpyxlis malicious. The vulnerability is the unrestricted and mutable supply-chain trust introduced by automatic installation.Attack Path
- One of the required modules is absent from the Python environment.
- An attacker compromises a selected package release, one of its transitive dependencies, or a package index or mirror configured for pip.
- The user invokes
web_scraper.py. - The script silently executes
python -m pip installfor the unpinned package. - The compromised package is installed and subsequently imported or otherwise executed.
- The malicious package code runs with the same operating-system identity and permissions as the invoking user or agent.
Impact Assessmen
...[truncated 444 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove automatic package installation from the runtime execution path.
- Declare dependencies in a reviewed dependency manifest and lock them to exact versions.
- Require cryptographic hashes for downloaded distributions, such as through a hash-locked requirements file.
- Install dependencies during a separate, explicit setup stage in an isolated virtual environment.
- Use an approved package index and restrict or disable untrusted pip configuration and fallback indexes.
- Audit transitive dependencies and update them through a controlled review process.
- If a dependency is missing at runtime, fail safely with setup instructions rather than silently downloading code.
