Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

security concerns with using mail::mailer

by pearlie (Sexton)
on Dec 29, 2004 at 10:43 UTC ( [id://417962]=perlquestion: print w/replies, xml ) Need Help??

pearlie has asked for the wisdom of the Perl Monks concerning the following question:

hello all,
what are the issues involved in using mail::mailer? can someone please throw light on the statement in the documentation that says:

"Secure all forms of send_headers() against hacker attack and invalid contents. Especially ``\n~...'' in ...::mail::send_headers."

thanks in advance

  • Comment on security concerns with using mail::mailer

Replies are listed 'Best First'.
Re: security concerns with using mail::mailer
by edan (Curate) on Dec 29, 2004 at 11:43 UTC

    This comment was in the "TO DO" section of the pod, meaning that the module author/maintainer was noting that he should do it, not you. Of course, you as the module "consumer" want to know that there may be a security problem in the module. The best thing to do in this case is to "Use the Source, Luke!":

    The Source

    There, you'll see the following little function, that might be of interest:

    sub _cleanup_hdrs { my $hdrs = shift; my $h; foreach $h (values %$hdrs) { foreach (ref($h) ? @{$h} : $h) { s/\n\s*/ /g; s/\s+$//; } } }

    So, in my estimation, this is "DONE", and no longer "TO DO". Perhaps you should contact the maintainer and request that the pod be updated? That's your call...

    Update: Oh yeah, forgot to mention that you should make sure that you've got the latest VERSION (1.65) of Mail::Mailer, so you can rest assured that you have got the fix.

    --
    edan

Re: security concerns with using mail::mailer
by Corion (Patriarch) on Dec 29, 2004 at 10:54 UTC

    This is the basic advice that you should never trust input read from a file or read from the internet or any other input to your script. In this specific case, you should always make sure that you accept nothing that looks like a newline and pass it on to the Mail::send_headers method. You should run your script with taint mode switched on, in any case.

    An easy/simple way to validate your data so that it doesn't contain embedded newlines is the following:

    my $subject = $query->param('subject'); $subject = '(Disallowed char in subject)' if $subject =~ m!\n!sm;

    You should never read the recipient of a mail from a HTML form!

Re: security concerns with using mail::mailer
by Jaap (Curate) on Dec 29, 2004 at 11:19 UTC
Re: security concerns with using mail::mailer
by Mutant (Priest) on Dec 29, 2004 at 10:50 UTC

    It's CPAN, there's more than one module to do it :)

    I've used Mail::Sender, and it seems to do the trick. (Requires access to a SMTP server)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://417962]
Approved by Mutant
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-25 15:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found