I'd just like to expand a little on grep's comments above, to explain why this script could be used as a spam portal.

print MAIL "To: $form{'usermail'}\n";
Somebody could simply copy and paste an entire mailing list into the 'usermail' field and submit it.
The email would then be sent to everyone in that list.
victim1@domain.com, victim2@domain.com, victim3@domain.com, etc...
You get the picture.
This is made worse because the $form{'message'} is sent as the body of the email, meaning the (ab)user could enter their own adverts, urls etc into the 'message' field, so everyone would receive spam (possibly offensive) and it would appear to have been sent by you.

If you switch on taint mode

#!/usr/bin/perl -wT
Then perl will force you to run every user inputted data through a regex before you can send it outside of your program, such as to sendmail.
my $username; If ($form{username} =~ /^([\w.-]+)$/) { $username = $1; } else { die("invalid username"); }
See the regex docs for help.
You would need to run every user input through a regex. The difficult one is validating the email address, have a search around the monastery for help with that.


In reply to Re: Insecurities in my scripting by fireartist
in thread Insecurities in my scripting by sulfericacid

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.