T08 · Insecure Dependencies
Warning
- Location
- scripts/quick-test.sh:19
- Finding
- Automatic Installation and Execution of an Unpinned Global npm Package<![CDATA[ ## Vulnerability Details **File Location**: `scripts/quick-test.sh:19-23`; also documented in `SKILL.md:14-24` **Vulnerability Type**: Unpinned third-party dependency with automatic global installation **Risk Level**: Medium ### Vulnerable Code From `scripts/quick-test.sh:19-23`: ```bash if ! npm ls -g --depth=0 @hackerpl/bailian-cli >/dev/null 2>&1; then npm i -g @hackerpl/bailian-cli fi ``` From `SKILL.md:14-24`: ```bash npm ls -g --depth=0 @hackerpl/bailian-cli ``` ```bash npm i -g @hackerpl/bailian-cli ``` ### Technical Analysis The smoke-test script automatically installs `@hackerpl/bailian-cli` from the npm registry when the package is not already available. No exact version, package integrity hash, lockfile, provenance requirement, or reviewed artifact is specified. As a result, the code installed and subsequently executed can change without any modification to this project. npm installation may execute package lifecycle scripts, and the installed `bailian` command later runs with the invoking user's permissions and environment. Global installation also places the package outside an isolated project dependency tree, increasing its reach and making reproducible review more difficult. The project does not contain evidence that the named package is currently malicious. The risk arises from trusting an unpinned external package and automatically installing it before execution. ### Attack Path 1. An attacker compromises the npm publisher account, package distribution process, or a future package release. 2. The attacker publishes a modified version of `@hackerpl/bailian-cli` containing a malicious lifecycle script or CLI payload. 3. A user runs `scripts/quick-test.sh` on a system where the package is not globally installed. 4. The script executes `npm i -g @hackerpl/bailian-cli` and retrieves the current uncontrolled package version. 5. Malicious lifecycle code may execute during installation, or malicious code executes when the script ...[truncated 893 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Pin the dependency to an exact reviewed version rather than installing the latest available release: ```bash npm install --save-exact @hackerpl/bailian-cli@REVIEWED_VERSION ``` 2. Manage the CLI as a local project dependency with a committed lockfile instead of installing it globally. 3. Use `npm ci` against the committed lockfile to obtain reproducible dependency resolution and integrity verification. 4. Remove automatic installation from the smoke-test script. If the dependency is missing, terminate with clear installation instructions and require explicit user approval before downloading executable code. 5. Review the selected package version, its transitive dependencies, lifecycle scripts, publisher provenance, and registry metadata before adoption. 6. Where supported, verify npm package provenance and use an allowlisted registry. Consider disabling lifecycle scripts during installation unless the reviewed package requires them: ```bash npm ci --ignore-scripts ``` 7. Execute the CLI from an isolated, least-privileged environment with access only to the required API key, input text, network destination, and output directory. 8. Avoid running the installation or TTS script as root or another privileged account. Rotate `BAILIAN_API_KEY` immediately if dependency compromise is suspected. ]]>
