T08 · Insecure Dependencies
- Location
scripts/render_mermaid.py:48- Finding
Automatic Execution of an Unpinned Mermaid CLI Package
- Content
View full analysis
Vulnerability Details
File Location:
scripts/render_mermaid.py, lines 48-57
Vulnerability Type: Unpinned runtime dependency retrieval and execution
Risk Level: MediumVulnerable Code:
python cmd = [ "npx", "-y", "@mermaid-js/mermaid-cli", "-i", mmd_path, "-o", png_path, "-b", "white", "-s", "2", ] + puppeteer_args result = subprocess.run(cmd, capture_output=True, text=True)Technical Analysis
The rendering script invokes
npxwith the-yoption and an unversioned@mermaid-js/mermaid-clipackage name. If the package is not already available locally,npxcan retrieve the currently resolved release from the configured package registry and execute it without interactive confirmation.Because no exact version, lockfile, or integrity hash is specified, the code executed during a future run may differ from the code reviewed during this audit. Although the use of an argument array prevents shell metacharacter injection through the file paths, it does not mitigate package supply-chain risk.
Attack Path
- An attacker compromises the Mermaid CLI package, one of its transitive dependencies, a package maintainer account, or the configured package registry.
- A malicious package version becomes the version resolved by the unpinned package name.
- A user follows the documented workflow and runs
render_mermaid.py. npx -ydownloads and executes the affected package without requesting confirmation.- Malicious package lifecycle or CLI code executes with the permissions and environmental access of the user running the skill.
Impact Assessment
Successful exploitation could provide arbitrary code execution under the account running the script. The resulting access may include reading or modifying documents available to that account, accessing environment variables and credentials exposed to the process, modifying project files, and making network ...[truncated 312 chars]
- Remediation
View remediation
Remediation Suggestions
- Pin Mermaid CLI to an exact, reviewed version, such as
@mermaid-js/mermaid-cli@X.Y.Z. - Install dependencies during a controlled setup phase rather than downloading executable packages at document-rendering time.
- Maintain a lockfile that pins transitive dependencies and verify package integrity metadata.
- Remove
-yso unexpected installation is not silently approved, or fail if the approved local executable is unavailable. - Use a trusted internal package mirror where appropriate.
- Run the renderer in a restricted, rootless container with minimal filesystem mounts, no unnecessary credentials, and network access disabled after dependency installation.
- Establish a deliberate dependency-update process that includes security review and regression testing.
- Pin Mermaid CLI to an exact, reviewed version, such as
