Skip to content

bug(web-ui): make system message HTML sink safe by default #110

@lidge-jun

Description

@lidge-jun

Summary

addSystemMsg() still injects raw HTML into the DOM via innerHTML, while some call sites pass interpolated Error.message or t() output. A few call sites were hardened, but the sink itself is still unsafe-by-contract.

Current Review Status

  • Partial after the 2026-04-18 pull audit
  • public/js/features/chat.ts now escapes some messages
  • public/js/ui.ts:116-124 still does div.innerHTML = text
  • public/js/features/i18n.ts:46-51 still interpolates raw values via String(v)

Why This Matters

A future call site can easily forget to escape user-controlled text and reopen an XSS / markup-injection path.

Suggested Scope

  • Make addSystemMsg() safe by default
  • Move icon/emphasis rendering to DOM composition or a branded/trusted HTML contract
  • Harden t() interpolation or force escaping at call sites

Evidence

  • public/js/ui.ts:116-124
  • public/js/features/chat.ts:100,102,122,144,381
  • public/js/features/i18n.ts:46-51

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:web-uiWeb UI and frontend behaviorbugSomething isn't workingpriority:P1Next up after stabilization

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions