T09 · Insecure Skill Coding Practices
- Location
scripts/build_radar_feed.py:126- Finding
Stored Cross-Site Scripting Through Unescaped Sample IDs
- Content
View full analysis
", ">") rows_html.append( f"{r.get('id')}{band}{r.get('ops_score')}{r.get('evasion_index')}{preview}" f"" f"" f"" ) ``` ### Technical Analysis The generated dashboard embeds each sample's `id` directly into an HTML document without HTML escaping. Sample IDs originate in suite JSON loaded by `load_suite()` and can therefore be controlled by anyone able to provide or modify the input suite. Although `text_preview` receives limited angle-bracket replacement, the ID receives no encoding at all. An ID containing HTML markup can terminate the existing `` element and inject executable content. For example: ```json { "id": "", "text": "sample", "label": 0 } ``` The resulting dashboard includes the attacker's `- Remediation
View remediation
{sample_id}" f"{band_text}" f"{escape(str(r.get('ops_score')), quote=True)}" f"{escape(str(r.get('evasion_index')), quote=True)}" f"{preview}" ) ``` 2. Prefer a maintained template engine with automatic HTML escaping rather than constructing the document through formatted strings. 3. Validate sample IDs against a restrictive format, such as `^[A-Za-z0-9_.-]{1,128}$`, when arbitrary characters are unnecessary. 4. Add a restrictive Content Security Policy, preferably disallowing inline scripts: ```html ``` 5. Add regression tests containing IDs and text with tags, quotes, ampersands, event handlers, and script payloads. Verify that they appear only as text in the generated document. ]]>
