regex evasion
Monday, June 19th, 2006It seems the good people from redteam-pentesting ( who also have a blog here: http://blogs.23.nu/RedTeam ) recently released a nice advisory where they could evade a regex and get some sql injection and passwd retrival (for another user) working for phpbannerexchange.
This was related to a small weakness in php where the ereg*() functions aren’t binary safe and it would stop matching after a 0-byte.
A while ago I’ve spend some time looking into regex evasion myself. Although not looking for oddities in the regex implementation itself, but instead looking for weaknesses in the regex itself.
For example, if you have: /^\d$/ that would only match numbers (0-9). Or so you would think, the $-sign will also match a next line. A potential attack vector here would be where the inputted data gets written to a line-based file. Where all the sudden you get next line injection.
After some googling I found out that this kind of regex evasion is used sometimes with some ids’s, there is a nice post about this on the snort forum: http://www.snort.org/archive-3-1353.html
The Redteam people think that we haven’t seen the last of these kind of attacks and I believe they are right.