fix(frontend): sanitize markdown HTML rendering in Text widget#52
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f9c16d1a90
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| marked.use({ | ||
| renderer: { | ||
| html({ text }) { | ||
| return escapeHtml(text) | ||
| }, |
There was a problem hiding this comment.
Register marked renderer only once
Because this is a <script setup> component, marked.use(...) executes every time a Text widget instance is created, but marked is a shared singleton. That means each mount appends another renderer override to global state; on dashboards with many widgets (or repeated mount/unmount cycles), this accumulates unnecessary wrapper chains and can eventually trigger the recursion/performance failure mode documented by Marked for repeated use() calls in component code. Move this to a one-time module initialization (outside per-instance setup) or use an isolated Marked instance.
Useful? React with 👍 / 👎.
Upstream Tracking
Motivation
marked.parse()and injected the result viav-html, which allowed stored XSS when Markdown contains raw HTML and event handlers.localStorage, an attacker who can save a page could execute scripts in other users' sessions.Description
escapeHtml()helper and registered amarkedrendererhtmlhook to escape raw HTML tokens before they are returned by the parser infrontend/src/widgets/Text/Widget.vue.marked.parse+v-html) to preserve formatting while neutralizing embedded HTML payloads.Testing
cd frontend && npm run typecheck, which completed successfully.Codex Task