T09 · Insecure Skill Coding Practices
- Location
scripts/zhihu_prepare.py:30- Finding
Unescaped Markdown Content Produces Unsafe HTML
- Content
View full analysis
{line[4:]}') elif line.startswith('## '): html_lines.append(f'{line[3:]}
') elif line.startswith('# '): html_lines.append(f'{line[2:]}
') # 分隔线 elif re.match(r'^---+$', line): html_lines.append('
') # 空行 elif line == '': html_lines.append('') else: # 行内格式 line = re.sub(r'\*\*(.+?)\*\*', r'\1', line) line = re.sub(r'\*(.+?)\*', r'\1', line) line = re.sub(r'`(.+?)`', r'\1', line) line = re.sub(r'\[(.+?)\]\((.+?)\)', r'\1', line) html_lines.append(f'{line}
') ``` ### Technical Analysis The Markdown converter interpolates user-controlled text directly into HTML elements without applying context-appropriate HTML escaping. This affects heading text, paragraph text, inline formatting content, link labels, and link destinations. For example, the following input remains active markup in the generated `html` field: ```markdown``` The link conversion also places an arbitrary user-controlled value inside an `href` attribute without escaping the attribute or validating its URI scheme: ```markdown [Open link](javascript:alert(document.domain)) ``` This produces: ```html Open link ``` The script serializes the result as JSON and does not itself render or execute it. Exploitation therefore requires a downstream component to insert the generated `html` value into an HTML-capable context without additional sanitization. Becau ...[truncated 1826 chars]
- Remediation
View remediation
[link](javascript:alert(1)) [link](" onmouseover="alert(1)) **** ``` A hardened implementation should ensure these inputs are escaped, rejected, or reduced to safe allowlisted markup. ]]>
