T09 · Insecure Skill Coding Practices
- Location
SKILL.md:101- Finding
Unsanitized Email Content Is Inserted into Authenticated Mail Pages as HTML
- Content
View full analysis
{ const bodyField = document.querySelector('[role="textbox"][contenteditable="true"]'); if (bodyField) { bodyField.focus(); bodyField.innerHTML = body.replace(/\n/g, '
'); } }, emailBody) ``` The equivalent Outlook implementation is: ```javascript // Fill body (Outlook) await browser.evaluate((body) => { const bodyField = document.querySelector('[aria-label="Message body"], [role="textbox"]'); if (bodyField) { bodyField.focus(); bodyField.innerHTML = body.replace(/\n/g, '
'); } }, emailBody) ``` The QQ Mail and 163 Mail implementations also write directly into iframe or editor HTML: ```javascript if (bodyField.tagName === 'IFRAME') { bodyField.contentDocument.body.innerHTML = body.replace(/\n/g, '
'); } else { bodyField.innerHTML = body.replace(/\n/g, '
'); } ``` Reply workflows repeat the same pattern: ```javascript await browser.evaluate((body) => { const bodyField = document.querySelector('[role="textbox"][contenteditable="true"]'); if (bodyField) bodyField.innerHTML = body.replace(/\n/g, '
'); }, replyBody) ``` ### Technical Analysis The skill places `emailBody` and `replyBody` into `innerHTML` without escaping or sanitizing the supplied content. Replacing newline characters with `
` does not neutralize HTML elements, event-handler attributes, forms, links, iframes, or remote resources. The sink executes inside an authenticated email-provider page. If an attacker can influence the requested email body, quoted reply material, or other content passed to these variables, crafted markup will be interpreted as HTML rather than displayed st ...[truncated 2114 chars]- Remediation
View remediation
` elements, rather than constructing HTML from the complete body. 3. If rich HTML email is an explicit requirement, process the body with a strict, well-maintained allowlist sanitizer before insertion. 4. Reject scripts, event attributes, forms, iframes, embedded objects, CSS capable of loading remote resources, and dangerous URL schemes. 5. Restrict links and media sources to validated schemes and explicitly approved destinations. 6. Apply the same safe insertion logic consistently to every Gmail, Outlook, QQ Mail, and 163 Mail compose and reply workflow. 7. Add security tests using payloads containing event attributes, remote images, forms, iframes, `javascript:` URLs, and malformed nested markup. ]]>
