open-webui/src/lib/utils
Classic298 bf6325ff33
fix: sanitize mermaid SVG output to prevent stored XSS in file preview (#25219)
renderMermaidDiagram returned raw mermaid SVG, which FilePreview.svelte injects
via wrapper.innerHTML = svg. Mermaid runs with securityLevel: 'loose', so it
neither sanitizes click hrefs (formatUrl skips sanitizeUrl) nor DOMPurifies its
output; a .md file with a click X href "javascript:..." directive (or an
HTML-label payload) therefore executes script in the app origin when previewed.
The chat path was already safe because SVGPanZoom DOMPurifies before rendering;
file preview was not.

Sanitize at the source: renderMermaidDiagram now returns DOMPurify-cleaned SVG
via a shared sanitizeSvg helper (same policy as SVGPanZoom), so every consumer
including the FilePreview innerHTML sink receives safe output.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 14:49:43 -07:00
..
characters fix(frontend): Attempt to resolve TypeError in RichTextInput.svelte 2025-08-03 22:36:08 -04:00
marked refac 2026-04-13 21:52:19 -05:00
transitions feat: custom model selector 2024-03-24 15:28:36 -07:00
_template_old.ts refac: title generation 2024-06-09 14:25:31 -07:00
audio.ts refac 2026-05-09 04:22:46 +09:00
codeHighlight.ts refac 2026-03-06 20:12:37 -06:00
codemirror.ts fix: fix memory leaking in CodeEditor (#22110) 2026-03-01 15:52:20 -05:00
connections.ts refac 2026-03-23 23:39:52 -05:00
csp.ts chore: format 2026-05-11 02:29:13 +09:00
excelToTable.ts refac 2026-03-06 20:12:37 -06:00
google-drive-picker.ts Fix formatting 2024-12-16 15:11:05 -05:00
hash.ts refac: kb sync 2026-05-20 01:13:52 +04:00
index.ts fix: sanitize mermaid SVG output to prevent stored XSS in file preview (#25219) 2026-05-31 14:49:43 -07:00
onedrive-file-picker.ts refac 2026-04-12 19:13:13 -05:00
pptxToHtml.ts refac 2026-03-06 20:12:37 -06:00
safeImageUrl.ts fix:image url validation and signout post (#24420) 2026-05-09 07:33:31 +09:00
text-scale.ts refac: rm ai slop 2025-11-19 03:51:10 -05:00