[Security]: mermaid SVG output is injected into HTML without sanitization (XSS via label HTML in loose mode)
- Lenguaje dominante
- Rust
- Estrellas
- 2.2k
- Forks
- 229
- Merge medio
- 2 h 46 min
- PR fusionados (30 d)
- 577
Descripción
Summary: Mermaid renders with `securityLevel: 'loose'`, which allows raw HTML inside diagram labels to survive rendering. MermaidBlock injects the rendered SVG straight into the DOM via `dangerouslySetInnerHTML` without sanitization, so a crafted diagram can execute script, abuse `on*` handlers, or navigate via `javascript:` URLs in the renderer context.
Area: Web UI
Reproduction or evidence: `src/web-ui/src/component-library/components/Markdown/MermaidBlock.tsx:209` assigns `svgContent` (produced by `MermaidService.renderDiagram`, cache path :59/:95) directly to `dangerouslySetInnerHTML`; no sanitization exists anywhere in the render chain. With `securityLevel: 'loose'`, a mermaid diagram containing `` / `` / `javascript:` href inside a label yields executable markup in the DOM.
Environment: BitFun version/commit 32f2427697ee16f253ee6119860a03255c0b3e47 (origin/main), mermaid ^11.10.1.
Guía de contribución
Línea de trabajo
Start with src/web-ui/src/component-library/components/Markdown/MermaidBlock.tsx, especially lines 59, 95, and 209, then trace MermaidService.renderDiagram and the svgContent cache path. Reproduce with the supplied HTML, script, event-handler, and javascript: label examples. Done means crafted loose-mode labels no longer execute when rendered while normal Mermaid SVG output still works.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- frontend, security, web-dev
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Activo
- Claridad
- Bien especificado
- Aptitud para principiantes
- 68/100