T09 · Insecure Skill Coding Practices
- Location
html-template.md:157- Finding
Unescaped User-Controlled Values in Generated HTML
- Content
View full analysis
🚗 {location} · {days}天租车自驾行前计划
{experience_level_label} · {trip_type_label} · {drivers_label} · {style_preference_label}``` Other direct interpolation locations include: ```html {location} · {days}天租车自驾行前计划 ``` ```html📋 {location} 租车关键注意事项``` The template requires direct placeholder replacement without establishing an output-encoding requirement: ```text - All `{placeholders}` must be replaced with actual content during generation; the final HTML should not contain brace-delimited placeholders. ``` ### Technical Analysis The Skill instructs the agent to place user-derived values, particularly the unrestricted `location` string, directly into an HTML document. It does not require HTML escaping, sanitization, length limits, or rejection of markup before interpolation. If a value containing HTML syntax is copied into the template verbatim, it can terminate the intended text context and introduce attacker-controlled elements. For example, a malicious location value could close the existing element and insert a `- Remediation
View remediation
`, `"`, and `'`. 2. Explicitly prohibit treating user-supplied or generated textual values as raw HTML. 3. Validate `days` as a bounded integer and validate enum fields against their documented allowlists before rendering. 4. Constrain `location` with a reasonable maximum length and reject control characters or markup when markup is not required. 5. Use a templating system with automatic escaping enabled instead of unrestricted textual placeholder replacement. 6. Keep dynamic values in text-node contexts. If values are ever inserted into attributes, URLs, CSS, or JavaScript, apply encoding specific to those contexts. 7. Add tests using payloads such as `
