• Latest
  • Trending
How to Protect Your Web Apps Using Anti-CSRF Tokens?

How to Protect Your Web Apps Using Anti-CSRF Tokens?

May 13, 2022
Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

July 29, 2025
French Telco Orange Hit by Cyber-Attack

French Telco Orange Hit by Cyber-Attack

July 29, 2025
ATC Ghana supports Girls-In-ICT Program

ATC Ghana supports Girls-In-ICT Program

April 25, 2023
Vice President Dr. Bawumia inaugurates  ICT Hub

Vice President Dr. Bawumia inaugurates ICT Hub

April 2, 2023
Co-Creation Hub’s edtech accelerator puts $15M towards African startups

Co-Creation Hub’s edtech accelerator puts $15M towards African startups

February 20, 2023
Data Leak Hits Thousands of NHS Workers

Data Leak Hits Thousands of NHS Workers

February 20, 2023
EU Cybersecurity Agency Warns Against Chinese APTs

EU Cybersecurity Agency Warns Against Chinese APTs

February 20, 2023
How Your Storage System Will Still Be Viable in 5 Years’ Time?

How Your Storage System Will Still Be Viable in 5 Years’ Time?

February 20, 2023
The Broken Promises From Cybersecurity Vendors

Cloud Infrastructure Used By WIP26 For Espionage Attacks on Telcos

February 20, 2023
Instagram and Facebook to get paid-for verification

Instagram and Facebook to get paid-for verification

February 20, 2023
YouTube CEO Susan Wojcicki steps down after nine years

YouTube CEO Susan Wojcicki steps down after nine years

February 20, 2023
Inaugural AfCFTA Conference on Women and Youth in Trade

Inaugural AfCFTA Conference on Women and Youth in Trade

September 6, 2022
  • Consumer Watch
  • Kids Page
  • Directory
  • Events
  • Reviews
Sunday, 6 December, 2026
  • Login
itechnewsonline.com
  • Home
  • Tech
  • Africa Tech
  • InfoSEC
  • Data Science
  • Data Storage
  • Business
  • Opinion
Subscription
Advertise
No Result
View All Result
itechnewsonline.com
No Result
View All Result

How to Protect Your Web Apps Using Anti-CSRF Tokens?

by ITECHNEWS
May 13, 2022
in Leading Stories, Opinion
0 0
0
How to Protect Your Web Apps Using Anti-CSRF Tokens?

The most common protection methods against Cross-Site Request Forgery (CSRF) attacks are anti-CSRF tokens. A CSRF attack is where unsuspecting authenticated users submit malicious requests unknowingly to the web app. Attackers leverage CSRF attacks to gain access to sensitive information, transfer funds, tamper with passwords and email ids, take over accounts, and so on. This article discusses how web apps can use anti-CSRF tokens to protect themselves from these attacks.

Anti-CSRF Tokens: The Basics 

Anti-CSRF tokens are related pairs of tokens given to users to validate their requests and prevent issue requests from attackers via the victim.

YOU MAY ALSO LIKE

French Telco Orange Hit by Cyber-Attack

ATC Ghana supports Girls-In-ICT Program

Each token contains a unique, unpredictable, secret value that is not guessable by a third party. Since it is impossible for attackers to determine or predict the value of the CSRF token, they cannot completely construct a valid HTTP request with all necessary parameters to honor the request from the victim user end. This is how they prevent CSRF attacks from happening.

Using Anti-CSRF Tokens to Secure Web Apps 

Synchronizer Token Pattern 

Synchronizer token pattern is a commonly used token-based cross-site request forgery protection technique. Here, anti-CSRF tokens are generated by the server-side application and transmitted to the client-side in a way that is included in the subsequent HTTP request made by the client.

When the user sends a request, the server-side application verifies and validates the request to ensure that the expected token is included. If the relevant token is not included, the server-side application rejects the request. So, only original users are authenticated to send requests in a given session.

