Skip to content

fix(visu): prevent stored XSS via SVG icon rendering#45

Open
Micsi wants to merge 1 commit into
mainfrom
codex/propose-fix-for-svg-stored-xss
Open

fix(visu): prevent stored XSS via SVG icon rendering#45
Micsi wants to merge 1 commit into
mainfrom
codex/propose-fix-for-svg-stored-xss

Conversation

@Micsi
Copy link
Copy Markdown
Owner

@Micsi Micsi commented May 17, 2026

Motivation

  • Remove a stored XSS sink introduced by rendering raw SVG content with v-html in the visu icon component while preserving existing icon UX.
  • Provide a minimal frontend-only mitigation so uploaded SVGs are no longer executed in-page without touching the existing icon storage/serving API.

Description

  • Replaced inline HTML insertion (v-html) in frontend/src/components/VisuIcon.vue with image rendering using a Blob URL created from the fetched SVG bytes.
  • Added lifecycle cleanup to revoke the created object URL on reload/unmount via URL.revokeObjectURL to avoid leaking object URLs.
  • Preserved sizing and dark/light color behavior by adapting CSS classes on the <img> and added loading="lazy" and decoding="async" for efficient rendering.
  • This is a targeted frontend change and does not modify server-side icon import/serve behavior.

Testing

  • Ran frontend type checking successfully with cd frontend && npm run typecheck and it completed without errors.

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a571bd191c

ℹ️ 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".

Comment on lines +26 to +30
const svgContent = await getSvg(svgIconName(props.icon))
if (!svgContent) return

const blob = new Blob([svgContent], { type: 'image/svg+xml' })
svgBlobUrl.value = URL.createObjectURL(blob)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Prevent leaked blob URLs from stale async icon loads

load() creates a blob URL after await getSvg(...) without verifying that the request is still current. If icon changes rapidly (or the component unmounts) while an earlier load() is in flight, that stale call can still assign a new URL, and the previously created URL is never revoked because resetBlobUrl() only revokes the current value. This introduces a real memory leak path that did not exist with plain string rendering; add a request/version guard (or cancellation) and revoke URLs from discarded/stale loads.

Useful? React with 👍 / 👎.

Comment on lines +22 to +30
async function load() {
resetBlobUrl()
if (!isSvg.value) return

const svgContent = await getSvg(svgIconName(props.icon))
if (!svgContent) return

const blob = new Blob([svgContent], { type: 'image/svg+xml' })
svgBlobUrl.value = URL.createObjectURL(blob)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Ignore outdated SVG fetch results before assigning src

Because load() is async and updates svgBlobUrl unconditionally after await getSvg(...), a slower earlier request can overwrite a newer icon state. In practice, quickly switching icon (e.g. svg:asvg:b or svg:a → emoji) can render the wrong SVG until another update occurs, since there is no token/check that the resolved content still matches the latest prop value.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant