T09 · Insecure Skill Coding Practices
- Location
scripts/quick_hook.py:228- Finding
Stored HTML Injection in Generated Reports
- Content
View full analysis
{label}" ``` `scripts/quick_hook.py`, lines 318-332: ```python fatal_text = ( f'⚠️ For queries related to "{kw}", ' f'{brand} achieves only a ' f'{brand_score}% average top-3 visibility rate across 5 AI engines, ' f'while the industry average is already {industry_avg}% (current rank: #{brand_rank})' f'{citation_hook}' ) cards_html += f'''🔍 "{kw}" · AI Top-3 Visibility Competitive Analysis (5 Engines){table_html} ``` `scripts/quick_hook.py`, lines 361-378: ```python return f''' GEO Quick Hook · {brand} * {{ box-sizing:border-box; margin:0; padding:0; }} bod ...[truncated 2992 chars]- Remediation
View remediation
{safe_label}" ) ``` 3. Escape all brand, competitor, keyword, engine, and citation strings used in: - Element text - The document title - Table cells - Warning messages - Dynamically generated labels 4. Prefer a maintained template engine configured with automatic HTML escaping rather than assembling the document with f-strings. 5. Add conservative input limits for brand names, competitors, and keywords. Reject control characters and unexpectedly long inputs. Character restrictions may provide defense in depth but must not replace output encoding. 6. Add regression tests using payloads containing tags, quotes, ampersands, and event handlers. Verify that generated reports contain encoded text such as `<` and do not create executable DOM elements. 7. Consider using a dedicated, isolated browser profile for untrusted generated reports and avoid exposing unrelated files through the same local HTTP server directory. ]]>
