Home  >  Article  >  Operation and Maintenance  >  What is a CSRF attack? How to prevent it?

What is a CSRF attack? How to prevent it?

王林
王林forward
2020-06-19 17:31:003977browse

What is a CSRF attack? How to prevent it?

What is a CSRF attack?

Cross-site request forgery refers to an attacker performing illegal operations as a legitimate user through cross-site requests.

(Recommended tutorial: web server security)

You can understand CSRF attacks this way: the attacker steals your identity and sends malicious requests to third-party websites in your name. . What CRSF can do includes using your identity to send emails, send text messages, conduct transaction transfers, and even steal account information.

How to prevent CSRF attacks

1. Security framework, such as Spring Security. token mechanism.

2. Perform token verification in the HTTP request. If there is no token in the request or the token content is incorrect, it will be considered a CSRF attack and the request will be rejected.

3. Verification code. Under normal circumstances, verification codes can very well curb CSRF attacks, but in many cases, due to user experience considerations, verification codes can only be used as an auxiliary means rather than the main solution.

4. Referer identification. There is a field Referer in the HTTP Header, which records the source address of the HTTP request. If the Referer is another website, it may be a CSRF attack and the request will be rejected. However, not all servers can obtain the Referer. Many users restrict the sending of Referers out of privacy protection considerations. In some cases, the browser will also not send the Referer, such as HTTPS jumping to HTTP.

The above is the detailed content of What is a CSRF attack? How to prevent it?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete