T08 · Insecure Dependencies
- Location
scripts/setup.sh:5- Finding
Unpinned Global npm Dependency Installation
- Content
View full analysis
Vulnerability Details
File Location:
scripts/setup.sh:5andscripts/render.py:41
Vulnerability Type: Unpinned third-party dependency installed globally
Risk Level: MediumVulnerable Code
scripts/setup.sh:5:bash echo "For PNG/SVG rendering, install mmdc: npm install -g @mermaid-js/mermaid-cli"scripts/render.py:41:python print(f" Install mmdc: npm install -g @mermaid-js/mermaid-cli")Technical Analysis
The project instructs users to install
@mermaid-js/mermaid-cliglobally without specifying a reviewed version or verifying package integrity. Consequently, npm resolves the mutable version associated with the registry's current default distribution tag.npm packages can execute lifecycle scripts during installation. If the package, one of its transitive dependencies, the selected registry, or the relevant publisher account is compromised, installation could execute attacker-controlled code. Global installation also expands the change scope by placing package executables and files in the user's global Node.js environment.
No evidence indicates that the named package is currently malicious. The vulnerability is the unsafe, non-reproducible dependency installation practice and the resulting exposure to future supply-chain compromise.
Attack Path
- An attacker compromises an upstream package release, transitive dependency, publisher account, or npm distribution channel.
- The attacker publishes a malicious version selected by npm's default distribution tag.
- A user follows the documented
npm install -g @mermaid-js/mermaid-cliinstruction. - npm downloads the mutable package version and its transitive dependencies.
- Malicious lifecycle code executes during installation with the permissions of the user running npm.
- The compromised package may also install a globally accessible executable that runs later when the renderer invokes
mmdc.
Impac
...[truncated 443 chars]
- Remediation
View remediation
Remediation Suggestions
- Pin
@mermaid-js/mermaid-clito a specifically reviewed version rather than relying on the latest distribution tag. - Use a project-local
package.jsonand lockfile with recorded integrity hashes instead of recommending global installation. - Install with a clean, trusted npm registry configuration and verify the lockfile in version control.
- Run the renderer in a container or another restricted environment with minimal filesystem and network access.
- Avoid running npm installation commands with
sudo, administrator rights, or other elevated privileges. - Add an update process that reviews release notes and dependency changes before changing the pinned version.
- Update all documentation and runtime messages so they consistently provide the hardened installation command.
- Pin
