http://qs1969.pair.com?node_id=58501


in reply to Second hack at Secure Mailer

Well, the good news is that you use CGI.pm. The bad news is that you don't use it.

You shouldn't scrub the query string directly; let CGI.pm deal with that. In fact, your initial tr/// of the query string completely breaks most requests. Moreover, if you were to add needed characters like [%&?] to your regex, it still would be unsafe, because of the unescaping performed by CGI.pm. Now, onto the following line:

$temp =~ s/\.+\///g;

Remember what you've been told regarding code checks for specific hacks. It's never something you should do, and that is what you are doing here. Consider how this expression would perform if given "..\..\" instead of "../../" on an NT platform- you can't possibly check for all the sploits, so don't even try. It would only serve to make your code more complex, buggy, and insecure. Now, moving on to this comment:

#you may now use the CGI methods.
You can always use the CGI.pm methods. CGI.pm is quite secure, and neeedn't launder any raw request data before it gets to see it. Launder the data that you get back from CGI.pm.

Also, as a matter of style, you should consider using CGI.pm's functions like print $query->header for some of your code. There's really no need to type alot that stuff out.

   MeowChow                                   
               s aamecha.s a..a\u$&owag.print