T08 · Insecure Dependencies
Error
- Location
- scripts/install_and_audit.sh:8
- Finding
- Unpinned Package Retrieval and Execution Through npx<![CDATA[ ## Vulnerability Details **File Location**: `scripts/install_and_audit.sh`, lines 8-19 **Vulnerability Type**: Unpinned third-party package execution **Risk Level**: High ### Vulnerable Code ```bash CLAWHUB_BIN="npx clawhub" if [ -z "$SKILL_NAME" ]; then echo "Uso: $0 <nome-da-skill>" exit 1 fi mkdir -p "$QUARANTINE_DIR" mkdir -p "$AUDIT_REPORT_DIR" echo "Iniciando instalação da skill '$SKILL_NAME' em quarentena..." # Using --dir to specify the installation directory for the skill $CLAWHUB_BIN install "$SKILL_NAME" --dir "$QUARANTINE_DIR" --force ``` The associated documentation also recommends an unpinned installation command in `SKILL.md`, line 52: ```text * **`clawhub` CLI**: Pode ser instalado globalmente via `npm i -g clawhub`. ``` ### Technical Analysis The script invokes `npx clawhub` without specifying an exact package version or validating package integrity. If the package is not already available locally, `npx` may retrieve the current package from the configured npm registry and execute it. Consequently, the code executed during installation is not fully determined by the reviewed project. It can change after the audit due to a legitimate update, registry compromise, maintainer-account compromise, package takeover, or malicious registry configuration. The globally documented `npm i -g clawhub` command has the same version-pinning weakness. The CLI is executed before the downloaded skill is audited. Any malicious behavior in the CLI, its dependencies, or applicable lifecycle behavior therefore occurs before the project’s pattern-based security checks can provide a warning. ### Attack Path 1. An attacker compromises the `clawhub` package, one of its dependencies, its maintainer account, or the package distribution path. 2. The attacker publishes a malicious version under the expected package name. 3. A user runs `scripts/install_and_audit.sh`. 4. `npx clawhub` resolves and downloads the unpinned package version. 5. The packa ...[truncated 917 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Pin `clawhub` to an exact, reviewed version rather than resolving the latest available release. 2. Declare the dependency in a project manifest and commit the corresponding lockfile. 3. Use npm integrity verification and retain verified package hashes in the release process. 4. Install the dependency in a controlled build stage instead of allowing `npx` to retrieve packages during each audit. 5. Invoke the verified local executable directly, for example through a project-local `node_modules/.bin` path. 6. Disable dependency lifecycle scripts where compatible with the required CLI behavior. 7. Use a trusted registry configuration and prevent environment-controlled registry substitution. 8. Run the verified CLI inside a disposable sandbox with no sensitive credentials and minimal network access. 9. Record the exact CLI version and integrity information in every generated audit report. ]]>
