T08 · Insecure Dependencies
- Location
scripts/upgrade-openclaw.sh:265- Finding
Unpinned npm Package Retrieval and Lifecycle Script Execution
- Content
View full analysis
Vulnerability Details
File Location:
scripts/upgrade-openclaw.sh, lines 265-270
Vulnerability Type: Untrusted supply-chain code execution through an unpinned dependency
Risk Level: HighVulnerable Code
bash if npm install -g openclaw@latest 2>&1; then NPM_INSTALL_OK=true break fi log "npm install 第 $retry 次失败,尝试官方 registry..." if npm install -g openclaw@latest --registry https://registry.npmjs.org 2>&1; then NPM_INSTALL_OK=true break fiThe related compatibility precheck also retrieves a mutable version reference:
bash npm pack openclaw@latest --pack-destination "$TMPDIR" 2>/dev/null || { fail "无法获取 openclaw@latest 包信息" exit 1 }Technical Analysis
The script globally installs
openclaw@latest, a mutable npm distribution tag, without pinning the package to the version inspected during the compatibility precheck. There is no checksum, signature, provenance, publisher identity, or package-content verification before installation.The first installation attempt uses the invoking user's configured npm registry. A malicious or compromised registry configuration can therefore supply an attacker-controlled package. The fallback explicitly uses the public npm registry, but remains exposed to package-maintainer account compromise, malicious publication, or an unauthorized change to the
latesttag.An npm installation may execute package lifecycle scripts such as
preinstall,install, andpostinstall. Consequently, retrieving and installing the package is also a remote code-execution channel. The preliminarynpm packoperation does not securely bind the subsequently installed package to the inspected tarball. Thelatesttag could resolve to a different release between the precheck and installation, creating a time-of-check/time-of-use gap.Attack Path
- An attacker compromises the
openclawnpm publisher, the package ...[truncated 1653 chars]
- An attacker compromises the
- Remediation
View remediation
Remediation Suggestions
- Resolve the intended release once, display the exact version to the user, and require explicit confirmation before making changes.
- Replace every
openclaw@latestreference with the approved exact version, such asopenclaw@1.2.3. - Use an explicitly configured trusted registry for both inspection and installation rather than allowing the first attempt to inherit an arbitrary user registry.
- Download the exact package tarball once and verify its npm integrity digest, trusted signature, or registry provenance before installation.
- Ensure the package inspected for its version and Node.js requirements is the same verified artifact that is installed, eliminating the time-of-check/time-of-use gap.
- Where package compatibility permits, install with
--ignore-scriptsto prevent lifecycle-script execution. If lifecycle scripts are required, inspect or allowlist them and perform installation in a constrained environment. - Run the upgrade under a dedicated, least-privileged service account with access limited to the OpenClaw installation and service resources.
- Retain the backup until post-upgrade validation is complete, and account for changes outside the package directory because restoring
$CURDIRcannot undo actions performed by malicious lifecycle scripts.
