Alt-PHP-Faq
Cheapest CO.UK domains in the UK! £1.88 per year!
And PHP/MySQL hosting 1p/1c for the first month, NO CATCH!


Question :

How do I stop spammers using header injection with my PHP Scripts? (Server Admin)

Answer :
*UPDATE*
System administrators I would recomend visting choon.net php-mail-header Patch. Using this patch will add additional headers into all sent mail, using the php mail command. This will enable you to track spam reports much faster.

Its also advisable to look at installing Suhosin Hardended PHP Patch, this patch adds far greater security to a PHP build. The mail options should slow down spammers and hackers efforts.



--
If you are a server admin you may have hundreds of websites that you have no control over.

The method we came up with involves using exim to take the mail from web forms and check for any bad content in the message body. Its a very easy fix, first you need to make sure you have exim installed.

This is based on exim-4.31 + Exiscan patch.

You need to edit php.ini and set the sendmail option to :-
sendmail_path = "/usr/exim/bin/exim -t -i"

This will ensure that PHP uses exim to deliver the local mail.

Now edit the exim configure file (Ours is located /usr/exim/configure)

Look for the line trusted_users, if this is not found add it in :-
trusted_users = nobody

Assuming that your webserver runs as nobody, this may also be www. (the user is listed in httpd.conf) If its another user then edit the above line.

The trusted_users can be at the top of exim's configuration file.

Next search for acl_smtp_rcpt = acl_check_rcpt

Below this add
acl_not_smtp = acl_check_pipe

Now search for acl_check_rcpt:

Above this line place the following :-
acl_check_pipe:
drop condition = ${if match {$message_body}\
{\N.*\
MIME-Version:.*\N}{true}}
log_message = "Spam MIME-Version:$header_subject: "

# This will also block attachments
# drop condition = ${if match {$message_body}\
# {\N.*\
# Content-Type:.*\N}{true}}
# log_message = "Spam: Content-Type: $header_subject: "

# This will also block attachments
# drop condition = ${if match {$message_body}\
# {\N.*\
# Content-Transfer-Encoding:.*\N}{true}}
# log_message = "Spam: Content-Transfer-Encoding: $header_subject: "

drop condition = ${if match {$message_body}\
{\N.*\
bcc:.*\N}{true}}
log_message = "Spam: bcc: $header_subject: "

drop condition = ${if match {$message_body}\
{\N.*\
cc:.*\N}{true}}
log_message = "Spam: cc: $header_subject: "
accept

accept

--

Save and restart apache/exim. This should now protect your contact forms.

Categories Return to Main PHP Faq

Installation

 

Questions

Installation
How to install PHP on Apache?
How do I install Apache, MySQL, PHP on Linux?
I am trying to install GD + Truetype with PHP4, but all I get is libgd was not built with TrueType font support
How did you install PHP with --mcrypt and --mhash?
When using GD/PHP to create thumbnails using imagecopyresized the thumbnail quality is not very good.
Can I compile php with mysql without having mysql sources?
How do I install PHP as a CGI?
How do I stop spammers using header injection with my PHP Scripts? (Webmasters)
How can I get PWS (Microsoft Personal Webserver) to work?
I have errors trying to install libxml so I can use --with-dom for PHP (checking for DOM in default path... not found)?
How do I install Sablotron with PHP?
Is there a Windows version of MySQL?
Is there an archive that installs mysql,php4,apache and perl on a windows system?
What do I have to do to convert PHP3 pages to PHP4 pages? Are there any compatibility problems?
I'm trying to compile PHP 4.1.1 on a SunOS 5.8 box as a DSO module with mcrypt 2.4.18 (i.e. libmcrypt.so.4.2.8), I get loads of errors.
Installing MySQL Perl Modules DBI
How do I install Sablotron to work with PHP on Windows?
How do I install the PostGRESQL client librarys so PHP can talk to remote PGSQL servers?
What version should I install?
make install gives an error saying i need LoadModule line in httpd.conf but its already there
Use ereg_replace to replace only the first occurence of a string instead of all?
error: conflicting types for `XML_FEATURE_UNICODE'
How do I install Curl?
Installing ioncobe with php5.2.3 gives the error Failed loading ioncube_loader_lin_5.2.so: ioncube_loader_lin_5.2.so: undefined symbol: zend_hash_destroy
 

Return to the main FAQ list



Free Forum    
Design & Layout Copyright © 2000- 2006 PHP MySQL Web Hosting Comments to Webmaster
Hosted by PHP 4 Hosting - PHP and MySQL Webhosting and Domain Names