T09 · Insecure Skill Coding Practices
- Location
REFERENCE.md:118- Finding
Unsafe HTML Injection in the Email Body Editor
- Content
View full analysis
' + String.fromCharCode(/* your codepoints */) + ''; if (signEl && signEl.parentNode) { signEl.parentNode.insertBefore(contentDiv, signEl); } else { editorDoc.body.appendChild(contentDiv); } ``` ### Technical Analysis The documented implementation constructs message content using `String.fromCharCode(...)` and assigns the resulting string to `innerHTML`. Character-code encoding only addresses the stated UTF-8 transport problem; it does not escape or sanitize HTML. If the code points are derived from untrusted or insufficiently validated message content, they can decode to arbitrary markup. For example, content containing an active HTML element with an event-handler attribute would be parsed as DOM rather than inserted as plain email text. The newly parsed elements are then attached to the authenticated email editor document through `insertBefore` or `appendChild`. Although script elements inserted through `innerHTML` are commonly non-executing, active elements and event-handler attributes can still create executable behavior when inserted into the document. The vulnerable pattern therefore exposes the authenticated browser context to DOM-based HTML injection. ### Attack Path 1. An attacker supplies crafted text that will be used as email-body content, or induces a user to request insertion of attacker-controlled content. 2. The automation converts that content into character codes using the documented `String.fromCharCode` approach. 3. The generated JavaScript reconstructs the original attacker-controlled string in the browser. 4. The string is concatenated into an HTML fragment and assigned to `contentDiv. ...[truncated 1227 chars]- Remediation
View remediation
