On Comment Spam
30 December 2008
I noticed an article on Slashdot today called Smart Spam Filtering For Forums and Blogs? where someone asks "Does anyone know of a good system for filtering spam".
In this post I reflect on comment spam and my approach to dealing with it.
Background
On this site I have previously talked about my past approaches to this topic:
- My original post on the subject was called 'only the penitent man will pass - on captchas and cotton wool', where I explained why I do not go in for 'captchas' or other party games that make it harder for you the reader to leave a comment.
- My next post was Akismet Blues where I discovered that a third-party comment judging service called Akismet was suddenly blocking everyone, due to the fact that the upstream changes in the service had broken the blog plugin I was using at the time.
- My third post on the subject was Django FreeComments cleanup script where I shared a command line cleanup script for Django FreeComments, a comments system that appeared in the previous version of Django.
Now I recoded the site to use Django 1.0 (read about that here), I had to make these decisions again.
Principles
The aim of this site is to have a discussion about the topics I raise. The comments are not some optional add on, they are core to what the site is about. Furthermore, my readers are busy people, who take the time out of their busy lives to share their wisdom, thoughts and views by leaving a comment here.
Therefore I respect that very highly. I have 1431 comments, I may not have responded individually to each of them, but I have read them all many times, and I have written SQL to move them each time I have changed blog software, backed them up, reformatted them, and so on.
This is a website about fairly advanced computing, which is aimed at adults. If someone can use a bash recipe or write a Python script, then if the comment spam fighting techniques fail, they have the intellect to handle a Viagra advert in the comments for a few minutes or hours.
Therefore my first principle is that the cost of a false positive is far greater than any number of false negatives. If there are false positives then they must not be permanent, and they must be easy to spot and reverse.
Secondly, as mentioned above, spam fighting should be server-side, it is my problem not yours - I am not into making the reader guess the word, jump through hoops or pin the tail on the donkey while blindfolded and spun around.
What is a spam comment?
The commenting system here is for discussing the topic and communicating with other readers. Linking to a resource that is relevant to the discussion is clearly not spam. Many people, while leaving a relevant comment, will link to their own website as a kind of signature. This is clearly not spam.
A person or script using the comment system to leave links to irrelevant websites for financial gain, with no comment or something extremely generic, is comment spam. So obviously context is important.
Catching by URLs
Most genuine commentators paste the URL in the post directly. Those that want to markup their text use the markup that I have specified.
Meanwhile spam comments have HTML or BBCode marked up links in them, from a few to dozens or hundreds of them. So comments with HTML or BBCode marked up links can be held for moderation. Comments with a large number of URLs can also be held for moderation. These little measures stop the most of the indiscriminate spam scripts sent from zombie machines.
Catching by IP
This leaves the more discriminate spammers, those who probe and test to try to see what goes or up not. These appear to send multiple spams from the same IP Address.
In the Image above, you can see the admin panel showing 18 comments held for moderation. Highlighted in red are 16 comments from the same IP Address. I moderate all the comments caught using a new version of my command-line tool. When a comment is confirmed as spam, it is deleted and the originating IP address is blocked, thus stopping repeat offenders.
Extra herbs and spices
I have some other ingredients to my spam fighting recipe, but at the moment they are not being brought into play because the above ingredients seem to do the trick. One advantage of using Django and Soturi is that I can quickly reprogram the site if my spam fighting recipe stops being effective.
Since this approach seems to work, I personally I have no desire to use some third-party service to filter my comments, because I have no easy way of knowing if or how it is likely to make false positives. Also being a technology site, people often write comments involving command line commands or source code which gets flagged easily in these filtering services.
Anyhow, that is my setup, I would be interested to hear what other people find useful.



1 Eion says...
Other than server-side processing of comments, I like to add additional <input>'s and hide them in external css. Most of the time the fields are populated by spam-bots, and if so, they get blocked.
No, not a perfect solution on it's own but just another feather in the cap against comment spam.
Posted at 2:20 a.m. on December 30, 2008
2 Bug says...
Well... Sadly, and I guess you hate me for it, I use captcha. But at least it's not an image, so even if you visit using w3m [yey!] you can comment. I know it's not perfect and it could get annoying... I thought about making a cookie of passing the captcha once grants you captcha-less life for as long as the cookie is alive, but I never got around to it [Along with the setting rewrite mod].
I guess creating your site from scratch has disadvantages [spam], but I still love the advantages, it lets me play around with it as much as I want.
Posted at 6:33 a.m. on December 30, 2008
3 Zeth says...
Hi Eion, Yes that is an interesting approach also. It is the only approach given by default in the stock Django comments module, though it does not stop all comment spam.
Bug, well the simple easy text-based question is not too annoying, and if the question rotates occasionally then it is quite effective.
Posted at 2:30 a.m. on December 31, 2008
4 bug says...
@Zeth: The hidden field does block some. Not perfect, but it does release some weight from the filtering system, as those are 100% false comments.
Acctually, if you would have tried to post comments or my webbie, you'd see that it doesn't change. I didn't see a reason to implant one, because as long as my webbie isn't boing boing or anything, it won't have hand made spam. This magical captcha of mine blocks the automated kind of spam. But if someone does manually code it, yeah. It'd be pain and I'd have to make the question change.
Posted at 7:46 a.m. on December 31, 2008
5 Ryan v. says...
Clever solution Eion. Sort of stumbled across a solution similar to that on my own (accidentally). Seems to be undefeated for the time being...
Posted at 12:03 a.m. on July 24, 2009
6 dahuletam says...
Having good content can only get you so far unless you also provide a good atmosphere to comment in
Posted at 7:43 p.m. on August 29, 2009
7 Sim says...
In relation to spam I think in most cases you need human judgment to decide whether it is a spam or not. I have used Akismet on my wordpress blog after hearing a lot of good things about it but I also think it is too too secure as their spam detecting system seems to be very strict. I don't mind linking to commenter as long as their comment is relevant to the post and is engaging with other commenter but some of these comments seem to be blocked off.
I do believe that many website owners comment for the purpose of building links towards their own sites however it does not necessarily mean they are spamming. As long as they are actually engaging with the blog post itself and with other commenter then it is not a spam.
Posted at 9:51 p.m. on September 15, 2009
8 expifesluse says...
Hi People How are you doing?
Posted at 6:29 p.m. on October 6, 2009