Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Preventing outbound SPAM

by UnderMine (Friar)
on Jun 01, 2006 at 12:09 UTC ( [id://553026]=perlquestion: print w/replies, xml ) Need Help??

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

Hi Monks,

I would like your collective wisdom on how best to impliment a SPAM filter for outbound SPAM.

Looking at the conventional solutions everything is based on preventing incoming spam and not designed to stop sending it :( It may be that I have missed something blatently obvious.

I have a website that have a large number of email forms that are used to send requests from the public to clients. Recently we have experienced a number of spammers copy and pasting into the forms.

Putting in a graphical code image would prevent bots using the forms but not stop people from copy and pasting. To make things more complex it is perfectly valid for a person to ask the same question of multiple clients.

My initial thoughts were along the lines of implimenting a whitelist and quarantining everything else. However with my hundreds of emails going through the system this will be manually intensive to manage. Now my thoughts have moved to a delayed mailing system that quarantines all mail except whitelisted addresses. If no more mails are recieved within a period it releases them otherwise it flags it to administrators.

Now back to the real question.

Can any of the CPAN modules such as Mail::SpamAssassin be used to flag potential outbound spam before it becomes an email?

Thanks
UnderMine

Replies are listed 'Best First'.
Re: Preventing outbound SPAM
by davorg (Chancellor) on Jun 01, 2006 at 12:23 UTC

    We had to consider this when writing the nms formmail program. Formmails are the most badly abused CGI programs on the web. Here are what we recommend (and, whenever possible, enforce) in formmail.

    • Only ever allow the form to send email to a fixed set of email addresses. Most spammers will test formmail programs by trying to get an email sent to themselves. If you don't send email to addresses that are input through the form then the spammer won't get his test email back and will probably abandon your site.
    • If you're sending to ad-hoc email addresses, then only send fixed text that is configured in the program and not taken from the form. If a spammer can't change what the email says then your system is of little use to him.
    • If you can't do either of the above, then force people to register (and check their email address is valid) before using your system to send email. That will discourage spammers as (for obvious reasons) they don't like to leave a trail.

    As in so many areas of life, it's just a case of making your system harder to abuse than your neighbours'. If your system gives the spammers any trouble at all then they'll soon move on to a less well-guarded server.

    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

      As in so many areas of life, it's just a case of making your system harder to abuse than your neighbours'. If your system gives the spammers any trouble at all then they'll soon move on to a less well-guarded server.

      This is not my experience - my (work) logs show that we often get repeated attempts at the same script from the same IP address, or from different IP addresses but with the same payload (including the same throwaway target email address) over a period of time.

      One particularly persistent guy has returned from the same IP address to the same script with the same payload once a month for at least the 6 months we've been logging enough to tell.

      Note that this is just logging the special case where people explicitly attempt to trick the script by inserting things like "some text\ncc: email@address" into random fields that look as if they might make it into email headers.

      (For what it's worth, we deal with this by logging such abuse, and blocking offending IP addresses for escalating periods of time.)

      Hugo

      Thanks.

      Each form goes to only one email address which is one of the clients members. However there are hundreds of forms one for each member.

      Unfortunately the client does not believe that you should have to register to ask there members a question. But we are trying to change that.

      UnderMine

        Unfortunately the client does not believe that you should have to register to ask there members a question. But we are trying to change that.

        Your client needs to be introduced to the realities of the situation; registration or spam - pick one :-)

        --
        <http://dave.org.uk>

        "The first rule of Perl club is you do not talk about Perl club."
        -- Chip Salzenberg

Re: Preventing outbound SPAM
by marto (Cardinal) on Jun 01, 2006 at 12:19 UTC
    UnderMine,

    Perhaps I am not understanding your question properly. This script you are using to process the HTML forms and send the mail, did you write it yourself? Is the spam being sent to your clients only, or are the spammers relaying mail to otheer people via your script? Have you looked at things like NMS Formmail?

    Thanks

    Martin
Re: Preventing outbound SPAM
by stonecolddevin (Parson) on Jun 01, 2006 at 12:15 UTC

    When you say the forms are used to send requests from the public to clients, does that mean that anyone is allowed to send these requests?

    I'm not completely understanding, but if only certain people are supposed to be using these forms, then maybe you should create some sort of members only interface? I'm not completely convinced you should wait until someone actually sends the data to be trying to prevent it.

    meh.
Re: Preventing outbound SPAM
by gellyfish (Monsignor) on Jun 01, 2006 at 12:20 UTC

    Can any of the CPAN modules such as Mail::SpamAssassin be used to flag potential outbound spam before it becomes an email?

    Well not quite before it becomes an e-mail but before it leaves the server, yes. You can use Mail::SpamAssassin's spamd in association with a plugin for your MTA (such as spamass-milter for Sendmail), to process the mail before it is forwarded on it's next hop. You can for instance set the threshold such that it will bounce or drop the mails rather than simply flagging them as spam.

    /J\

Re: Preventing outbound SPAM
by fizbin (Chaplain) on Jun 16, 2006 at 19:17 UTC

    In addition to everything else being proposed here, you should seriously consider consulting a DNS-based RBL. It's easy to do, especially in a web-backend context where you're guaranteed to be connected to the internet and to have the sender's IP address.

    --
    @/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2024-04-24 17:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found