T08 · Insecure Dependencies
- Location
main.py:9- Finding
Automatic Runtime Installation of an Unpinned Third-Party Dependency
- Content
View full analysis
=1.1.0 ``` ### Technical Analysis When the `docx` module is unavailable, importing or executing `main.py` automatically invokes pip and installs `python-docx`. This changes the environment without an explicit installation or approval step. The package constraint specifies only a minimum version. It does not pin a reviewed release or verify package hashes. Consequently, the package selected at runtime can vary based on the execution date, configured Python package indexes, dependency resolver behavior, and available releases. Python packages may execute code during installation and are imported immediately afterward. If an attacker compromises a configured package index, a permitted package release, or the dependency distribution channel, attacker-controlled code could execute under the account running the Skill. This is a supply-chain weakness rather than evidence that the current `python-docx` package is malicious. ### Attack Path A viable exploitation path requires the dependency to be missing and an attacker to influence the package source or release: 1. ...[truncated 1490 chars]- Remediation
View remediation
``` 3. **Use hash verification** through a lock file or hash-pinned requirements generated by a dependency-management tool: ```text python-docx== \ --hash=sha256: ``` Include verified hashes for all transitive dependencies. 4. **Install dependencies during an explicit deployment or setup phase**, not while handling user requests. Use a dedicated virtual environment or isolated container. 5. **Restrict package sources** to an approved HTTPS index and disable untrusted supplemental indexes. Apply controls through deployment configuration rather than dynamically accepting the host's arbitrary pip configuration. 6. **Perform dependency review and update testing.** Upgrade pinned versions deliberately after vulnerability scanning and integrity verification. 7. **Run the Skill with least privilege** and restrict access to sensitive files, credentials, and network resources to reduce the impact of any future dependency compromise. ]]>
