[frontend/security] XSS via unescaped innerHTML with user-controlled character names in chat.js #788
Labels
No labels
area:chat
area:core
area:llm
area:routes
area:tools
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
refactor
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
sleepy/odysseus#788
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Finding
chat.jslines 810-814 inject the character name into the DOM viainnerHTMLwithout HTML escaping:getCharacterName()inpresets.jsreturnscustom.character_name— a user-configured string stored in preset settings. If a user sets their character name to<img src=x onerror=alert(1)>, it executes as HTML.Same pattern at line 3026 (string concatenation variant) and line 3828.
Impact
Stored XSS — any user who can create/edit a preset can inject arbitrary JavaScript that executes for anyone viewing chat messages rendered with that character name. In a multi-user deployment, this is a privilege escalation vector.
Evidence
presets.js:874:return custom.character_name || "";— no sanitizationchat.js:814:holder.innerHTML = \...${roleLabel}...`;` — no escapingesc()function exists inui.jsbut is not applied toroleLabelRecommendation
Apply
esc()to roleLabel before inserting into innerHTML, or usetextContentfor the role label element.