Mga Pahina

Friday, August 21, 2020

CSRF Referer Header Strip

Intro

Most of the web applications I see are kinda binary when it comes to CSRF protection; either they have one implemented using CSRF tokens (and more-or-less covering the different functions of the web application) or there is no protection at all. Usually, it is the latter case. However, from time to time I see application checking the Referer HTTP header.

A couple months ago I had to deal with an application that was checking the Referer as a CSRF prevention mechanism, but when this header was stripped from the request, the CSRF PoC worked. BTW it is common practice to accept empty Referer, mainly to avoid breaking functionality.

The OWASP Cross-Site Request Forgery (CSRF) Prevention Cheat Sheet tells us that this defense approach is a baaad omen, but finding a universal and simple solution on the Internetz to strip the Referer header took somewhat more time than I expected, so I decided that the stuff that I found might be useful for others too.

Solutions for Referer header strip

Most of the techniques I have found were way too complicated for my taste. For example, when I start reading a blog post from Egor Homakov to find a solution to a problem, I know that I am going to:
  1. learn something very cool;
  2. have a serious headache from all the new info at the end.
This blog post from him is a bit lighter and covers some useful theoretical background, so make sure you read that first before you continue reading this post. He shows a few nice tricks to strip the Referer, but I was wondering; maybe there is an easier way?

Rich Lundeen (aka WebstersProdigy) made an excellent blog post on stripping the Referer header (again, make sure you read that one first before you continue). The HTTPS to HTTP trick is probably the most well-known one, general and easy enough, but it quickly fails the moment you have an application that only runs over HTTPS (this was my case).

The data method is not browser independent but the about:blank trick works well for some simple requests. Unfortunately, in my case the request I had to attack with CSRF was too complex and I wanted to use XMLHttpRequest. He mentions that in theory, there is anonymous flag for CORS, but he could not get it work. I also tried it, but... it did not work for me either.

Krzysztof Kotowicz also wrote a blog post on Referer strip, coming to similar conclusions as Rich Lundeen, mostly using the data method.

Finally, I bumped into Johannes Ullrich's ISC diary on Referer header and that led to me W3C's Referrer Policy. So just to make a dumb little PoC and show that relying on Referer is a not a good idea, you can simply use the "referrer" meta tag (yes, that is two "r"-s there).

The PoC would look something like this:
<html>
<meta name="referrer" content="never">
<body>
<form action="https://vistimsite.com/function" method="POST">
<input type="hidden" name="param1" value="1" />
<input type="hidden" name="param2" value="2" />
...
</form>
<script>
document.forms[0].submit();
</script>
</body>
</html>

Conclusion

As you can see, there is quite a lot of ways to strip the Referer HTTP header from the request, so it really should not be considered a good defense against CSRF. My preferred way to make is PoC is with the meta tag, but hey, if you got any better solution for this, use the comment field down there and let me know! :)

Related articles


  1. Pentest Tools Windows
  2. Pentest Tools Open Source
  3. Pentest Tools Bluekeep
  4. Hacking Tools For Kali Linux
  5. Nsa Hack Tools
  6. Hack Tool Apk No Root
  7. Hack Tools For Mac
  8. Pentest Tools Windows
  9. Hacking Tools Windows
  10. Github Hacking Tools
  11. Hacker Security Tools
  12. Pentest Tools List
  13. How To Make Hacking Tools
  14. Pentest Tools For Windows
  15. Hacker Techniques Tools And Incident Handling
  16. Pentest Tools Android
  17. Hack Tools Mac
  18. Hacker Tools Apk Download
  19. Hacker Tools Free
  20. Hacker Tools Mac
  21. Hacking Tools Windows
  22. Easy Hack Tools
  23. Hacking Tools For Windows Free Download
  24. Hack Tools For Games
  25. Best Pentesting Tools 2018
  26. What Are Hacking Tools
  27. Hacking Tools 2019
  28. World No 1 Hacker Software
  29. Pentest Tools Free
  30. Hacking Tools For Beginners
  31. What Is Hacking Tools
  32. Android Hack Tools Github
  33. Hacker Tools 2020
  34. Hacker Tools Windows
  35. Hack Tools
  36. Tools Used For Hacking
  37. Kik Hack Tools
  38. Tools For Hacker
  39. Hacking Tools Pc
  40. Pentest Tools Free
  41. Hacker Search Tools
  42. Hacker Tools 2020
  43. Best Hacking Tools 2019
  44. Hacking Tools For Windows 7
  45. Hacking Tools Kit
  46. Hacker Tools
  47. Pentest Tools List
  48. Hack Tools For Ubuntu
  49. Hacker
  50. New Hack Tools
  51. Hacking Tools Download
  52. Hacking Tools Name
  53. Pentest Tools Website Vulnerability
  54. Pentest Tools Linux
  55. Pentest Tools Online
  56. Pentest Tools Alternative
  57. Hack Tools For Games
  58. Hacking Tools Online
  59. Hackers Toolbox
  60. Hacker Tools For Mac
  61. Hacking Tools
  62. Usb Pentest Tools
  63. Pentest Tools Port Scanner
  64. World No 1 Hacker Software
  65. Game Hacking
  66. Hack Tools For Games
  67. Pentest Tools Find Subdomains
  68. Hack Tools
  69. Hack Tools For Ubuntu
  70. Pentest Tools Kali Linux
  71. Hacker Tools
  72. Hacking Tools 2020
  73. Hak5 Tools
  74. Blackhat Hacker Tools
  75. Hack Tools Pc
  76. Hacker Tools Free Download
  77. Hacker Tools Windows
  78. Github Hacking Tools
  79. Hacking Tools Hardware
  80. Pentest Tools Url Fuzzer
  81. Hacking Tools Hardware
  82. Hacker Tools For Ios
  83. Hack Tools
  84. Pentest Tools Subdomain
  85. Free Pentest Tools For Windows
  86. Hacker Techniques Tools And Incident Handling
  87. Pentest Tools For Windows
  88. Growth Hacker Tools
  89. Hacker Tools Github
  90. Hacking Tools For Windows Free Download
  91. Beginner Hacker Tools
  92. How To Hack
  93. Hacking Tools For Pc
  94. Pentest Tools Website Vulnerability
  95. Pentest Tools Apk
  96. How To Hack
  97. Hacker Tools Linux
  98. Hacker Tools Online
  99. Pentest Tools Free
  100. Hack Tools
  101. Hacking App
  102. Computer Hacker
  103. Pentest Tools Github
  104. Pentest Tools Subdomain
  105. Hacker Tools Free Download
  106. Bluetooth Hacking Tools Kali
  107. Growth Hacker Tools
  108. Hacker Tools Linux
  109. Pentest Tools Alternative
  110. Computer Hacker
  111. Hacking Tools
  112. How To Hack
  113. Tools For Hacker
  114. Hack Tools For Ubuntu
  115. Wifi Hacker Tools For Windows
  116. New Hacker Tools
  117. Hacker Tools Free
  118. Black Hat Hacker Tools
  119. Hacker Security Tools
  120. Pentest Tools Android
  121. Pentest Tools Website
  122. Hacker Tools Hardware
  123. New Hacker Tools
  124. How To Install Pentest Tools In Ubuntu
  125. Hacking Tools For Windows Free Download
  126. Hack Apps
  127. Hack Tools For Games
  128. Tools For Hacker
  129. Hacker Tools 2020
  130. Hacking Tools 2020
  131. Wifi Hacker Tools For Windows

No comments:

Post a Comment