At 08:30 PM 7/29/01 -0700, [EMAIL PROTECTED] wrote:
> > Gia Elise Barboza <[EMAIL PROTECTED]> said:
>
> > open(mail, "|mail barbozag\@msu.edu");
> > print mail "bad news: guessed \n";
> > close (mail);
>
>This works, but if you are not certain of the contents of the email message
>(e.g. writing a CGI interface to let a user compose and send an email
>message)
>then doing the above can be very dangerous. mail or mailx allows shell
>escape
>sequences in the input (a line starting with a ~! escapes to the shell).
>This is a very nasty security hole, especially if your script runs as root.
>
>It is better to pipe the message and headers into sendmail which has no
>escape
>sequences. So something like:
>
>open(MAIL, "|/usr/sbin/sendmail soandso\@somedomain.com");
>print MAIL <<EOF;
>From: whoever\@localdomain.com
>Subject: hi there
>
>This is the body of the message.
>EOF
>
>Note the message header is separated from the body by an empty line.
Yes, but if you create the above using something like
open (MAIL, "|/usr/sbin/sendmail $email")
to which you should by the way add
or die "sendmail: $!\n";
then you now need to validate $email to make sure that it isn't something like
[EMAIL PROTECTED]; rm -rf /
Better to use
open MAIL, "|/usr/sbin/sendmail -oi -t" or die "sendmail : $!\n";
print MAIL <<"EOF";
To: $email
etc. Oh, and check the status on the close.
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]