CSRF (Cross-site request forgery cross-site requests forgery)
Although it sounds like a cross-site script (XSS), it is very different from XSS and is almost at odds with the way it is attacked. XSS leverages trusted users within the site, while CSRF leverages trusted sites by disguising requests from trusted users.
Trust Site A, rogue site B, user C
Attack Flow:
1. Premise: User C logs on to site A and site A will generate cookies in the user's local browser
2. User C in the case of login, access to malicious site B--B will secretly send a request to the user C
3. According to the request of B, user C's browser takes a cookie to access a
4. A cannot judge the source, the request of B will be processed according to User C's permission
How to Defend:
Important scenarios: such as payment, transfer, change of password, modification of personal information, etc.
First, verify the Refer field in the Refer:http request, you need to determine the source
Second, add token: Each request generates a token
Security testing-CSRF attacks and defenses