🇰🇷 한글 설명
phoenixframework의 phoenix_html 라이브러리에서 Phoenix.HTML.attributes_escape/1 함수가 속성 값은 이스케이프하지만 속성 이름(key)은 이스케이프하지 않아 발생하는 XSS 취약점입니다. 공격자가 제어하는 속성 이름으로 HTML에 임의의 속성과 스크립트를 주입할 수 있습니다.
💡 쉬운 설명
웹 페이지에 들어가는 HTML 속성의 이름을 검사하지 않아, 악의적인 사용자가 이름 안에 특수문자를 넣어 스크립트를 몰래 삽입할 수 있습니다. 이를 통해 다른 사용자의 브라우저에서 악성 코드가 실행될 수 있습니다.
🇺🇸 원문 (English)
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') vulnerability in phoenixframework phoenix_html allows an attacker who controls attribute names to inject attributes and script into rendered HTML via Phoenix.HTML.attributes_escape/1.
attributes_escape/1 in lib/phoenix_html.ex escapes attribute values but not attribute names. key_escape/1 passes a binary key through html_escape, which neutralizes quotes and angle brackets but not whitespace, so a key such as x onmouseover ends the attribute and starts a new one. An atom key is only dasherized, so any character passes, including quotes and >. Nested data, aria and phx keys take the same paths. An application is affected when it builds attribute keys from untrusted input and renders them through HEEx <tag {@attrs}>, content_tag/3, or a direct call. Before 3.0.0 the same code lived in Phoenix.HTML.Tag.
This issue affects phoenix_html: from 1.0.0 before 3.3.5 and from 4.0.0 before 4.4.0.
📍 영향받는 시스템
phoenix_html 1.0.0 이상 3.3.5 미만, 4.0.0 이상 4.4.0 미만을 사용하며 신뢰할 수 없는 입력으로 속성 키를 생성해 HEEx, content_tag/3 등으로 렌더링하는 Phoenix 애플리케이션
⚔️ 공격 벡터
사용자 입력이 속성 이름으로 사용되는 경우 'x onmouseover=alert(1)' 같은 키를 전달해 새로운 이벤트 속성을 주입하여 XSS를 실행
🛡️ 대응 방법
phoenix_html을 3.3.5 또는 4.4.0 이상으로 업데이트하고, 속성 이름을 사용자 입력으로부터 직접 생성하지 않도록 허용 목록(allowlist)으로 검증
🔧 검증 코드
출력된 phoenix_html 버전이 1.0.0~3.3.5 미만 또는 4.0.0~4.4.0 미만이면 취약하며, 3.3.5 이상 또는 4.4.0 이상이면 패치된 버전입니다.
mix deps | grep phoenix_html