Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

How can we prevent CSRF attack ?

We can prevent CSRF attack in two ways :

1. User Side Prevention:

  • Browsing Habits: Encourage users to browse one tab at a time, avoiding multiple tabs to reduce the risk of CSRF attacks.
  • Remember-Me Functionality: Suggest users not to use automatic login or “remember-me” features, as these may expose them to CSRF vulnerabilities.

2. Server Side Prevention:

  • CSRF Tokens:
    • What is it? A CSRF token is a unique string tied to a user’s session.
    • How it works: The server generates a token and sends it to the user’s browser, which stores it. The token is also stored on the server.
    • Submission: When a user submits a form or makes a request, the CSRF token must be included.
    • Validation: The server checks if the received token matches the one stored for that user’s session.

Leave a Comment