Microservices Revenge
Category: Web
Description
I've upgraded the security of this website and added a new feature. Can you still break it?
- Junhua
Attachments: dist.zip
Write-up
- This challenge appears to be a continuation of the previous Microservices challenge.
- The flag can now only be obtained from the
/flagendpoint of a new microservice atrflagpage. - Unfortunately, direct access to
rflagpageis not possible, and we must go through thegateway. - However, specifying
flagpageas theservicequery parameter to thegatewaywill redirect us to the/constructionendpoint ofrflagpage, as indicated by the specified routes. - We need to identify potential attack vectors that can be exploited to forward our request to
http://rflagpage/flag. - It seems that
http://rhomepage/is vulnerable to Server-Side Template Injection (SSTI), as we can manipulate ourusercookie to render malicious markup content, which is treated as safe HTML input.

- Another attack vector we discovered is SSTI in
http://radminpage/, where we can inject malicious markup content by manipulating theusercookie, as there is no input sanitization before rendering.

- It is more promising to focus on the second attack vector, as we can attempt to leverage SSTI to achieve Server-Side Request Forgery (SSRF). The first attack vector primarily allows us to execute malicious client-side payloads, but it is unlikely to enable us to forward our request to
rflagpage. - Since
radminpageandrflagpageare in the same network, we aim to exploit the second SSTI vulnerability to make a request tohttp://rflagpage/flagviaradminpage, retrieve its content, and then send it to our webhook by appending it. - However, there is a custom Web Application Firewall (WAF) method in the gateway called
is_sus()that checks theservicequery parameter and theusercookie against a list of forbidden words. - To bypass these checks, we can cleverly construct a payload that utilizes Jinja2 filters and additional query parameters.
- By specifying banned strings in the query parameters and utilizing Jinja2 filters in our SSTI payload, we can slowly build our payload by retrieving banned content from our query parameters.
- We can use
subprocess.Popenwhich can be accessed via"".__class__.__subclasses__with SSTI and execute inline Python code usingpython3 -c "<python code>". - The Python code we aim to execute is as follows:
- The following
curlrequest contains the necessary logic to exfiltrate the flag fromhttp://rflagpage/flagand send it to our webhook URL:
Flag: grey{55t1_bl4ck1ist_byp455_t0_S5rf_538ad457e9a85747631b250e834ac12d}