T09 · Insecure Skill Coding Practices
- Location
scripts/format.py:1649- Finding
Unsanitized Markdown permits active HTML injection in generated documents
- Content
View full analysis
' f'' f'' ) ``` ```python text = re.sub( r'(?\1', text, ) text = re.sub(r'<(https?://[^\s<>]+)>|<(https?://[^\s<>]+)>', lambda m: f'' f'{m.group(1) or m.group(2)}', text) links: list[str] = [] def _stash_link(m: re.Match) -> str: links.append(m.group(0)) return f"\x00L{len(links) - 1}\x00" text = re.sub(r']*>.*?', _stash_link, text, flags=re.S) text = re.sub(r'(?"\',。、)】」]+)', lambda m: f'{m.group(1)}', text) text = re.sub(r"\x00L(\d+)\x00", lambda m: links[int(m.group(1))], text) text = re.sub(r"\x00C(\d+)\x00", lambda m: code_spans[int(m.group(1))], text) text = re.sub(r"\x00E(\d+)\x00", lambda m: escapes[int(m.group(1))], text) return text ``` The preformatter also explicitly preserves raw HTML tags: ```python _PREFORMAT_PROTECT_PATTERNS = ( re.compile(r"^[ \t]*```[^\n]*\n.*?^[ \t]*```[ \t]*$", re.M | re.S), re.compile(r"`[ ...[truncated 2960 chars]
- Remediation
View remediation
