T08 · Insecure Dependencies
- Location
scripts/generate_qr.py:9- Finding
Automatic Installation of an Unpinned Python Dependency
- Content
View full analysis
Vulnerability Details
File Location:
scripts/generate_qr.py, lines 9-17
Vulnerability Type: Unpinned runtime dependency installation
Risk Level: HighVulnerable Code
python def ensure_qrcode(): try: import qrcode return qrcode except ImportError: import subprocess subprocess.check_call([sys.executable, "-m", "pip", "install", "qrcode[pil]", "-q"]) import qrcode return qrcodeThe automatic installation behavior is also explicitly documented in
SKILL.md, lines 56-59:markdown ## Dependencies The script auto-installs `qrcode[pil]` via pip if missing. No manual setup needed.Technical Analysis
When the
qrcodemodule is unavailable, the script invokes pip at runtime to installqrcode[pil]. The dependency has no pinned version, package hash, lockfile, or verified source repository. Pip therefore resolves a mutable package version using the environment's configured package indexes.This creates a supply-chain trust boundary during ordinary skill execution. If the package release, configured package index, DNS/network path, or local pip configuration is compromised, an attacker-controlled distribution could be installed. Python packages can execute code during installation or when imported immediately afterward.
The subprocess call does not use a shell, so the package string itself does not create shell-command injection. The vulnerability is the uncontrolled acquisition and execution of mutable third-party code.
Attack Path
- An attacker compromises the relevant package distribution channel, a configured private package index, or the victim's pip configuration.
- The skill runs in an environment where
qrcodeis not already installed. import qrcoderaisesImportError.- The exception handler invokes pip and resolves
qrcode[pil]without a version or hash constraint. - The malicious o ...[truncated 710 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove automatic package installation from application runtime. If
qrcodeis unavailable, exit with a clear dependency error. - Declare the dependency in controlled project metadata such as
requirements.txtorpyproject.toml. - Pin the package to a reviewed version and lock all transitive dependencies.
- Use hash verification, such as pip's
--require-hashes, for reproducible installations. - Install dependencies during a dedicated build or deployment phase rather than while processing user requests.
- Restrict package indexes to explicitly trusted HTTPS repositories and disable unexpected fallback indexes.
- Run the skill in a least-privileged, isolated environment without unnecessary credentials or filesystem access.
- Remove automatic package installation from application runtime. If
