T08 · Insecure Dependencies
- Location
scripts/generate_doc.py:15- Finding
Automatic Installation of an Unpinned Third-Party Dependency
- Content
View full analysis
Vulnerability Details
File Location:
scripts/generate_doc.py, lines 15-23
Vulnerability Type: Supply-chain exposure through runtime dependency installation
Risk Level: MediumVulnerable Code:
python def check_deps(): try: from docx import Document return True except ImportError: print("Installing python-docx...") import subprocess subprocess.check_call([sys.executable, "-m", "pip", "install", "python-docx", "-q"]) return TrueTechnical Analysis
When
python-docxis unavailable, the script automatically invokespipand installs the package without pinning a version or verifying package hashes. The effective dependency version and its transitive dependency graph can therefore change after the Skill has been audited.The installation also inherits the executing environment's pip configuration, including configured package indexes, extra indexes, proxies, and trusted hosts. If an index, package release, transitive dependency, or pip configuration is compromised, installation-time or import-time code can execute with the privileges of the user running the Skill.
The subprocess call uses an argument list and is not vulnerable to shell command injection. The weakness is the uncontrolled and mutable software supply chain.
Attack Path
- The attacker compromises a configured Python package index, publishes a compromised dependency release, or causes the runtime to use an attacker-controlled package source.
- The target environment does not already have an importable
docxmodule. - A user invokes
scripts/generate_doc.py. check_deps()catchesImportErrorand automatically executespip install python-docx.- Pip retrieves and installs the mutable package and its dependencies without version or hash verification.
- Malicious installation-time or import-time code executes under the account running the Skill ...[truncated 472 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove automatic dependency installation from the document-generation path.
- Declare dependencies in a dedicated dependency manifest and install them during an explicit, controlled setup phase.
- Pin
python-docxand all transitive dependencies to reviewed versions. - Use a lockfile or a hash-checked requirements file, such as:
text python-docx==REVIEWED_VERSION --hash=sha256:REVIEWED_HASH - Install from an approved package index and prevent untrusted
extra-index-urlconfiguration in production. - If the dependency is missing, terminate with a clear error instead of modifying the environment:
python def check_deps(): try: import docx except ImportError as exc: raise RuntimeError( "python-docx is required; install the reviewed locked dependencies first" ) from exc - Run dependency installation and document generation in a least-privileged virtual environment or isolated container.
- Add automated dependency vulnerability and integrity scanning to the release process.
