T09 · Insecure Skill Coding Practices
- Location
scripts/detector.py:531- Finding
Stored HTML Injection in Generated Reports
- Content
View full analysis
{ex[:80]}{"..." if len(ex) > 80 else ""}' for ex in cat["examples"][:5] ) ``` ```python # scripts/detector.py:559-561 Detector Report{f' — {filename}' if filename else ''}Phase 0 Detector Report{f' — {filename}' if filename else ''}
``` ```python # scripts/polish.py:642 Polish Report — {filename} ``` ```python # scripts/polish.py:654Polish Report — {filename}
``` ### Technical Analysis The report generators construct HTML with Python formatted strings and insert filenames and detected source-text matches directly into the markup. These values are not passed through an HTML-escaping function. On filesystems that permit HTML metacharacters in filenames, an attacker can create a document whose filename contains elements such as ``, `- Remediation
View remediation
{escape(str(ex[:80]), quote=True)}" for ex in cat["examples"][:5] ) ``` 3. Apply escaping consistently in both `format_report_html()` and `_polish_report_html()`. Do not rely on input validation alone, because valid filenames and document text can contain HTML metacharacters. 4. Consider using a template engine with automatic HTML escaping if report complexity increases. 5. Add regression tests covering filenames, pattern labels, matches, and change descriptions containing: - `
