T08 · Insecure Dependencies
Warning
- Location
- scripts/analyze_financial_report.py:22
- Finding
- Runtime Installation of Unpinned Third-Party Dependencies## Vulnerability Details **File Location**: `scripts/analyze_financial_report.py:22-29`; behavior is also declared in `SKILL.md:55` **Vulnerability Type**: Supply-chain exposure through automatic dependency installation **Risk Level**: Medium ### Vulnerable Code ```python try: import pandas as pd import openpyxl except ImportError: print("正在安装依赖...") import subprocess subprocess.check_call([sys.executable, "-m", "pip", "install", "pandas", "openpyxl"]) import pandas as pd import openpyxl ``` The corresponding Skill documentation states: ```markdown **环境依赖**:脚本会自动检查并安装 `pandas`、`openpyxl`,无需手动安装。 ``` ### Technical Analysis If either dependency import fails, the script automatically invokes `pip` and installs `pandas` and `openpyxl` into the active Python environment. Neither package versions nor distribution hashes are pinned. Package installation can execute package build or installation logic with the same operating-system privileges as the Agent process. The effective source is determined by the environment's `pip` configuration, including configured package indexes, mirrors, proxy behavior, and trusted-host settings. Consequently, a compromised package release, compromised or malicious mirror, or unsafe package-index configuration could cause unreviewed code to execute during an otherwise local financial-report analysis. The command uses an argument list rather than a shell command, so this is not shell-command injection. The risk arises from automatic retrieval and execution of mutable, unpinned third-party components. ### Attack Path 1. The Skill is invoked to analyze an Excel workbook. 2. At least one required module is unavailable or fails to import in the active environment. 3. The exception handler automatically launches `python -m pip install pandas openpyxl`. 4. `pip` resolves the latest acceptable distributions through the environment's configured index or m ...[truncated 1080 chars]
- Remediation
- ## Remediation Suggestions 1. Remove dependency installation from the report-analysis runtime. If imports fail, terminate with a clear setup error rather than modifying the environment. 2. Declare dependencies in a reviewed dependency manifest and lock exact versions. 3. Require package hashes, for example through a hash-locked requirements file and `pip install --require-hashes`. 4. Install dependencies during a separate deployment or setup phase in an isolated virtual environment or container. 5. Use only an explicitly approved package index or internal mirror, with TLS verification enabled. 6. Regularly scan and update locked dependencies through a controlled review process. 7. Run the analysis process with least privilege and without unnecessary network access. A safer runtime pattern is: ```python try: import pandas as pd import openpyxl except ImportError as exc: raise RuntimeError( "Required dependencies are missing. Install the reviewed, locked " "dependencies before running this script." ) from exc ```
