I run several sites off Mediawiki, and the spam problem has been getting progressively worse recently.

Making the wiki ‘registered users only can edit’ helps a bit, but most of the spambots can get around that now. In fact most seem to get around the ‘easy rollback’ of recently registered users changes by creating their spamming accounts quite some time before actually using them to spam.

Most of the spam I get is of a particularly useless kind. It’s wrapped in a div set with a style of “overflow:auto;height:1px;”, which makes it invisible on the page. However, as most recent releases of MediaWiki also default to adding a “nofollow” to external links, this means that the spam links get no googlejuice either.

Although useless to the spammer, it’s highly irritating to wiki admins. However, there is a particularly simple fix.

In your LocalSettings.php, just add one line:

$wgSpamRegex="/overflow\s*:\s*auto/i";

Now any attempt to include text that matches in an edit causes the edit to fail.

I’m sure this is documented somewhere, but I only came across it on one of the mailing lists. So I’m offering it out here in the hope that some other plagued mediawiki admin can cut back their admin burden too.

Comments

8 Responses to “Mediawiki spam”

  1. Eric on March 27th, 2006 9:44 pm

    Hi, I just wanted to drop you a note that this was incredibly useful to me just now - the mediawiki I was just tasked with admin’ing was having a flux of spam of exactly the sort you describe, and I think this edit will take care of it. Thanks!

  2. Ed on March 28th, 2006 2:18 pm

    Thank you!!

    Before last week, they would attack, disappear, I would clean it, and we’d repeat a month later.

    This week they were very persistent, hitting the same pages over and over.

    Thanks for the salvation!
    Ed

  3. Jacques Lema on March 28th, 2006 11:23 pm

    Thanks you, this really saved my day. Those suckers really ruined my newly created wiki.

  4. ChocoFlop - Live! Image and Photo Editing for Mac OS X » Blog Archive » Bloody spammers on March 28th, 2006 11:26 pm

    [...] For all those looking for a peaceful solution on block these invisible texts added by spambots, Read this post. [...]

  5. DooMAD on April 2nd, 2006 9:37 am

    The fix is working perfectly, there hasn’t been a single piece of spam since. I’ve also passed it along to a few other wiki admins. Thank you.

  6. Nabeel Aejaz on May 3rd, 2006 11:21 am

    Thank you so much. It was a great help to end this nuisance.

  7. Rage on Omnipotent » Blog Archive » Wiki anti-spam on August 25th, 2006 9:43 am

    [...] One stop fix for most “hidden divs” [...]

  8. Gordon Morehouse on October 11th, 2006 7:13 am

    Please see http://wiki.evernex.com/index.php?title=Blocking_Spam_in_Mediawiki for a HOWTO on blocking spam in MediaWiki.

    I keep it updated fairly often and run a fairly active small wiki on which I’ve successfully been able to go back to an open edit (no account required) policy. Successful spam attacks in the last 6 months: 0.

Leave a Reply