Vulnerability library
Security checkJanuary 29, 2023

Improper Control of Generation of Code ('Code Injection') in mdx-mermaid

Understand the exposure, see the recommended fix, and check whether your own website has related weaknesses.

Low severitynpmmdx-mermaid

Check your website

Find this and other vulnerabilities with a free scan.

Your scan runs on your computer. No account required.

Description

Arbitary javascript injection

Modify any mermaid code blocks with the following code and the code inside will execute when the component is loaded by MDXjs

The block below shows a valid mermaid code block

mermaid graph TD; A–>B; A–>C; B–>D; C–>D; `

The same block but with the exploit added

mermaid ` + (function () { alert

Recommendation

Update the mdx-mermaid package to the latest compatible version. Followings are version details:

  • Affected version(s): **= 2.0.0-rc1 < 1.3.0**
  • Patched version(s): **2.0.0-rc2 1.3.0**

References

Could your website be exposed too?

SmartScanner can check your website for Improper Control of Generation of Code ('Code Injection') in mdx-mermaid and gives you actionable findings to investigate.

Start a free scan

Related Issues

See something that needs correcting? Let us knowUpdated January 29, 2023