Lot of people talk about implementing CSRF to stop cross site attacks on a webpage. But i think it is pretty easy to compromise CSRF and make requests to a server.
So how it works ?
- You start with a page, render a form and keep a hidden field with CSRF token.
- When form is submitted the other page will expect CSRF token in order to validate the request.
- While validating the request, server will check CSRF token with a secret to see if token is valid.
- Now the secret itself is stored in session or cookie.
Which means if i go to a website, copy the CSRF token from the webpage, and session value from browser network tab. After this i can construct a CURL request, set these values and make as many requests as i can.
So what is the need of CSRF at all ?