T08 · Insecure Dependencies
- Location
scripts/generate_excel.py:24- Finding
Automatic Installation of an Unpinned Runtime Dependency
- Content
View full analysis
Vulnerability Details
File Location:
scripts/generate_excel.py, lines 24-32
Vulnerability Type: Supply-chain exposure through automatic dependency installation
Risk Level: HighCode Evidence
python try: import openpyxl from openpyxl.styles import Font, PatternFill, Alignment, Border, Side from openpyxl.utils import get_column_letter except ImportError: print("缺少 openpyxl,正在安装...") import subprocess subprocess.check_call([sys.executable, "-m", "pip", "install", "openpyxl", "-q"]) import openpyxl from openpyxl.styles import Font, PatternFill, Alignment, Border, Side from openpyxl.utils import get_column_letterTechnical Analysis
If
openpyxlcannot be imported, the script automatically invokes pip and installs the package at runtime. The installation does not specify an exact version, verify package hashes, enforce a trusted package index, or require explicit operator approval.Python package installation can execute package-controlled build and installation logic. Consequently, the effective code executed by the Skill is not limited to the reviewed repository. It also depends on whichever package and version the configured pip index returns at execution time.
The risk can become exploitable if:
- The configured package index or package mirror is compromised.
- Local pip configuration redirects requests to an attacker-controlled index.
- DNS, proxy, or repository infrastructure is compromised.
- A future dependency release is malicious or compromised.
- The script is executed in an environment where Python package resolution has been modified.
Attack Path
- An attacker compromises or influences the Python package source used by the execution environment.
- The attacker causes the supplied
openpyxlpackage or one of its dependencies to contain malicious installation or import-time code. - A user invokes Excel generation ...[truncated 952 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove all automatic package installation from runtime application code.
- Declare
openpyxlin a project dependency manifest and lock it to a reviewed version. - Use a lock file or requirements file with cryptographic hashes, for example pip's
--require-hashesoption. - Install dependencies during a controlled deployment or build phase rather than during report generation.
- Configure an approved package repository and prevent untrusted local pip configuration from overriding it.
- If the dependency is unavailable, terminate safely with a clear installation instruction instead of invoking pip automatically.
- Run the script in a least-privileged, network-restricted environment to reduce the impact of a compromised dependency.
- Add dependency vulnerability and provenance checks to the release process.
