4T$ CTF | My Sky Blog (Web, Golang Template Injection)

Difficulty: Easy

Golang templates include little to no features to allow for file read or RCE but be careful when passing certain variables as they can be accessed and cause damage in some ways.

Our objective in this challenge is to read the flag, one way is to gain access to an admin account and read it from /flag path.

Let's start with reading the code, we have 3 releveant files :

index.go :

sessions.go :

and users.go :

we can see in the index.go that there is a way for SSTI, we can make q username that would inject code into the template through the random messages, we can test that with {{.}}.

we get a bunch of addresses and values, now we see what variables are passed to the template.

the return function in index.go passes the whole session object, we know that we have all the posts stored in the session and since the first post is the one from admin we can change the password of the admin from it and gain access to the app as admin.

we can delete the cookie and create a new user with this username :

now the admin password is test, we can login as that account, access the home page and then get the flag.

Last updated