T09 · Insecure Skill Coding Practices
- Location
scripts/case.py:81- Finding
Stored HTML Injection in Markdown-to-HTML Export
- Content
View full analysis
\1", html, flags=re.MULTILINE) html = re.sub(r"^## (.+)$", r"\1
", html, flags=re.MULTILINE) html = re.sub(r"^# (.+)$", r"\1
", html, flags=re.MULTILINE) lines = html.split("\n") result = [] in_ul = False for line in lines: line = line.strip() if not line: if in_ul: result.append("") in_ul = False continue if line.startswith("") in_ul = False result.append(line) elif line.startswith("-"): if not in_ul: result.append("- ")
in_ul = True
result.append(f"
- {line[1:].strip()} ") else: if in_ul: result.append("
{line}
") if in_ul: result.append("") return "\n".join(result) def export_html(md_path, html_path): with open(md_path, encoding="utf-8") as f: md = f.read() body = md_to_html(md) html = f""" Case Study body {{ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; max-width: 800px; margin: 60px auto; padding: 0 20px; color: #1a1a1a; line-height: 1.8; }} h1 {{ border-bottom: 3px solid #2563eb; padding-bottom: 10px; color: #1e3a8a; }} h2 {{ margin-top: 40px; color: #1e40af; border-left: 4px solid #3b82f6; padding-left: 12px; }} p {{ margin: 12px 0; }} ...[truncated 2082 chars]- Remediation
View remediation
`, event-handler attributes, malformed tags, SVG payloads, and `javascript:` links. 5. Consider applying a restrictive Content Security Policy to generated documents as defense in depth, while not treating it as a replacement for output encoding and sanitization. ]]>
