What is a cross-site forgery request attack?
My own understanding: User A with browser access to a vulnerability site B, and a also visited the malicious website C, assuming that user A on the B site for a transaction, C site has a HTML fragment, then user A Browser will send a request to the B website Transaction link, because a has been logged in the B site, so b site processing of this request, but this request is not user A's own behavior sent, but B website can not determine whether the user is actively sent, so caused the attack! You can use this image to understand
This figure is taken from HYDDD's blog hyddd's blog--"talking about the CSRF attack mode"
How to protect?
In server-side defense, the main practice is to set a pseudo-random number for each user's cookie on the server side
Generates a pseudo-random number into a cookie, and then submits the number as a hidden field in the form to the HTML page after it is submitted for validation
Set up verification codes for forms
When the browser opens multiple different forms at the same time, the server creates multiple random numbers, and the random number corresponding to the last form overwrites the random number of the previous form, and only the last open form can be submitted, so you should avoid this situation. So the random number of each form should be stored in each separate place.
Reference: HYDDD's blog--"talking about CSRF attack mode"
Preliminary understanding of CSRF cross-site forgery request attack