The following best practices should be followed in generating and validating tokens.

  • A non-predictable, well-established random number generator with enough entropy must be leveraged to generate unique tokens.
  • The tokens must be kept secret and handled securely throughout the lifecycle.
  • One effective transmission method is to transmit the token within a hidden field of an HTML form.
    • The field with the anti-CSRF token must be placed at the earliest possible instance within the HTML document for stronger security.
    • It must be placed before non-hidden input fields and locations that allow user-controllable data embedded within the HTML.
    • This way, the web app is protected against several CSRF techniques that manipulate the HTML document and capture its content by crafting data.
  • The tokens must have a short expiry period not to be reused.
  • The tokens must not be transmitted within cookies for stronger CSRF protection.
  • Safe ways such as compare hashes must verify the anti-CSRF tokens.
  • Token should not be sent in HTTP GET requests to ensure that they aren’t directly available in the URL or that they don’t leak in the Referrer header.

CSRF Protection for Each Request 

Anti-CSRF tokens can be generated once per session or for each request. Per request tokens are more secure than per-session tokens as they provide attackers a shorter timeframe to exploit the tokens. So, in scenarios where a higher level of protection is necessary, tokens are generated for each session. As soon as it is verified, the token is invalidated.

Despite the simplicity in implementation, this method has some serious drawbacks.

  • It erodes user experiences as they will not operate using multiple tabs. The flow gets interrupted/ broken when the back button is used.
  • It may affect the server performance, especially when high traffic volumes. This drawback can be averted if less resource-intensive random number generators are used.

Anti-CSRF Tokens for Specific Forms

The synchronized token pattern method generates anti-CSRF tokens per session verified by each form. When web apps need an added level of protection, they may be configured to generate tokens for each form. To ensure that the tokens aren’t exposed to the browser, they are typically hashed with the form’s filename. The hashes will only match if the token and the current form are valid.

Non-Persisted Tokens

Server capacity is limited, and organizations would want to avoid persisting tokens as it would cause web servers to store lots of information. This is especially costly for web apps busy with high traffic volumes. To overcome these challenges, non-persisted tokens are used. These cryptographic tokens do not require the web app to store anti-CSRF tokens in the server sessions. The only drawback with this method is that encryption consumes more resources than random number generation.

Anti-CSRF for Login Forms

Though user impersonation may not be possible until they are logged in, users could be tricked into logging in as attackers without CSRF protection. So, anti-CSRF is necessary when the user is logged in and even for login forms.

The Way Forward

Anti-CSRF tokens, though highly effective, can be bypassed under certain circumstances. So, they must be used in combination with other CSRF prevention techniques and a robust web security solution like AppTrana to fortify your security posture.

Source: IndusfaceCMS
Via: Security Boulevard
Tags: How to Protect Your Web Apps Using Anti-CSRF Tokens?
ShareTweet

Get real time update about this post categories directly on your device, subscribe now.

Unsubscribe

Search

No Result
View All Result

Recent News

Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

July 29, 2025
French Telco Orange Hit by Cyber-Attack

French Telco Orange Hit by Cyber-Attack

July 29, 2025
ATC Ghana supports Girls-In-ICT Program

ATC Ghana supports Girls-In-ICT Program

April 25, 2023

About What We Do

itechnewsonline.com

We bring you the best Premium Tech News.

Recent News With Image

Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa

July 29, 2025
French Telco Orange Hit by Cyber-Attack

French Telco Orange Hit by Cyber-Attack

July 29, 2025

Recent News

  • Absa and Visa Extend Strategic Partnership to Advance Growth and Innovation Across Africa July 29, 2025
  • French Telco Orange Hit by Cyber-Attack July 29, 2025
  • ATC Ghana supports Girls-In-ICT Program April 25, 2023
  • Vice President Dr. Bawumia inaugurates ICT Hub April 2, 2023
  • Home
  • InfoSec
  • Opinion
  • Africa Tech
  • Data Storage

© Copyright 2026, All Rights Reserved | iTechNewsOnline.Com - Powered by BackUPDataSystems

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In

Add New Playlist

No Result
View All Result
  • Home
  • Tech
  • Africa Tech
  • InfoSEC
  • Data Science
  • Data Storage
  • Business
  • Opinion

© Copyright 2026, All Rights Reserved | iTechNewsOnline.Com - Powered by BackUPDataSystems

Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?
Go to mobile version