T09 · Insecure Skill Coding Practices
- Location
assets/template.html:168- Finding
Unsafe Interpolation of Untrusted Podcast Content into Generated HTML
- Content
View full analysis
` for paragraphs, `` for headings, and `
` for quotations | | `{{QUOTES}}` | Quote list, with one `
- ` element per quote | | `{{DATE}}` | Article generation date in `YYYY-MM-DD` format | ``` The corresponding placeholders in `assets/template.html:168-203` are inserted directly into executable HTML contexts: ```html {{TITLE}}
🎙 {{PODCAST_NAME}} · {{EPISODE}}{{TITLE}}
{{SUBTITLE}}
📅 {{DATE}}``` `SKILL.md:73-74` activates this workflow: ```markdown When `webpage` is selected, read `assets/template.html`, fill the article content into the template, output a complete HTML file, and save it as `article.htm ...[truncated 3135 chars]{{LEAD}}{{BODY}} 🎙 来源:{{PODCAST_NAME}} {{EPISODE}} 整理于 {{DATE}}✦ 值得记住的话
-
{{QUOTES}}
- ` element per quote | | `{{DATE}}` | Article generation date in `YYYY-MM-DD` format | ``` The corresponding placeholders in `assets/template.html:168-203` are inserted directly into executable HTML contexts: ```html {{TITLE}}
- Remediation
View remediation
`, `"`, and `'`. - Do not rely on the language model to avoid producing unsafe markup. 2. **Sanitize fields that intentionally contain HTML** - Process `BODY` and `QUOTES` with a mature allowlist-based HTML sanitizer before interpolation. - Permit only the structural elements required by the specification, such as `p`, `h2`, `blockquote`, `cite`, `ul`, `ol`, `li`, `strong`, and `em`. - Remove all event-handler attributes, including attributes beginning with `on`. - Reject `script`, `style`, `iframe`, `object`, `embed`, `form`, `input`, `button`, `meta`, `base`, SVG, and MathML unless a documented requirement and safe sanitizer configuration exist. - Reject dangerous URL schemes such as `javascript:` and unsafe `data:` content. 3. **Generate HTML through a safe rendering layer** - Prefer a template engine that escapes values by default. - Require explicit, reviewed handling only for sanitized HTML fragments. - Avoid raw string replacement as the security boundary. 4. **Add browser-level defense in depth** - Add a restrictive Content Security Policy, for example: ```html ``` - If images are unnecessary, use `img-src 'none'` instead. - Keep external scripts, frames, forms, and network resources disabled. 5. **Clarify the Skill instructions** - State explicitly that podcast transcripts, metadata, summaries, and fetched webpage content are untrusted. - Require escaping and sanitization before saving `article.html`. - Prohibit copying source-provided raw HTML directly into the template. 6. **Add adversarial tests** - Test ...[truncated 293 chars]
