Resources

People often ask me "How did you learn how to hack?" The answer: by reading. This page is a collection of the blog posts and other articles that I have accumulated over the years of my journey. Enjoy!

PHP Loose Type Comparison - 167

SpiderSecPosted 6 Years Ago
  • PHP has two comparison operators: loose and strict. Dealing with loose operator comparison in PHP is well known to be very weird with interesting results.
  • A good example of the weird is this table, which has a list of all of the comparisons and what happens to it.
  • The twitter link (above) is showing a CSRF bypass because of the loose type checking that occurs. By adding an array ([]) for the CSRF token (instead of the actual token) the type comparison gets messed up.
  • What actually happens? When empty array gets evaluated in the strcmp, it returns null. Then, it compares null with 0. According to the chart above, null == 0. So, this bypasses the security check!
  • An example of a vulnerable package.