Cookies are used to manage state, handle logins or to track you for advertising purposes and should be kept safe. The process involved in setting cookie are:-
The ‘anti-CSRF’ flag can be accessed easily by the attacker using some scripts. The attacker can successfully trick a victim into sending a valid request. Because of this, the server will fail to determine the attacker because it is not validating the origin. Using SamSite Cookie attribute, a developer can instruct all the browsers accessing the website to control if the cookies are sent along with the request.
Using this vulnerability, an attacker can:-
Beagle recommends setting the flag to lax and strict for maximum security.
The ‘strict’ attribute prevents a cookie from being sent by the browser to the target site in all cross-site browsing context.
The default ‘lax’ value provides a proper balance between security and usability for websites. This flag is used by applications that maintain a user’s logged-in session.