T08 · Insecure Dependencies
Warning
- Location
- scripts/setup.sh:16
- Finding
- Unpinned Global Installation of a Third-Party npm Package<![CDATA[ ## Vulnerability Details **File Location**: `scripts/setup.sh`, lines 16-20 **Vulnerability Type**: Unpinned third-party dependency installed globally **Risk Level**: Medium ### Complete Code Snippet ```bash # Check if QMD is installed if ! command -v qmd &> /dev/null; then echo "📦 Installing QMD..." npm install -g @tobilu/qmd echo "✅ QMD installed" fi ``` ### Technical Analysis The setup script installs `@tobilu/qmd` without specifying an exact version, validating an integrity hash, or using a lockfile. Consequently, npm resolves the mutable package version associated with the registry's current default distribution tag. npm package installation can execute package lifecycle scripts such as `preinstall`, `install`, and `postinstall`. Because the package is installed globally, those scripts execute with the permissions of the user running the skill and can modify files accessible to that user. The script also does not request confirmation immediately before installing the package or verify that npm is using an expected trusted registry. This does not establish that the current QMD package is malicious. The vulnerability is the unsafe dependency acquisition mechanism: future package changes, registry compromise, maintainer-account compromise, or registry configuration manipulation could turn the setup command into a code-execution path. ### Attack Path 1. An attacker compromises the npm package, its publisher account, or the registry configuration used by the victim. 2. The attacker publishes a malicious release or changes the package's default distribution tag. 3. A user without an existing `qmd` executable invokes the skill's setup command. 4. `npm install -g @tobilu/qmd` resolves and downloads the attacker-controlled package version. 5. Malicious package code or lifecycle scripts execute with the invoking user's permissions. 6. The payload can access or modify files available to that user and may alter globally installed Node.j ...[truncated 778 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Pin QMD to an exact, reviewed version: ```bash npm install -g @tobilu/qmd@<audited-version> ``` 2. Record and validate the expected package integrity digest before installation. 3. Verify that npm is configured to use the intended HTTPS registry and reject unexpected registry overrides. 4. Prefer a project-local dependency with a lockfile instead of modifying global Node.js tooling. 5. Disable lifecycle scripts with `--ignore-scripts` if QMD does not require them; otherwise, audit all lifecycle scripts for the pinned release. 6. Prompt for explicit user consent before downloading and executing third-party package code. 7. Run installation and indexing as an unprivileged account, never through `sudo` or a privileged service. 8. Document the exact dependency version and provide a controlled update procedure that reviews new releases before adoption. ]]>
