T08 · Insecure Dependencies
Warning
- Location
- scripts/agents.py:17
- Finding
- Unpinned Python Dependencies Permit Unreviewed Package Versions<![CDATA[ ## Vulnerability Details **File Location**: `scripts/agents.py:17` and `scripts/agents.py:30` **Vulnerability Type**: Unpinned third-party dependencies **Risk Level**: Medium ### Vulnerable Code ```python Install: pip install google-cloud-dialogflow-cx google-auth ``` ```python except ImportError: print("Error: google-cloud-dialogflow-cx not installed") print("Run: pip install google-cloud-dialogflow-cx google-auth") sys.exit(1) ``` ### Technical Analysis The installation instructions request `google-cloud-dialogflow-cx` and `google-auth` without exact version constraints or integrity hashes. Consequently, package resolution selects whatever compatible releases are available from the configured package index at installation time rather than versions that were reviewed with this project. If an upstream release, transitive dependency, or configured package repository is compromised, users following these instructions could install attacker-controlled code. Python packages may execute code during installation and are imported when the script starts, creating both installation-time and runtime execution opportunities. ### Attack Path 1. An attacker compromises a named dependency, one of its transitive dependencies, or a package index used by the victim. 2. The attacker publishes or serves a malicious version that satisfies the unconstrained installation request. 3. A user follows the installation instruction printed or documented by the script: `pip install google-cloud-dialogflow-cx google-auth`. 4. The package manager resolves and installs the malicious or compromised release. 5. Attacker-controlled code executes during package installation or when `agents.py` imports the package. 6. The code runs with the privileges and environment access of the user invoking `pip` or the CLI. This path requires compromise or malicious control of a relevant package distribution channel; the audited repository itself does not contain an embe ...[truncated 479 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Define reviewed, exact dependency versions in a requirements or lock file, for example: ```text google-cloud-dialogflow-cx==REVIEWED_VERSION google-auth==REVIEWED_VERSION ``` 2. Generate and verify cryptographic hashes for all direct and transitive packages, and install with hash enforcement: ```bash python -m pip install --require-hashes -r requirements.txt ``` 3. Replace both unpinned installation instructions in `scripts/agents.py` with a command that installs from the locked dependency file. 4. Use a trusted, explicitly configured package index and prevent fallback to untrusted indexes. 5. Run dependency vulnerability and provenance checks during CI, and update locked versions through a reviewed process. 6. Install dependencies in an isolated virtual environment under a non-privileged account, and avoid exposing cloud credentials during installation. ]]>
