1

I'm working on a CTF where to obtain the flag I need to trigger the admin user of a Flask app to reveal it. The way this has to be done is through a CSRF + XSS chain attack, as the validation script first login on the app, then navigates to my evil server that triggers the CSRF.

The attack chain is required because of a session cookie set as httponly

I'm able to trigger that CSRF by performing a redirect to an unprotected endpoint of the app, the same where an unchecked GET parameter is vulnerable to a reflected XSS as the value is rendered inside HTML.

This is my XSS payload where I redirect the user after CSRF:

http://localhost:80/vulnerable?message=<script>fetch('http://localhost:80/flag',{method:'POST',credentials:'include'}).then(alert('succes'));</script> 

I'm not able to interact with the vulnerable Flask app, I can only see its log.

My issue is that if login (unprivileged account) in the app, then I point my browser to http://my_evil_server:5000 (this is what the validation script visits) navigation is redirected to http://localhost:80/vulnerable, the XSS executed and I could see a POST request to http://localhost:80/flag returning HTTP 302.

On the other side when the same thing is done though the challenge script (automated navigation with Selenium) I see that the CSRF succeed but the fetch() call inside the XSS payload triggers an HTTP 400 Bad Request

What could be the problem in what I'm triyng to do?

3
  • 1
    A JS compatibility issue? I would try to make the XSSes script contact an endpoint on your server, to check that the request is being performed as expected. Unless there's something else in the application. A 400 is BAD REQUEST, meaning one or more validation failed, make sure the app doesn't have specific checks.CommentedMar 11 at 13:50
  • 1
    The same execution, with a slightly modified payload is able to send a POST request to an ncat listening instance used for test. Moreover, i'm able to get the home of the vulnerable app, although that it is a GET endpoint
    – Zanna
    CommentedMar 11 at 14:09
  • 1
    CTF solved, maybe there was in place some protection and I've gone down the rabbit hole too much. Changing the page to fetch was the key
    – Zanna
    CommentedMar 11 at 15:11

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.