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

In reply to Re: Second hack at Secure Mailer by MeowChow
in thread Second hack at Secure Mailer by SilverB1rd

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.