T09 · Insecure Skill Coding Practices
- Location
scripts/animate_svg_html.py:92- Finding
Inline Script Injection Through Unsafely Serialized SVG Content
- Content
View full analysis
str: payload = json.dumps(svg_data, ensure_ascii=False, separators=(",", ":")) safe_title = re.sub(r"[<>]", "", title) max_width = max_width_for(svg_data) display_width = display_width_for(max_width) duration_attr = f' data-p2m-duration="{duration_hint}"' if duration_hint else "" indented_css = "\n".join(" " + line if line.strip() else line for line in motion_css.splitlines()) ``` ```html- Remediation
View remediation
", "\\u003e") .replace("&", "\\u0026") .replace("\u2028", "\\u2028") .replace("\u2029", "\\u2029") ) ``` Escaping every `<` is stronger than replacing only `... ``` The JSON must still escape `<` to prevent premature element termination. 3. Validate the parsed SVG against an allowlist of required tags and attributes. Reject active or externally referencing content such as: - `script` - `foreignObject` - Event-handler attributes such as `onload` - `javascript:` URLs - Unexpected external `href` or `xlink:href` values 4. Add regression tests using SVG text containing entity-encoded ``, `
