T08 · Insecure Dependencies
- Location
scripts/install-cli.sh:164- Finding
Automatic Installation and Execution of an Unpinned npm Package
- Content
View full analysis
Vulnerability Details
File Location:
scripts/install-cli.sh:164-183,scripts/install-cli.sh:195-211, andscripts/install-cli.sh:216-223
Vulnerability Type: Unpinned third-party dependency installed from a mutable package reference
Risk Level: HighComplete Code Snippet
bash if command -v linkedclaw >/dev/null 2>&1; then cur=$(current_version) if [ -n "$cur" ] && version_ge "$cur" "$MIN_VERSION"; then latest=$(latest_version) if [ -z "$latest" ] || version_ge "$cur" "$latest"; then emit_installed "already-installed" "" exit 0 fi # A newer version exists — upgrade in place. upd_out=$(npm install -g @linkedclaw/cli@latest 2>&1) if [ $? -eq 0 ]; then hash -r 2>/dev/null || true new=$(current_version) if [ -n "$new" ] && version_ge "$new" "$latest"; then emit_installed "updated" "\"from\": \"$cur\"" exit 0 fi fi emit_installed "already-installed" \ "\"update_skipped\": \"newer version $latest available but in-place upgrade did not take effect\"" exit 0 fi fi npm_out=$(npm install -g @linkedclaw/cli@latest 2>&1) npm_status=$? if [ "$npm_status" -eq 0 ] && command -v linkedclaw >/dev/null 2>&1; then if post_install_check "global" ""; then exit 0; else exit 1; fi fi NPM_GLOBAL_DIR="$HOME/.npm-global" mkdir -p "$NPM_GLOBAL_DIR" npm_out=$(npm install --prefix "$NPM_GLOBAL_DIR" -g @linkedclaw/cli@latest 2>&1) npm_status=$? export PATH="$NPM_GLOBAL_DIR/bin:$PATH" if [ "${ALLOW_SUDO:-0}" = "1" ] && command -v sudo >/dev/null 2>&1; then npm_out=$(sudo -n npm install -g @linkedclaw/cli@latest 2>&1) npm_status=$? if [ "$npm_status" -eq 0 ] && command -v linkedclaw >/dev/null 2>&1; then if post_install_check "sudo" ""; then exit 0; else exit 1 ...[truncated 1947 chars]- Remediation
View remediation
Remediation Suggestions
- Pin the CLI to an exact audited version, such as
@linkedclaw/cli@0.2.6, rather than using@latest. - Verify the package tarball against a trusted integrity hash or signed release metadata before installation.
- Remove automatic upgrades of already usable installations. Present an available update to the user and require explicit approval.
- Prefer a project-local installation governed by a committed lockfile instead of a global installation.
- Remove the sudo installation branch. If privileged installation is unavoidable, require a separate explicit administrative action outside the agent workflow.
- Disable or tightly control npm lifecycle scripts where operationally possible.
- Audit the exact CLI release before changing the pinned version.
- Pin the CLI to an exact audited version, such as
