Lets learn "Cross Domain Referer Leakage / Cross Site Request Forgery"

 Welcome Back ! Guys


Lets get to know about a new web vulnerability known as Cross Domain Referer Leakage . We'll use BurpSuite in this tutorial . If you are not familiar with the burpsuite then I would recommend to visit Introduction to web Application Security tutorial , and then come back to this tutorial to learn about Cross Domain Referer Leakage . It is also known as CSRF(Cross Site Request Forgery).

What is Cross Domain Referer Leakage or Cross site Request Forgery?
Whenever a request is created from browser , a HTTP header is send with the request which contains attributes like Content-type(what type of data is being sent in request) , Agent ( which agent is used to make a request - Chrome or Mozilla or Python ) etc . On of such attributes of interest is "Referer" indicating request is coming from which site . For example : Say A friend send you the link to some website in facebook message . When you open that link the HTTP header in contains a referer as 'www.facebook.com' and the request to site is originating from "www.facebook.com" .If the originating URL contains any sensitive information within its query string , such as session  token, then this information will be transmitted to other domain . If the other domain is not fully trusted by the application , then this may lead to security compromise . This security issue is known as Cross domain referer leakage or Cross site Request Forgery .

Is this defination getting complicated ?

Lets make it easy with an example :

Suppose we are adding some product to cart at flipkart.com .To do this we click on add button and a request is created to its server and item is added to its cart . Suppose we capture the add to cart request and send that request to any facebook friend . So when facebook friend (to whom link is sent ) opens the link it will be redirected to flipkart.com and that specific product gets added in his cart as well . Some event happened without any information known to user . This is cross domain request forgery . Now Flipkart does not want this , it wants that an item is added to cart only if the user wants and himself click on the button , not by clicking on any unknown link . So lets see how flipkart solve this issue  by capturing the add to cart request on burpsuite . Again if you are not familiar wth burp suite I would recommend to read this first and then come back .

Capturing flipkart add to cart request using burpsuite :

Step 1 : Configure burpsuite with your browser .
Step 2 : Open flipkart.com and add some product to cart .
Step 3 : Find that request in http history in burpsuite .



In above image , you can see the referer passed in the http request header . Now on the server side it is checked wheather the request is coming from the flipkart.com or facebook.com . If it is flipkart.com then add item to the cart else just ignore the request .


Another method to prevent CSRF is to add csrf-token to every request made . A token is provided as meta data in the html page by the server . When the request is made from the site itself( actually add to cart button is clicked) , then javascript add the token to request header . But if the request is made from other domain like facebook.com then request header donot contain the csrf token so server simply ignore the request and declare it as CSRF issue .

Hope at this position , you are able to understand what is cross domain request forgery is.
For any queries or problems , please comment below .
And stay tuned for the upcoming tutorials on other web application vulnerabilities .

Until Then ...'
HAPPY HACKING !!

Comments

Popular posts from this blog

Lets learn "About kube proxy in iptables mode"

Lets learn "System design for paste bin (or any text sharing website)"

Lets learn "Factory design pattern"