T08 · Insecure Dependencies
- Location
agent.py:8- Finding
Automatic Installation of Unpinned Dependencies at Module Import
- Content
View full analysis
Vulnerability Details
File Location:
agent.py:8-16
Vulnerability Type: Unpinned runtime dependency installation
Risk Level: MediumVulnerable Code
python # 自动安装依赖库(若用户未安装) def install_dependencies(): required_packages = ["qrcode", "pillow"] for package in required_packages: try: __import__(package) # 检查库是否已安装 except ImportError: # 自动安装缺失的库 subprocess.check_call([sys.executable, "-m", "pip", "install", package]) # 初始化:安装依赖库 install_dependencies()The behavior is also explicitly documented in
SKILL.md:36-38:markdown - 未安装依赖库:自动尝试安装 qrcode 和 Pillow,若安装失败,提示用户手动执行“pip install qrcode pillow”;Technical Analysis
Importing
agent.pyinvokesinstall_dependencies()automatically. When a listed import is considered unavailable, the function executespip installusing an unconstrained package name. It does not pin versions, verify package hashes, require a trusted repository, or request user approval.Consequently, package selection depends on the process environment and its configured pip indexes. A compromised index, malicious dependency release, or attacker-controlled package source could cause untrusted package installation or build logic to execute.
There is also an implementation error in the availability check: the distribution named
pillowis normally imported asPIL, notpillow. Calling__import__("pillow")therefore generally raisesImportErroreven when Pillow is installed, causing a pip command to be launched whenever the module is loaded. Conversely, the top-level imports ofqrcodeandPILoccur before this installer runs, so genuinely missing dependencies may prevent the intended recovery mechanism from running at all.Attack Path
- The skill module is loaded by the Agent process.
- Module initialization invokes
install_dependencies(). - A dependency is missing o ...[truncated 1193 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove dependency installation from module import and never modify the runtime environment merely by loading the skill.
- Declare dependencies in a controlled deployment manifest or lockfile and install them before the Agent starts.
- Pin exact reviewed versions of
qrcodeandPillow. - Require package hashes, such as through a hash-locked requirements file and
pip install --require-hashes. - Use an explicitly configured, trusted package repository rather than inheriting arbitrary pip index settings.
- Perform dependency installation in an isolated virtual environment under a low-privilege deployment account.
- If runtime installation is unavoidable, require explicit administrator or user approval and log the package name, version, source, and verified hash.
- Correct dependency checks to inspect the actual import names, particularly
PILfor Pillow. - Move any dependency diagnostics before application imports only as a non-installing check that produces a clear setup error.
