T09 · Insecure Skill Coding Practices
- Location
assets/index.html:408- Finding
DOM-Based Cross-Site Scripting Through Chat Input
- Content
View full analysis
${text.replace(/\n/g, "`; } else { div.innerHTML = `
")}👤${text}`; } box.appendChild(div); box.scrollTop = box.scrollHeight; } ``` ### Technical Analysis The `appendMsg` function inserts the `text` parameter into an HTML template and assigns the result to `innerHTML`. No HTML escaping, sanitization, or element allowlisting is performed before this assignment. The value originates from the text input or the browser speech-recognition transcript. An attacker-controlled string containing HTML with event handlers can therefore create executable DOM nodes. For example, the following input can execute JavaScript when the browser attempts to load the invalid image: ```html``` Assistant responses are also rendered through `innerHTML`. Several responses incorporate portions of the user's input, such as a navigation destination or search query. Consequently, removing only the vulnerable user-message branch would not fully address the problem. This is DOM-based XSS because the injection and execution occur entirely in client-side JavaScript without requiring a server response. ### Attack Path 1. A user opens `assets/index.html` in a browser. 2. An attacker causes malicious HTML to be entered into the chat field. This could occur through direct input, pasted content, or a transcript produced after the user acti ...[truncated 1310 chars]
- Remediation
View remediation
