T08 · Insecure Dependencies
Warning
- Location
- scripts/convert_mermaid.py:96
- Finding
- Unpinned Mermaid CLI Package May Be Downloaded and Executed Through npx<![CDATA[ ## Vulnerability Details **File Location**: `scripts/convert_mermaid.py:96-101` **Vulnerability Type**: Unpinned third-party dependency execution **Risk Level**: Medium ### Vulnerable Code ```python # 尝试使用npx print("尝试使用npx...") cmd[0] = 'npx' cmd.insert(1, '@mermaid-js/mermaid-cli') result = subprocess.run(cmd, capture_output=True, text=True, timeout=30) ``` The same unversioned dependency is recommended in `README.md:17-20` and `SKILL.md:52-55`: ```bash npm install -g @mermaid-js/mermaid-cli # Or use npx npx @mermaid-js/mermaid-cli --version ``` ### Technical Analysis The conversion script falls back to executing `@mermaid-js/mermaid-cli` through `npx` when the initial `mmdc` conversion fails. No exact package version, lockfile, or integrity value constrains the artifact that may be executed. Depending on the local npm cache and npx configuration, npx can retrieve the currently published package and execute its package code. This makes the effective dependency capable of changing after the Skill has been reviewed. The package name is the expected official scoped package, and no evidence indicates that it is currently malicious; the vulnerability is the absence of reproducible dependency pinning and the automatic execution behavior. The subprocess call uses an argument list rather than `shell=True`, so this is not shell-command injection. The risk instead arises from supply-chain trust placed in an unpinned remote package. ### Attack Path 1. An attacker compromises the upstream package, its publisher account, or the relevant package distribution channel. 2. A malicious or compromised release becomes the version resolved by the unversioned package specification. 3. A user follows the documented npx installation command, or an installed `mmdc` returns an error and triggers the script's npx fallback. 4. npx downloads or resolves the unpinned package. 5. Package installation or CLI code executes with the privileges of the user running the Sk ...[truncated 554 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Pin Mermaid CLI to a reviewed exact version, such as `@mermaid-js/mermaid-cli@X.Y.Z`. 2. Add a project-local `package.json` and committed lockfile generated by `npm ci`. 3. Invoke the locally installed locked binary rather than allowing npx to resolve a package dynamically. 4. Remove the automatic npx fallback. If the local binary fails, return an error and require an explicit dependency installation step. 5. Use npm integrity verification and review lockfile changes during dependency updates. 6. Run the renderer under a dedicated, unprivileged account or isolated container to limit the consequences of a compromised dependency. 7. Avoid running dependency installation or diagram conversion as root. ]]>
