T09 · Insecure Skill Coding Practices
- Location
scripts/generate_report.py:96- Finding
Stored HTML Injection Through the User-Supplied Report Query
- Content
View full analysis
", "ANALYSIS_CONTENT": "", "SCORE_SECTION": "", "PRICE_CONTENT": "", "ADVICE_TITLE": "选购与鉴定建议", "ADVICE_ITEMS": "", "WARNING_ITEMS": "", "CHECKLIST_ITEMS": "", "CERT_SECTION": "", } html = template for key, val in content.items(): html = html.replace("{{" + key + "}}", val) return html ``` The corresponding template sink is: ```html{{HERO_SUBTITLE}}
``` ### Technical Analysis The `--query` command-line argument is treated as untrusted user input. It is assigned to `hero_subtitle` and then inserted directly into an HTML document through raw string replacement. No context-sensitive HTML escaping or sanitization is applied before the value reaches the template. Consequently, HTML metacharacters in the q ...[truncated 1748 chars]- Remediation
View remediation
``` 5. Add regression tests using payloads containing angle brackets, quotation marks, event handlers, script elements, and encoded variants. Verify that each payload is rendered as inert text. 6. Prefer a template engine with automatic escaping enabled rather than manual `str.replace()` interpolation. ]]>
