T09 · Insecure Skill Coding Practices
- Location
SKILL.md:92- Finding
Unsanitized User-Influenced Content Is Inserted into Generated HTML Reports
- Content
View full analysis
当前定位 Current Stage``` ```html{{STAGE_NAME}}{{STAGE_DESCRIPTION}}{{DIM1_LABEL}}{{DIM1_SCORE}}/10``` The generated fragments are then inserted directly into the report template: ```html {{ASSESSMENT_SECTION}} ``` ```html {{ACTION_SECTION}} ``` ### Technical Analysis The report-generation workflow places personalized, potentially user-influenced values such as `STAGE_DESCRIPTION`, `ACTION_TITLE`, and `ACTION_DESC` into HTML contexts. It also instructs the Agent to replace `ASSESSMENT_SECTION` and ...[truncated 2543 chars]行动指南 Action Guide-
{{ACTION_TITLE}}{{ACTION_DESC}}
-
- Remediation
View remediation
`, `"`, and `'` before placing user-influenced text into HTML. - Treat stage names, descriptions, dimension labels, and action content as plain text by default. 2. **Separate fixed markup from dynamic data** - Keep all HTML structure in a trusted static template. - Substitute only escaped scalar values rather than generating whole HTML sections from user content. - Do not permit user input to control element names, attributes, or raw fragments. 3. **Sanitize intentionally supported rich text** - If formatting is required, process it with a reputable allowlist-based HTML sanitizer. - Permit only necessary elements such as paragraphs, lists, and basic emphasis. - Remove script-capable elements, inline event handlers, `style` attributes where unnecessary, embedded documents, and dangerous URL schemes such as `javascript:`. 4. **Validate non-text placeholders** - Restrict stage class values to the exact allowlist `passed`, `current`, or an empty string. - Restrict badge and card classes to `current` or an empty string. - Parse scores and percentages as numbers and enforce the expected ranges before rendering. 5. **Apply browser defense in depth** - Add a restrictive Content Security Policy that disallows inline script and remote resources. - Move the template’s inline JavaScript into a fixed local script if scripts must remain enabled. - Avoid granting generated reports access to a privileged application origin. 6. **Add adversarial tests** - Test script elements, broken-tag payloads, SVG event handlers, image error handlers, encoded markup, dangerous links, and malformed numeric or class values. - Verify that every payload is displayed as inert text or removed by sanitization. ]]>
