One task I've been assigned at my new job is to find a reliable way of stopping spammers from exploiting an issue with Email-Simple. Basically, the email looks like this:

To: GetADiplomaOnline Content-Type: multipart/alternative; boundary=be638aa04b654852d0173c0e3f9b6d20 From: some@email.address.co.uk to: @huge_list_of_email_addresses

Because we have both a To: and a to: header (note case), Email::Simple reports the To: header ("GetADiplomaOnline") when doing this:

my $email = Email::Simple->new($email_text); my @headers = $email->header('to');

If the case of the headers were the same, then I'd get both headers. Because I don't get both headers, our validation checks ignore the second header. Peeking inside the email object reveals this:

'header_names' => { 'content-type' => 'Content-Type', 'to' => 'To', 'from' => 'From', 'subject' => 'Subject' }, 'order' => [ 'To', 'Content-Type', 'From', 'to', 'Subject' ]

Further research reveals the this module parses both headers, though it doesn't report both in this case. RFC 2822 says we can't have more than one header for to: (assuming I read it correctly), so I'm guessing that one way to stop this spam attack is to disallow email which has more than one to:, cc: or bcc: header.

Is this a reasonable approach? If so, how should I go about this? I don't want to reach into Email::Simple's internals to test this, but I have so little experience in this area that I'm not sure what best practices are.

Note: Email::Simple::Headers does not report the extra to: header, so that is not an option.

Cheers,
Ovid

New address of my CGI Course.


In reply to Spammers exploiting Email::Simple by Ovid

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.