CSRF (Cross-Site Request Forgery)
How CSRF Works
Via a CSRF attack, the attacker can bypass the authentication process or perform actions with higher privileges. What to do to execute this attack:
Create the custom payload
Embed the request into a hyperlink
Trick the victim into clicking the link which will send your request to the website.
Forge the request to conduct malicious action
This attack only works if the victim is an authenticated user because when the request is made, the application will check if the cookies of a valid session are available. If the relevant cookies are available, those will need to be sent with the request. If the session is valid and the website approves the sent cookies, CSRF attack becomes successful.
This attack only works if the victim is an authenticated user because when the request is made, the application will check if the cookies of a valid session are available. If the relevant cookies are available, those will need to be sent with the request. If the session is valid and the website approves the sent cookies, the CSRF attack will be successful.
Payloads
Some payloads that can be used during CSRF attacks can be found below:
Tools
Remediation
The most popular prevention method is adding an Anti-CSRF Token which will be associated with a particular user to prevent CSRF attacks. Another known prevention method is adding Same-Site flag to Cookies which will check if the origin of the request sender is the same as the Cookie owner. The following suggestions can be listed as Suggestions for CSRF attacks.
Use CSRF token in HTTP header and match its value on server side.
Do not use GET HTTP method for critical operations such as Create/Update/Delete
Implement “Same-site” Attribute to cookies.
Last updated