T09 · Insecure Skill Coding Practices
- Location
scripts/dashboard.py:73- Finding
Stored Cross-Site Scripting in Generated Dashboards
- Content
View full analysis
{self.title} ...{self.title}
""" ``` ```python value_str = f"{kpi['prefix']}{kpi['value']}{kpi['suffix']}" html += f"""""" ``` ```python for chart_id, chart_info in self.charts.items(): html += f"""{kpi['title']}{value_str}{change_html}""" ``` ```python for table in self.tables: html += '{chart_info['title']}\n' html += f'{table["title"]}
\n' html += ' \n \n' for col in table['columns']: html += f' \n' html += ' \n' for row in table['data'][:50]: html += ' \n' for col in table['columns']: val = row.get(col, '') html += f' \n' html += ' \n' ``` ```python html += '{col} {val} - Remediation
View remediation
`, `&`, U+2028, and U+2029 before embedding. 5. Prefer a template engine with automatic HTML escaping and explicitly distinguish HTML, attribute, JSON, and JavaScript contexts. 6. Add a restrictive Content Security Policy as defense in depth, avoiding `unsafe-inline` where feasible. 7. Add regression tests using payloads such as: - `` - `` - `');alert(1);//` 8. Verify that generated output displays these strings as text and does not create executable DOM nodes or break JavaScript syntax. ]]>
