Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a HTML page with Form in my application. The HTML page has submit button which submit to a handler (ashx) or to an aspx page in my same web application.

I want to implement CSRF protection for my application. Any suggestion or guidance regarding this is appreciated.

What I have tried:

I thought about getting some token from the server and storing in the HTML page. When the form will be submitted to the server I will verify the validity of the token in the ASHX/ASPX page. How should I generate the token in server, store it in the server and validate again in the server when the form is submitted. I am using database to store session information.
Posted
Comments
Atlapure Ambrish 10-Jul-17 7:45am    
For CSRF refer below URLs..
https://software-security.sans.org/developer-how-to/developer-guide-csrf
https://stackoverflow.com/questions/29939566/preventing-cross-site-request-forgery-csrf-attacks-in-asp-net-web-forms

As you are thinking to generate a token and store it on server to validate later on, I think you can do that. The approach should be generate a GUID (or this could be any value of you choice, would be more beneficial if you could make it configurable) and then encrypt it before storing on server using some algorithm and then add this to a hidden field on your form. Encrypting would add an extra validation level.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900