Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blocking spam in a PHP site without bothering the user

I'm currently working on a little chat/forum site that I roughed out in a weekend, and it has anonymous entries (i.e.: no usernames or passwords). This looks like it could be easy-cake for a spammer to ruin, but I don't want to bother the user with captchas or similar anti-spam inputs.

Are there any invisible-to-the-user alternatives to these? Thanks for your help.

like image 757
SpleenTea Avatar asked Aug 02 '09 04:08

SpleenTea


1 Answers

One thing you should know about spammers is they always go for the low-hanging fruit. Same with hackers. By this I mean they'll pick the easiest to hit targets that affect the most users. This is why PHP and Windows vulnerabilities are often exploited: they affect so many users that if you find such a weakness/exploit your target "market" is huge.

It's also a big part of the reason why Linux and Mac OSs remain relatively unscathed by viruses for example: the target market is much smaller than Windows. Now I'm not equating the security and robustness of Windows with Mac/Linux but even though the security model of the latter two is much better the number of attacks against the former is still disproportionate with the deficiencies it has.

I say this because one of the best ways to avoid these kinds of problems is not to use popular softare. phpBB for example has had lots of attacks made against it just because it's so popular.

So by doing your own chat/forum system you're at a disadvantage because you have a system that doesn't have the field-testing something popular does but you also have an advantage in that it isn't worth most spammer's time to exploit it. So what you need to watch out for is what can automated systems do against you. Contact forms on Websites tend to have recognizable markers (like name, email and comment fields).

So I would advise:

  • Ignoring responses that come within say 5-10 seconds of sending the form to the user;
  • Using a honeypot (CSS/JS hidden fields as described elsewhere);
  • Using Javascript where applicable to render, reorder or display the form;
  • Using non-predictable form field names; and
  • Throttle bad responses by IP.
like image 58
cletus Avatar answered Sep 21 '22 09:09

cletus