T09 · Insecure Skill Coding Practices
- Location
references/report-template.html:271- Finding
Unescaped Dynamic Content in Generated HTML Reports
- Content
View full analysis
{TITLE}
{SUBTITLE}Research Overview
{SOURCE_COUNT}Collected Assets{DIRECTION_COUNT}Design Directions{PLATFORM_COUNT}Platforms CoveredResearch requirement: {REQUIREMENT}
Research scope: {SCOPE}
Keywords: {KEYWORDS}
{REFERENCE_ANALYSIS}- Remediation
View remediation
`, `"`, and `'`. - Do not rely on the language model to perform encoding consistently. 2. **Sanitize intentional HTML** - If placeholders such as `{DIRECTIONS}` must contain markup, process them with a maintained allowlist-based HTML sanitizer. - Permit only necessary structural elements and safe attributes. - Reject scripts, iframes, embedded objects, forms, event-handler attributes, inline executable content, and unsafe SVG or MathML. 3. **Validate URLs** - Parse source and image URLs before inserting them. - Permit only explicitly required schemes, normally `https`. - Reject `javascript:`, `data:`, `file:`, and other unnecessary schemes. - Where practical, restrict URLs to the expected research-platform domains. 4. **Separate data from presentation** - Store research results as structured data. - Render plain text through safe text-node APIs rather than string concatenation. - Use explicit, reviewed rendering functions for galleries, source links, and direction cards. 5. **Add browser-side defense in depth** - Add a restrictive Content Security Policy that disallows inline scripts, plugins, framing, and unapproved network destinations. - Avoid inline event handlers entirely. - Add safe link attributes such as `rel="noopener noreferrer"` to external links opened in new tabs. 6. **Document and test the security boundary** - Update `SKILL.md` to state that user input and harvested content are untrusted. - Add test cases containing HTML tags, event handlers, dangerous URL schemes, malformed attributes, SVG payloads, and closing-tag injection. - Verify that generated reports display these payloads as inert text or remove them safely. ]]>
