🇰🇷 한글 설명
Mistune 마크다운 파서의 render_toc_ul() 함수에서 사용자 입력 제목으로부터 생성된 앵커 ID와 텍스트를 HTML 이스케이프 없이 직접 포맷 문자열에 삽입하면서 XSS 취약점 발생. 공격자는 악의적인 제목 텍스트를 통해 <script> 태그를 포함한 임의의 HTML을 목차에 주입할 수 있음.
💡 쉬운 설명
Mistune이 마크다운 문서의 제목을 목차로 변환할 때 특수문자를 제대로 검증하지 않아 악성 스크립트를 삽입할 수 있습니다. 공격자는 수상한 제목을 입력해 웹 페이지에 원치 않은 코드를 실행시킬 수 있습니다.
🇺🇸 원문 (English)
Mistune is a Python Markdown parser with renderers and plugins. Prior to 3.2.1, render_toc_ul() builds a <ul> table-of-contents tree from a list of (level, id, text) tuples. Both the id value (used as href="#<id>") and the text value (used as the visible link label) are inserted into <a> tags via a plain Python format string — with no HTML escaping applied to either value. When heading IDs are derived from user-supplied heading text (the standard use-case for readable slug anchors), an attacker can craft a heading whose text breaks out of the href="#..." attribute context, injecting arbitrary HTML tags including <script> blocks directly into the rendered TOC. This vulnerability is fixed in 3.2.1.
📍 영향받는 시스템
Mistune < 3.2.1 (Python 패키지)
⚔️ 공격 벡터
마크다운 문서에서 이스케이프되지 않은 특수문자를 포함한 제목을 입력하면 href 속성 컨텍스트를 벗어나 HTML 태그 주입 가능
🛡️ 대응 방법
Mistune을 3.2.1 이상으로 업그레이드 (pip install --upgrade mistune)
🔧 검증 코드
SAFE가 출력되면 3.2.1 이상으로 패치됨, VULNERABLE이 출력되면 즉시 업그레이드 필요
pip show mistune | grep Version | awk '{print $2}' | awk -F. '{if($1==3 && $2>=2) print "SAFE"; else print "VULNERABLE"}'