T08 · Insecure Dependencies
- Location
setup.sh:12- Finding
Unpinned Global npm Dependency Installation
- Content
View full analysis
Vulnerability Details
File Location:
setup.sh, lines 12–16
Vulnerability Type: Unpinned third-party dependency installed globally
Risk Level: MediumVulnerable Code
bash if ! command -v mcporter >/dev/null 2>&1; then echo "mcporter not found. Installing mcporter..." npm install -g mcporter echo "mcporter installed." fiTechnical Analysis
The setup script installs
mcporterfrom the npm registry without specifying an exact version or verifying package integrity. Consequently, every fresh setup resolves whatever release the package registry currently identifies as the latest version rather than the version that was reviewed and tested with this project.npm installation can execute package lifecycle scripts. If the package, one of its transitive dependencies, or its publishing account is compromised, malicious lifecycle code could execute with the permissions of the user running
setup.sh. The-goption also modifies the user's or system's global Node.js environment rather than confining the dependency to the project.Installation takes place before the script validates the required API credentials. Therefore, even an invocation that must later fail because credentials are missing can still install and execute the mutable dependency.
Attack Path
- An attacker compromises the
mcporternpm package, its maintainer account, or a transitive dependency, and publishes a malicious release. - A user without
mcporterinstalled runsbash setup.sh. npm install -g mcporterresolves and downloads the mutable current release.- npm executes any applicable package lifecycle scripts during installation.
- Malicious code runs with the invoking user's privileges and the package is added to the global tool environment.
- The compromised globally installed command may also execute during subsequent
mcporter config addandmcporter listoperations.
Impact Assessment
Successful exploitation could execute ar ...[truncated 570 chars]
- An attacker compromises the
- Remediation
View remediation
Remediation Suggestions
-
Pin
mcporterto an exact audited version rather than resolving the latest release:bash npm install --global --ignore-scripts mcporter@X.Y.ZConfirm first that disabling lifecycle scripts is compatible with the package.
-
Prefer a project-local, lockfile-controlled installation over a global installation. Commit a lockfile containing resolved dependency versions and integrity hashes, then use a reproducible installation command such as
npm ci. -
Verify the package source, maintainer identity, published artifacts, transitive dependency tree, and registry integrity metadata before adoption.
-
Validate API credentials before performing any installation so that failed configuration attempts do not unnecessarily modify the environment:
bash if [ -z "${API_KEY}" ] || [ -z "${API_SECRET}" ]; then echo "Missing API credentials." exit 1 fi -
Require explicit user confirmation before installing or changing global tooling, and document the exact package version that has been security-reviewed.
-
Run setup with ordinary user privileges and avoid
sudoor administrator execution.
-
