T08 · Insecure Dependencies
- Location
scripts/notion_publisher.py:79- Finding
Unpinned Mermaid Package Is Downloaded and Executed at Runtime
- Content
View full analysis
Vulnerability Details
File Location:
scripts/notion_publisher.py:79-86
Vulnerability Type: Runtime execution of an unpinned third-party package
Risk Level: HighVulnerable Code
python result = subprocess.run([ 'npx', '-y', '@mermaid-js/mermaid-cli', '-i', mmd_file, '-o', str(output_file), '-b', 'transparent', '-s', '2' # scale ], capture_output=True, timeout=30, text=True)Technical Analysis
Mermaid rendering invokes
npx -y @mermaid-js/mermaid-cliwithout an exact package version, lockfile, or integrity verification. When the package is unavailable locally,npxcan retrieve the current package release from the configured npm registry and immediately execute it without interactive confirmation.The executable payload can therefore change after the Skill has been reviewed. A compromised package release, npm account, registry, dependency, or local registry configuration could cause arbitrary JavaScript to execute under the identity of the Agent process.
Rendering Mermaid diagrams is necessary for the declared functionality, but downloading and executing a mutable package during normal processing exceeds the minimum safe privilege required. A reviewed and locally installed renderer would provide the same functionality with materially less risk.
Attack Path
- An attacker compromises the Mermaid CLI package, one of its dependencies, its publisher account, or the npm registry resolution path.
- The Agent processes content that invokes
_convert_mermaid_to_image. npx -yresolves and downloads the mutable package version without requesting approval.- Package installation hooks or CLI initialization code execute locally.
- Malicious code inherits the Agent process environment and filesystem permissions.
- The code can access application credentials, modify the blog repository, alter generated content, or initiate additional network connections.
...[truncated 685 chars]
- Remediation
View remediation
Remediation Suggestions
- Install Mermaid CLI during a controlled deployment phase rather than during article processing.
- Pin an exact reviewed version, for example
@mermaid-js/mermaid-cli@X.Y.Z. - Commit and enforce a package lockfile with
npm ci. - Verify registry origin and lockfile integrity in CI.
- Invoke a fixed local executable such as
node_modules/.bin/mmdc; do not use runtimenpx -y. - Disable package lifecycle scripts during installation where compatible, using
npm ci --ignore-scripts. - Run rendering in a sandbox or container without API credentials and with write access limited to the image output directory.
- Apply resource, network, and execution time limits to the renderer.
