T09 · Insecure Skill Coding Practices
- Location
SKILL.md:90- Finding
Unescaped Placeholder Substitution Enables HTML Injection and Script Execution
- Content
View full analysis
content`; otherwise output empty string. 4. **Output** — Save completed HTML as `.html` file and provide the link. ``` Representative affected sinks in `template.html` include: ```html 旅行安全与禁忌 · {place} ``` ```html``` Additional placeholders are inserted directly into list items, table cells, and `div` elements throughout `template.html:222-319`. The optional `{friendly_zone_4_optional}` value is explicitly constructed as raw HTML. ### Technical Analysis The required `place` variable originates from user input. Other values can contain user-influenced or externally researched text. The workflow requires direct placeholder replacement but does not require HTML entity encoding, contextual output escaping, sanitization, or validation. Consequently ...[truncated 2422 chars]旅行安全与禁忌 · {place}
面向普通观光游客 · 时间:{time_of_day} · 出行:{travel_party}
偏好:{pref}模式:合规安全{safety_tip}- Remediation
View remediation
`, `"`, and `'`. - Do not rely on the language model to avoid producing markup. 2. **Separate text values from trusted markup** - Treat `friendly_zone_4` as plain text. - Escape its content first, then construct the surrounding `- ` element in trusted template logic. - Do not allow `{friendly_zone_4_optional}` or any other content variable to carry unrestricted HTML. 3. **Use an auto-escaping template engine** - Render the document through a template system that escapes variables by default. - Permit raw HTML only for fixed, developer-controlled fragments. - Add tests covering closing tags, event-handler attributes, encoded payloads, and malformed markup. 4. **Validate structured fields** - Apply allowlists and length limits to telephone numbers, application names, and destination metadata. - Reject control characters and unexpected markup in fields intended to contain plain text. 5. **Add browser-level defense in depth** - Add a restrictive Content Security Policy, preferably delivered as an HTTP header when the file is hosted. - If only a single HTML file is possible, add an appropriate CSP `meta` element. - Disallow inline scripts and event handlers, and restrict outbound connections to approved destinations. 6. **Update the workflow documentation** - Replace the raw-substitution requirement with explicit instructions that every externally influenced value must be contextually escaped before rendering. - Document that generated or researched content is untrusted even when it was not entered directly by the user. ]]>
