T09 · Insecure Skill Coding Practices
- Location
scripts/interactive_charts.py:97- Finding
Stored HTML and JavaScript Injection in Generated Reports
- Content
View full analysis
str: """Wrap a Plotly div in a complete HTML document.""" t = THEMES.get(theme, THEMES["powerbi"]) return f""" {title or 'Chart'} * {{ box-sizing: border-box; margin: 0; padding: 0; }} body {{ font-family: {FONT_FAMILY}; background: {t['paper_bg']}; color: {t['font_color']}; padding: 16px; }} .chart-title {{ font-size: 18px; font-weight: 600; margin-bottom: 12px; color: {t['primary']}; }} .chart-wrap {{ background: {t['bg']}; border-radius: 8px; padding: 16px; box-shadow: 0 2px 8px rgba(0,0,0,.08); }}{('""" ``` Additional unsafe interpolation occurs in KPI cards and dashboard sections: ```python for c in cards: change = c.get("change", "") change_color = "#107C10" if str(change).startswith("+") else "#D83B01" card_html += f"""' + title + '') if title else ''} {plotly_div}""" ``` ```python elif sec["type"] == "insights": sections_html += f'{c['title']}{c['value']}{change}{sec["html"]}' ``` ### Technical Analysis The report generator inserts caller-controlled values directly into HTML without context-aware escaping or sanitization. Affected values inc ...[truncated 2144 chars]- Remediation
View remediation
`, ``, `<object>`, and `<embed>` elements. - Inline event attributes such as `onclick` and `onerror`. - `javascript:` and unsafe `data:` URLs. - Untrusted style content and navigation-capable elements. 5. Keep trusted Plotly-generated fragments separate from arbitrary caller-provided HTML. 6. Add a restrictive Content Security Policy to generated reports, avoiding `unsafe-inline` where possible. 7. Add regression tests using malicious values in every exposed text and HTML field. ]]>
