Consider the following script:
#!/usr/local/bin/perl
use strict;
use CGI qw(param);
$user_name = param(UserName);
$email_addy = param(EmailAddy);
$comments = param(Comments);
open(SENDMAIL, "| sendmail -oi -t") or die "Can't fork for sendmail: $!\n";
print SENDMAIL <<EOF;
From: $email_addy
To: joe\@exitwound.org
Subject: Message from $user_name
$user_name ($email_addy) has sent you the following:
-----------------------------------------
$comments
-----------------------------------------
EOF
save_parameters(*SENDMAIL);
close(SENDMAIL);
Other than flooding Joe's inbox, can you think of any way that this script could be abused? More specifically, is it possible to abuse this script to send email to someone other than Joe?
Posted from exitwound.org, comment here.
Drive-by email (Score:3, Informative)
Reply to This
Re:Drive-by email (Score:1)
If things get any worse, I'll have to ask you to stop helping me.
Re:Drive-by email (Score:2)
Re:Drive-by email (Score:1)
steveNOSPAM@exitwound.org%0A%0DCc:shockNOSPAM@exitwound.org
and
steveNOSPAM@exitwound.org\nCc:shockNOSPAM@exitwound.org
Both resulted in one email being sent to the hardcoded To: address, with nothing being received as a copy. And both resulted in goofed headers as previously described.
What am I missing here? I agree with you that not checking $email_addy should be abusable, but I don't seem to be able to replicate it.
If things get any worse, I'll have to ask you to stop helping me.
Re:Drive-by email (Score:2)
Re:Drive-by email (Score:1)
steveNOSPAM@exitwound.org%0ACc:shockNOSPAM@exitwound.org
results in the same thing ... Jeez. What am I missing here? This script may be insecure, but I'll be damned if I can prove it.
If things get any worse, I'll have to ask you to stop helping me.
Re:Drive-by email (Score:2)
personally I avoid directly calling sendmail (Score:1)
Re:personally I avoid directly calling sendmail (Score:1)
Unfortunately, in this situation, the developer has no control over the installed modules. He has to live with what he has, and in this case has to follow the FAQ on sending mail.
dws [perl.org] pretty much hit it on the head with the inadequate (i.e., no) untainting/validation of the input.
But yeah, if the situation was different, I'd definitely go with modules.
If things get any worse, I'll have to ask you to stop helping me.