The demo URL to cause the failure looks like:
http://www.mydomain.com/ScanAlert%2500.cfm
I send all 404s to an ASP page that grabs the URL from the QS, so I end up with a raw QS like:
404;http://www.mydomain.com:80/scanalert%00.cfm
Then I pass that URL through a function to strip malicious characters, but now, I see where I was going wrong.
The first thing I did in the function was to unescape the string, so I could filter and escaped characters, like "<" and remove them. But after playing with my script, I see that if I escape the string instead of unescaping I'll see:
404%3Bhttp%3A//www.mydomain.com%3A80/scanalert%2500.cfm
So now, it seems like instead of unescaping, I need to escape first...I'm wondering what the best way to handle this is, however? should I just escape the string and then try to remove all malicious escape sequences? I guess that's no different from doing an interative replace on "<", " ' ', etc.?
This is legacy code in a website that has other problems, like non-parameterized SQL queries, and this is where the above error was occuring. Would parameterizing the queries protect against an escaped %00?
Any comments would be appreciated.