Lab: CSRF where token is not tied to user session
tags: Portswigger Web Security Academy Web
- Description: This lab’s email change functionality is vulnerable to CSRF. It uses tokens to try to prevent CSRF attacks, but they aren’t integrated into the site’s session handling system.
- Goal: To solve the lab, use your exploit server to host an HTML page that uses a CSRF attack to change the viewer’s email address.
You have two accounts on the application that you can use to help design your attack. The credentials are as follows:
wiener:petercarlos:montoya
Background
CSRF token should tied to user session otherwise, it’ll exploited by attacker.
Recon
-
Username:
wiener
Session: l3IjqV4KRDAmncviJTvP80KK3RAHDJLGCSRF Token:u4wMMtIhhUoTlc2LgadJFNRKOZ6bFAZr -
Username:
carlos
Session: Goc2H2lmU9Ki7Of4IcOWpE4XFNMWFslRCSRF Token:UGabdiPPbGaTLsSa8vOV6MfBEvi2nGQ3 -
What if we change session or csrf_token?
It seems work properly which means the user session didn’t tie with unique csrf_token
Exp
The csrf token should be altered to another token that was intercepted by Burp Suite which means this token haven’t sent it. So, we can altered a package to forge another user to achieve CSRF. Exploit Payload:
1 | |

Reference
Lab: CSRF where token is not tied to user session - write up