T09 · Insecure Skill Coding Practices
- Location
SKILL.md:61- Finding
Markdown-to-HTML Conversion Permits Script Injection
- Content
View full analysis
{m.group(2)}' return k md = re.sub(r'```(\w*)\n(.*?)```', save, md, flags=re.DOTALL) md = re.sub(r'`(.+?)`', r'\1', md) for i in range(4, 0, -1): md = re.sub(rf'^{"#"*i}\s+(.+)$', rf'\1', md, flags=re.M) md = re.sub(r'\*\*(.+?)\*\*', r'\1', md) md = re.sub(r'\*(.+?)\*', r'\1', md) md = re.sub(r'\[(.+?)\]\((.+?)\)', r'\1', md) for k, v in blocks.items(): md = md.replace(k, v) print(f'{md}') ``` ### Technical Analysis The converter builds HTML by directly interpolating attacker-controlled Markdown content. It does not HTML-escape code-block contents, headings, link labels, or other text before inserting them into the output document. Existing raw HTML in the Markdown is also left intact. Markdown link destinations are copied directly into `href` attributes without validating their URI scheme or encoding attribute delimiters. A link such as `[open](javascript:alert(document.domain))` therefore produces a dangerous `javascript:` URL. Raw HTML such as `` can remain executable in the generated page. Code-block content is similarly placed inside `
text ` without escaping HTML metacharacters. An attacker can include closing tags and active HTML to escape the intended code element. ### Attack Path 1. An attacker supplies or modifies a Markdown document processed by the documented converter. 2. The document contains an active HTML payload, a `javascript:` Markdown link, or code-block content that closes the generated `` ...[truncated 873 chars]- Remediation
View remediation
` elements, event attributes, attribute-breaking input, dangerous URI schemes, and code-block escape payloads. ]]>
