Lesson Plan Title: How to Perform Cross Site Request Forgery.

 

Concept / Topic To Teach:

This lesson teaches how to perform Cross Site Request Forgery (CSRF) attacks.

 

How the attacks works:

Cross-Site Request Forgery (CSRF/XSRF) is an attack that tricks the victim into loading a page that contains img links like the one below:

<img src="http://www.mybank.com/sendFunds.do?acctId=123456"/>

When the victim's browser attempts to render this page, it will issue a request to www.mybank.com to the transferFunds.do page with the specified parameters. The browser will think the link is to get an image, even though it actually is a funds transfer function. The request will include any cookies associated with the site. Therefore, if the user has authenticated to the site, and has either a permanent cookie or even a current session cookie, the site will have no way to distinguish this from a legitimate user request. In this way, the attacker can make the victim perform actions that they didn't intend to, such as logout, purchase item, or any other function provided by the vulnerable website

 

General Goal(s):

Your goal is to send an email to a newsgroup that contains an image whose URL is pointing to a malicious request. Try to include a 1x1 pixel image that includes a URL. The URL should point to the CSRF lesson with an extra parameter "transferFunds=4000". You can copy the shortcut from the left hand menu by right clicking on the left hand menu and choosing copy shortcut. Whoever receives this email and happens to be authenticated at that time will have his funds transferred. When you think the attack is successful, refresh the page and you will find the green check on the left hand side menu.

 

Figure 1 How to perform CSRF

 

Solution:

 

To complete this lesson you need to embed HTML code in the message box. This HTML code should contain a image tag linking to an URL that is not a real image  will but start a transaction on the web server instead.

 

The format of an image in html is <img src="[URL]" width="1" height="1" />

The transaction can be triggered by an URL to the current lesson and an extra parameter “transferFunds’ and the amount. The width=1 and height=1 will not show the image.

 

This payload will work:

<img src=”http://localhost/WebGoat/attack?Screen=81&menu=210&transferFunds=5000” width="1" height="1" />

 

So create a new message with title “Test” and a message with the payload.

Figure 2 Insert payload

 

The page will refresh and you will see a new message in the message list.

 

Figure 3 New message test

 

Click on the message test. This will download the message and display the contents as HTML, executing the payload. Examine the HTTP Request in WebScarab that is generated when the browers tries to render the image tag.

 

Figure 4 CSRF attack

 

Now you need to refresh the page to get the green star next to the lesson.

 

Figure 5 Lesson completed

 

Solution by Erwin Geirnaert ZION SECURITY