T08 · Insecure Dependencies
Warning
- Location
- scripts/setup.sh:16
- Finding
- Unpinned Global Installation of Gemini CLI<![CDATA[ ## Vulnerability Details **File Location**: `scripts/setup.sh`, lines 16-19 **Vulnerability Type**: Unpinned third-party dependency installed globally **Risk Level**: Medium ### Vulnerable Code ```bash info "Checking gemini-cli..." if ! command -v gemini >/dev/null 2>&1; then info "Installing @google/gemini-cli..." npm install -g @google/gemini-cli || fail "Failed to install gemini-cli" fi ``` ### Technical Analysis The setup script installs `@google/gemini-cli` without specifying an exact version or validating package integrity. Consequently, each fresh installation retrieves and installs whichever version is currently associated with the package's default npm distribution tag. Although the package name and namespace are consistent with the declared functionality, the installation is not reproducible and implicitly trusts all future upstream releases. npm package installation can execute lifecycle scripts, and the `-g` option installs the package into a system-wide location. If setup is run with elevated privileges—as may be necessary for later operations that write to `/usr/share`, `/etc`, and `/usr/local/bin`—package lifecycle code may execute with those same privileges. ### Attack Path 1. An upstream package release, maintainer account, or package distribution channel is compromised, or a future release introduces malicious installation behavior. 2. A user runs `scripts/setup.sh` on a fresh system where the `gemini` command is absent. 3. The script resolves the current default version of `@google/gemini-cli` rather than a previously reviewed version. 4. npm downloads the changed package and executes any applicable lifecycle scripts with the privileges of the setup process. 5. Malicious package code can modify files, read accessible credentials, install additional software, or establish persistence within those privileges. ### Impact Assessment Successful exploitation provides code execution with the privileges of the account running ...[truncated 340 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Pin the dependency to an exact, reviewed version, for example: ```bash npm install -g @google/gemini-cli@<reviewed-exact-version> ``` 2. Verify the package archive against an independently maintained integrity hash or approved artifact manifest before installation. 3. Implement a controlled update process that reviews release notes, package contents, dependency changes, and lifecycle scripts before changing the pinned version. 4. Avoid running npm installation as root. Install the CLI into a dedicated unprivileged account or a user-local prefix. 5. Prefer a lockfile-based local installation or a verified, immutable container image over mutable global installation. 6. Disable npm lifecycle scripts where operationally possible and explicitly install only artifacts that do not depend on them. ]]>
