T08 · Insecure Dependencies
Warning
- Location
- setup.sh:9
- Finding
- Unpinned Global npm Package Installation## Vulnerability Details **File Location**: `setup.sh`, lines 9–13 **Vulnerability Type**: Unpinned third-party dependency installed globally **Risk Level**: Medium ### Vulnerable Code ```bash # 检查 mcporter if ! command -v mcporter &> /dev/null; then echo "⚠️ 未找到 mcporter,正在安装..." npm install -g mcporter echo "✅ mcporter 安装完成" fi ``` ### Technical Analysis The setup script installs the latest version of the `mcporter` npm package without pinning a reviewed version or verifying package integrity or provenance. Because npm packages may execute lifecycle scripts during installation, the package registry response effectively determines what code runs when the setup script is executed. The `-g` option installs the package globally rather than isolating it within the project. This expands the affected scope and may modify system-wide or user-wide npm binaries and package directories. If the package, publisher account, dependency tree, or configured npm registry is compromised, attacker-controlled code could execute with the privileges of the user running `setup.sh`. ### Attack Path 1. An attacker compromises the `mcporter` package, one of its dependencies, its publisher account, or the npm registry configured on the victim's system. 2. The attacker publishes or serves a malicious version containing an installation lifecycle script or malicious executable. 3. A user follows the documented setup procedure and runs `bash setup.sh` on a system where `mcporter` is not already installed. 4. The command `npm install -g mcporter` resolves the unpinned package to the attacker-controlled version. 5. npm executes the malicious package or its lifecycle scripts with the invoking user's privileges. 6. The payload may inspect the process environment, including `TENCENT_MEETING_TOKEN`, alter the MCP configuration, replace globally available tooling, access user-readable files, or establish persistence where the user's permissions allow it. ### Impact Assessmen ...[truncated 805 chars]
- Remediation
- ## Remediation Suggestions 1. Do not automatically install the package globally from the setup script. Treat `mcporter` as a separately installed prerequisite and fail with clear, trusted installation instructions when it is absent. 2. If automated installation is necessary, pin an exact reviewed version, for example: ```bash npm install --global --ignore-scripts mcporter@<reviewed-exact-version> ``` 3. Confirm that `mcporter` remains functional with `--ignore-scripts`; if lifecycle scripts are genuinely required, audit those scripts and all transitive dependencies before installation. 4. Verify package provenance and integrity using a trusted lockfile, registry policy, package signatures or attestations, and a known integrity digest where supported. 5. Prefer project-local installation over global installation so the dependency is isolated and represented in a committed lockfile. 6. Configure an explicit trusted npm registry and reject unexpected registry overrides in security-sensitive deployment environments. 7. Run setup under a dedicated, least-privileged account. Never run the installation as root or an administrator. 8. Keep `TENCENT_MEETING_TOKEN` out of the environment during dependency installation. Request or load it only after all dependencies have been installed and verified. 9. Document the reviewed package version and establish a controlled update process that includes dependency and lifecycle-script review before upgrading.
