🇰🇷 한글 설명
leandrocp MDEx에서 Markdown 코드 펜스의 highlight_lines_class info-string 속성 값이 이스케이프 없이 렌더링된 HTML의 class 속성에 삽입되어 저장형 및 반사형 크로스사이트 스크립팅(XSS)이 발생합니다. 신han 여부와 무관하게 공격자가 제출한 Markdown이 다른 사용자 브라우저에서 스크립트로 실행될 수 있습니다.
💡 쉬운 설명
마크다운으로 글을 쓰는 사이트에서 특수하게 작성된 코드 블록을 넣으면, 그 글을 보는 모든 사람의 브라우저에서 악성 스크립트가 실행될 수 있습니다. 로그인 없이도 공격이 가능합니다.
🇺🇸 원문 (English)
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') vulnerability in leandrocp MDEx allows stored or reflected cross-site scripting via attacker-controlled Markdown.
When syntax highlighting and full info-string forwarding (render: [full_info_string: true]) are enabled, the Lumis adapter copies the value of a code fence's highlight_lines_class info-string attribute, unescaped, into the class attribute of every rendered line. comrak_nif::lumis_adapter::LumisAdapter::parse_custom_attributes in native/comrak_nif/src/lumis_adapter.rs shlex-parses the info string and stores each key=value pair verbatim, highlight_lines_config pulls highlight_lines_class into the per-line class value, and write_highlighted interpolates that value directly into the class attribute of the per-line <div>. A single-quoted shell token preserves an inner double quote through shlex parsing, so a value such as '"><script>alert(1)</script>' terminates the class attribute early and the markup that follows is emitted as live HTML.
An attacker who can submit Markdown (through comments, posts, wiki pages, documentation, or any user-generated content) can inject arbitrary HTML and JavaScript that runs in the browser of every user who views the rendered output, enabling session theft, account takeover, and other client-side attacks. No authentication or special privileges are required.
The vulnerable native code originally shipped inside mdex (in native/comrak_nif/src/lumis_adapter.rs) and was later extracted into the separate mdex_native package (native/mdex_native_nif/src/lumis_adapter.rs), where it remains unpatched.
This issue affects mdex from 0.11.3 before 0.12.3, and mdex_native from 0.1.0 before 0.2.3.
📍 영향받는 시스템
mdex 0.11.3 이상 0.12.3 미만, mdex_native 0.1.0 이상 0.2.3 미만 (구문 강조 및 render: [full_info_string: true] 사용 시)
⚔️ 공격 벡터
공격자가 댓글, 게시글, 위키 등 사용자 입력 Markdown에 조작된 highlight_lines_class 값을 포함한 코드 펜스를 삽입하면 해당 내용을 조회하는 사용자에게 스크립트가 실행됩니다.
🛡️ 대응 방법
mdex 0.12.3 이상 또는 mdex_native 0.2.3 이상으로 업그레이드하고, 그 전까지는 full_info_string 옵션을 비활성화하거나 사용자 입력을 신뢰하지 않도록 출력을 HTML 이스케이프 처리합니다.
🔧 검증 코드
출력된 버전이 mdex는 0.12.3 미만(0.11.3 이상), mdex_native는 0.2.3 미만(0.1.0 이상)이면 취약하며, 해당 범위 밖이면 패치된 것입니다.
grep -E 'mdex|mdex_native' mix.lock 2>/dev/null