Cross Site Request Forgery (METHORD 02)

Cross Site Request Forgery (METHOD 02)



In last post Cross Site Request Forgery (Method 01) we discussed how to achieve SCRF attack protection using synchronized token pattern method. with this post lets see how to do it using double-submitted cookie pattern 




Referring to above diagram, in double-submitted cookies (for the session and for the CSRF token) are stored in the web browser. In previous method we stores CSRF token values on the sever side. here it not the way we do it.

Sample website was created and you can find it in my Github 



index.php

once this page gets loaded on the web browser user sees a simple login form. Username and password are hard-coded in the code. as in previous example too.





result.php







As you can see two cookies are stored on the browser. These cookies have 1 year expiration time and they are accessible from anywhere.

Javascript function is written to retrieve the CSRF value from the CSRF cookie set on the browser. Then DOM will be modified with the value that is retrieved from the CSRF cookie. 


home.php



CSRF cookie value and the html hidden field CSRF value are sent to the checkToken function as parameters.


token.php





 This function returns true if the CSRF token values get matched.


So here you go, another way of protecting your website from CSRF attacks using double submitted cookie pattern.

Thank you for reading my blog !!
:) :)












Comments

Popular posts from this blog

Attacks Against Weak Token Generation

Some Terminologies You Should Know About Trojans

Nmap Scanning