T09 · Insecure Skill Coding Practices
- Location
scripts/generate_report.py:505- Finding
Stored HTML and JavaScript Injection in Generated Reports
- Content
View full analysis
{icon}""" for c in competitors.get("top_competitors", [])[:8]: comp_list_html += f""" {c['name']} {c['distance']}m {c.get('rating', '-')} {c.get('address', '-')} """ ``` Additional unescaped HTML and JavaScript interpolation occurs in the report template: ```python 开店选址分析报告 - {address}{label}{count} 个 密度 {density}/km²{items}{address} — {store_type}选址评估{address}{store_type}竞品分析 — {store_type}
``` The JavaScript-context sink is: ```javascript datasets: [{ label: '{store_type}选址评分', data: [ {scores.get('foot_traffic', 0)}, {scores.get('customer_demographics', 0)}, {scores.get('traffic_pattern', 0)}, {scores.get('spending_power', 0)}, {scores.get('competition', 0)}, {scores.get('environment', 0)} ], ``` ### Technical Analysis The report generator constructs an HTML document through Python f-string interpolation without applying output encoding appropriate to the destination context. The affected values include: - The user-supplied store type. - The user-supplied address or its geocoded represent ...[truncated 2483 chars]- Remediation
View remediation
``` 6. Add regression tests containing HTML metacharacters, closing tags, quotes, and JavaScript breakout sequences in every externally derived field. Verify that the resulting report displays them only as text. ]]>
