Secret Notes
Secret notes was an XSS challenge that consisted on a self xss that could be leveraged through csrf, it was also necessary to bypass CSP.
Last updated
Secret notes was an XSS challenge that consisted on a self xss that could be leveraged through csrf, it was also necessary to bypass CSP.
Last updated
The app has two main features, a notepad to which you login to and it links the note to your session, so whenever you login with the same user, you'll see the same note (this may sound obvious but it's kind of the catch here😉).
It's possible to login to the notepad using admin as username and password. Once logged in we receive a CSP header as follows:
Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-eval' cdnjs.cloudflare.com maxcdn.bootstrapcdn.com; style-src maxcdn.bootstrapcdn.com 'self' 'unsafe-inline';
The app won't run simple xss payloads such as <script>alert()</script>, but it does accept anything from cdnjs, that means we could, for example, import angular.js and finaly be able to run javascript. There is an hacktricks article that makes this fairly easy to accomplish.
Running the following payload will pop an alert:
The second feature of the app allows you to input an url to which the admin will browse.
The app also doesn't have any CSRF protections at all. With all the info we've gathered, we could send an url that would take the admin to a CSRF payload that would send a login form to the app using the same credentials we did, so the admin will be redirected to our self xss payload.
We could try exfiltrating cookies with a payload as follows.
We set the location to a server we control and pass the cookies as a get parameter, this is basic data exfiltration via xss. After storing the xss payload in the notepad, we just need to get the admin to login. This can be done serving the following html form generated with burpsuite (Engagement tools > Generate CSRF POC):
Burp suite generates a PoC that requires user interaction, but it can be modded with javascript to run automatically. After sending the CSRF url to the admin, a cookie hits our server.
After decoding the base64 data, we get the flag 😛