GCWing / GCWing/OpenBitFun

[Security]: mermaid SVG output is injected into HTML without sanitization (XSS via label HTML in loose mode)

Ouverte
#2,602 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Rust
Étoiles
2.2k
Forks
229
Merge moyen
2 h 46 min
PR mergées (30 j)
577

Description

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.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
typescript
Domaine
frontend, security, web-dev
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Active
Clarté
Clairement spécifiée
Accessibilité débutants
68/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.