{"id":215,"date":"2018-02-15T04:50:27","date_gmt":"2018-02-15T04:50:27","guid":{"rendered":"http:\/\/malwrforensics.com\/en\/?p=215"},"modified":"2018-04-04T04:02:10","modified_gmt":"2018-04-04T04:02:10","slug":"how-to-test-if-a-web-page-is-vulnerable-to-a-cross-site-request-forgery-csrf-attack","status":"publish","type":"post","link":"https:\/\/malwrforensics.com\/en\/2018\/02\/15\/how-to-test-if-a-web-page-is-vulnerable-to-a-cross-site-request-forgery-csrf-attack\/","title":{"rendered":"How to test if a web page is vulnerable to a cross site request forgery (CSRF) attack"},"content":{"rendered":"<p>Let&#8217;s assume you have created an account and have logged in to a website. Among the options you have, there is one where you can edit your profile. Once we land on that page, we want to check if there is a protection against a CSRF (cross-site request forgery) attack.<\/p>\n<p>First thing is to view the source and inspect the form.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-216\" src=\"http:\/\/malwrforensics.com\/en\/wp-content\/uploads\/2018\/02\/form_no_csrf_token.png\" alt=\"\" width=\"632\" height=\"320\" srcset=\"https:\/\/malwrforensics.com\/en\/wp-content\/uploads\/2018\/02\/form_no_csrf_token.png 1006w, https:\/\/malwrforensics.com\/en\/wp-content\/uploads\/2018\/02\/form_no_csrf_token-300x152.png 300w, https:\/\/malwrforensics.com\/en\/wp-content\/uploads\/2018\/02\/form_no_csrf_token-768x389.png 768w\" sizes=\"auto, (max-width: 632px) 100vw, 632px\" \/><\/p>\n<p>Immediately you can see one thing that is missing, a random text\/token (usually 8 or more characters). Something like this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-217\" src=\"http:\/\/malwrforensics.com\/en\/wp-content\/uploads\/2018\/02\/csrf_token_example.png\" alt=\"\" width=\"391\" height=\"17\" srcset=\"https:\/\/malwrforensics.com\/en\/wp-content\/uploads\/2018\/02\/csrf_token_example.png 391w, https:\/\/malwrforensics.com\/en\/wp-content\/uploads\/2018\/02\/csrf_token_example-300x13.png 300w\" sizes=\"auto, (max-width: 391px) 100vw, 391px\" \/><\/p>\n<p>Why is a CSRF token important ? Well, in this case, without a CSRF token, if a user clicks on a link while he\/she is logged in, the profile data can be changed.<\/p>\n<p>Imagine you are buying something on a website and while you have the items in the cart, you visit a webpage that is able to change your address so when you click on the &#8220;Buy&#8221; button, the items will be shipped somewhere else. You can find more examples\u00a0<a href=\"https:\/\/www.owasp.org\/index.php\/Cross-Site_Request_Forgery_(CSRF)\">here<\/a>.<\/p>\n<p>To see it in action, assuming that you&#8217;re using Burp, edit your profile, locate the request in the HTTP history, right click on it and select\u00a0 &#8220;Send it to Repeater&#8221;.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-218\" src=\"http:\/\/malwrforensics.com\/en\/wp-content\/uploads\/2018\/02\/csrf_burp_repeater.png\" alt=\"\" width=\"595\" height=\"276\" srcset=\"https:\/\/malwrforensics.com\/en\/wp-content\/uploads\/2018\/02\/csrf_burp_repeater.png 595w, https:\/\/malwrforensics.com\/en\/wp-content\/uploads\/2018\/02\/csrf_burp_repeater-300x139.png 300w\" sizes=\"auto, (max-width: 595px) 100vw, 595px\" \/><\/p>\n<p>You can then edit the parameters with new values and submit it. When you refresh the page in the browser, you should be able to see the new values.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s assume you have created an account and have logged in to a website. Among the options you have, there is one where you can edit your profile. Once we land on that page, we want to check if there is a protection against a CSRF (cross-site request forgery) attack. First thing is to view [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[61,77,49,24],"class_list":["post-215","post","type-post","status-publish","format-standard","hentry","category-security","tag-burp","tag-cross-site-request-forgery","tag-csrf","tag-web-security"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[]}},"featured_image_urls_v2":{"full":"","thumbnail":"","medium":"","medium_large":"","large":"","1536x1536":"","2048x2048":""},"post_excerpt_stackable_v2":"<p>Let&#8217;s assume you have created an account and have logged in to a website. Among the options you have, there is one where you can edit your profile. Once we land on that page, we want to check if there is a protection against a CSRF (cross-site request forgery) attack. First thing is to view the source and inspect the form. Immediately you can see one thing that is missing, a random text\/token (usually 8 or more characters). Something like this: Why is a CSRF token important ? Well, in this case, without a CSRF token, if a user clicks&hellip;<\/p>\n","category_list_v2":"<a href=\"https:\/\/malwrforensics.com\/en\/category\/security\/\" rel=\"category tag\">Security<\/a>","author_info_v2":{"name":"malwrforensics","url":"https:\/\/malwrforensics.com\/en\/author\/u_malwrforensics\/"},"comments_num_v2":"0 comments","_links":{"self":[{"href":"https:\/\/malwrforensics.com\/en\/wp-json\/wp\/v2\/posts\/215","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/malwrforensics.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/malwrforensics.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/malwrforensics.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/malwrforensics.com\/en\/wp-json\/wp\/v2\/comments?post=215"}],"version-history":[{"count":3,"href":"https:\/\/malwrforensics.com\/en\/wp-json\/wp\/v2\/posts\/215\/revisions"}],"predecessor-version":[{"id":276,"href":"https:\/\/malwrforensics.com\/en\/wp-json\/wp\/v2\/posts\/215\/revisions\/276"}],"wp:attachment":[{"href":"https:\/\/malwrforensics.com\/en\/wp-json\/wp\/v2\/media?parent=215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/malwrforensics.com\/en\/wp-json\/wp\/v2\/categories?post=215"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/malwrforensics.com\/en\/wp-json\/wp\/v2\/tags?post=215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}