T09 · Insecure Skill Coding Practices
- Location
scripts/generate_report.py:146- Finding
Stored HTML and JavaScript Injection Through Unescaped Report Data
- Content
View full analysis
{news["summary"]}' if news.get("summary") else "" return f'''{news["rank"]}''' def render_section(section): news_html = "\n".join(render_news_card(n) for n in section["news"]) count = len(section["news"]) return f'''{news["title"]}{news["source"]} {news["time"]} {news["tag"]}{summary_html}{section["icon"]}{section["name"]}{count} 条{news_html}''' def render_stats(stats): cards = "" for s in stats: cards += f'''''' return f'{s["num"]}{s["label"]}{cards}\n' ``` The top-story fields are interpolated in the same unsafe manner: ```python def generate_html(data): top = data["top_story"] sections_html = "\n".join(render_section(s) for s in data["sections"]) stats_html = render_stats(data["stats"]) return f''' ...[truncated 3036 chars]- Remediation
View remediation
"> javascript:alert(1) data:text/html, ``` Tests should verify that markup is rendered as inert text and that unsafe URLs are rejected rather than included in the output. 7. Consider deploying a restrictive Content Security Policy when reports are hosted. This should be treated as defense in depth and not as a replacement for output escaping and URL validation. ]]>
