T09 · Insecure Skill Coding Practices
- Location
references/report-template.md:377- Finding
Unescaped Dynamic Content in Generated HTML Reports
- Content
View full analysis
{{TITLE}} ``` ```html{{TITLE}}
AI Piano Teacher Report
{{STUDENT_LEVEL}}{{NAV_ITEMS}}{{MODULES}}``` The template's usage rules direct the agent to replace every placeholder with actual content and save the result as an HTML file, but they do not require contextual output encoding or sanitization. ### Technical Analysis The template inserts dynamic values directly into HTML contexts. Values such as `TITLE`, `STUDENT_LEVEL`, repertoire names, assessment content, and other generated module text may be derived from user input. No instruction requires HTML metacharacters to be escaped before substitution. For example, an attacker-controlled title or student-level value containing the following markup could be inserted into the resulting document: ```html``` When the generated report is opened in a browser, the injected event handler may execute. The `NAV_ITEMS` and `MODULES` placeholders present a broader risk because they intentionally accept HTML fragments. These fields cannot be secured through ordinary text es ...[truncated 2005 chars]
- Remediation
View remediation
`, `"`, and `'` in titles, student levels, dates, names, repertoire names, and instructional text. - Apply encoding at the point where each value is inserted rather than relying on input filtering. 2. **Construct HTML fragments from trusted templates** - Do not accept raw user-controlled HTML for `NAV_ITEMS` or `MODULES`. - Generate elements, attributes, and navigation targets from fixed templates. - Insert user-derived values only into encoded text nodes. 3. **Sanitize content when limited markup is required** - Apply a strict allowlist of necessary elements and attributes. - Reject `
