T09 · Insecure Skill Coding Practices
- Location
scripts/lib/report_template.py:195- Finding
Stored HTML Injection in Generated Reports
- Content
View full analysis
报告摘要 · {brand}""" ``` An additional unescaped interpolation occurs in the source-analysis section: ```python if any(any(kw in d.lower() for kw in brand_keywords) for d, _ in top_domains): brand_note = f'* {brand} 品牌官网' ``` ### Technical Analysis The report generator constructs HTML through Python f-string interpolation. The `brand` value originates from the user-controlled `--brand` command-line argument. The `comp_text` value is assembled from competitor names, including names discovered through AI analysis of remote search responses. These values are inserted directly into HTML without passing through the existing `_esc()` escaping function. As a result, HTML metacharacters remain active markup rather than being rendered as text. For example, a malicious brand value containing an HTML element with an event handler could be written directly into `geo_report.html`. The same issue may arise if an external AI response causes a malicious string to be accepted as a discovered competitor name. This is a stored injection because the malicious value is persisted in the generated report and becomes ...[truncated 1250 chars]综合评估: {brand} 跨平台GEO综合得分 {geo_o} 分,{grade_text}。品牌提及率 {mr_pct}%({total_mentioned}/{total_completed} 条回答提及),正面率 100%(无负面评价)。在 {_pct(int(mr_overall*100),100) if mr_overall else 0}% 的有效回答中被主动推荐或提及,整体品牌认知度{'较高' if mr_pct >= 50 else '有待提升'}。
各平台表现:
{platform_html}竞品格局: AI回答中高频出现的竞品包括{comp_text}等,竞争环境较为拥挤。
发力方向: {directions_text}。
- Remediation
View remediation
`, `"`, `'`, event-handler attributes, and closing tags. 5. Apply a restrictive Content Security Policy, preferably disallowing inline scripts and limiting network destinations. 6. Treat AI-derived structured fields as untrusted input even when an agent has converted them into JSON. 7. Apply `_esc(brand)` to the interpolation at line 862 and audit all other template interpolations for consistent contextual encoding. ]]>
