moai-mermaid-diagram-expert
Audited by Socket on Mar 2, 2026
1 alert found:
Obfuscated FileNo explicit malicious code (reverse shell, credential theft, direct OS-level sabotage) is present in the provided fragment. However, the module dangerously injects untrusted diagram text into a headless browser page that loads Mermaid.js from a remote CDN and sets securityLevel to 'loose'. This combination creates a realistic attack surface: a malicious diagram or a compromised CDN can execute in-page JavaScript, make outbound network requests, and exfiltrate data accessible in the browser context. The code is also malformed/corrupted in places and missing key functions, reducing confidence that safeguards exist. Recommended mitigations: do not render untrusted diagrams with 'loose'; prefer 'strict' or sanitize diagram input; pin or locally host Mermaid runtime (use SRI/pinned version); run Playwright with network disabled or use request interception to block outbound requests; fix the malformed string and complete missing implementations; add explicit tests and clear sandboxing for untrusted content.