CSRF
Cross-Site Request Forgery (CSRF)
What is CSRF?
- Cross-Site Request Forgery (CSRF) is an attack that focuses an end user to execute harmful actions on web application. The user should be authenticated user. Attacker can trick user to visit attacker’s domain. Then using CSRF attack, attacker can force user to perform state changing requests. For example, change email, bank details
Example :Changing users email
- User loges in to web application (exmple.com) hosted on attacker.com
- User visits attacker’s domain.:Attacker domain(attacker.com)
- The attacker tricks user’s browser into sending request that changes users email in the web application hosted on the domain example.com.
- When the request is sent to the domain example.com, The users authentication cookie appended to the outgoing cross site request .In this way web application knows whose email should be changed.
- Next the request is processed by the web application hosted on the domain example.com.
- Finally, users email changed
Attackers sample code of the page
- <html><body>Hello<script>var xhr = new XMLHttpRequest();xhr.open(“POST”,”https://example.com/profile.jsp”,true);xhr.setRequestHeader(“Content -Type”,”application/x-www-form-urlencoded);xhr.withCredentials = true;var body = email=attacker@example.com & action = Change+email;xhr.send(body);</script></body></html>
References
[1] https://app.pluralsight.com/library/courses/cross-site-forgery-request-web-app/table-of-contents
Comments
Post a Comment