T09 · Insecure Skill Coding Practices
- Location
scripts/recolor_choropleth.py:34- Finding
Unvalidated style values allow active-content injection into generated SVG files
- Content
View full analysis
' stroke = "#7a7a7a" if rid in region_ids_colors else style["neutral_stroke"] tag = re.sub(r'stroke="[^"]*"', f'stroke="{stroke}"', tag) if 'stroke="' in tag else tag[:-1] + f' stroke="{stroke}">' return tag ``` ```python font = html.escape(style["font_family"]) return f''' {stops} {html.escape(label)} ``` ```python rows.append(f'{html.escape(str(cat))}') ``` ```python extras = f''' {html.escape(args.title)} {html.escape(args.subtitle)} {legend_svg} ''' ``` ### Technical Analysis The `--style` option loads arbitrary JSON and merges every supplied property int ...[truncated 2154 chars]- Remediation
View remediation
` elements - `on*` event-handler attributes - `` elements - Unsafe `href` or `xlink:href` values - Unapproved external-resource references 8. Add regression tests using values containing quotes, angle brackets, event handlers, URLs, and malformed CSS. 9. Document that untrusted SVG and style files must not be processed until sanitization is implemented. ]]>
