Cross Site Request Forgery(CSRF)

Cross Site Request Forgery(CSRF)


WEB Attack Method CSRF

  Cross-Site Request Forgery (CSRF) is an attack that forces an end user to execute unwanted actions on a web application in which they’re currently authenticated. With a little help of social engineering (such as sending a link via email or chat), an attacker may trick the users of a web application into executing actions of the attacker’s choosing. If the victim is a normal user, a successful CSRF attack can force the user to perform state changing requests like transferring funds, changing their email address, and so forth. If the victim is an administrative account, CSRF can compromise the entire web application.

alt text

Impact of the attacks are;

  • Submitting or deleting a record.
  • Submitting a transaction.
  • Purchasing a product.
  • Changing a password.
  • Sending a message.
  • Make a fund transfer.
  • Depending on the nature of the action, the attacker might be able to gain full control over the user's account
  • EXAMPLE OF CSRF ATTACK

    Let’s considers this vulnerable application that allows users to change their password via a POST request. The original form looks like this:

    alt text

    The attacker can create a copy of this form, changing the password to one known by the attacker (123 in this example): alt text

    Unlike the original form, the attacker’s version does not have a submit button, and has a script that automatically submits the form as soon as the user loads the HTML.

    PREVENTATION

    The most common way to prevent CSRF attack is to include a CSRF token within relevant requests. The token must meet the following criteria:

  • Unpredictable with high entropy, as for session tokens in general.
  • Tied to the user's session.
  • Strictly validated in every case before the relevant action is executed.
  • Also CSRF token should be created randomly using timestamp and transfer it to user in a hidden way

    © 2024