July 15th, 2009

Why you should limit login attempts

WordPress, by Donncha.
limit-logins

Some idiot at 213.155.4.184 hit all my websites over the last few days trying to login to my blogs. He fired off hundreds of automated requests probing and searching and testing my admin login. Each request had a different password. I use difficult to guess passwords but seeing the attempts was disconcerting.

I went searching and found the Limit Login Attempts plugin. After installing, a new page appears under Settings with a wealth of options:

lockout

I’m glad I did install it, it caught the same guy when he hit this blog a few hours later! You should probably install it too.

PS. Matt asked me to explain how I recorded those requests. There is a WordPress plugin that sends an email when a POST request is made but I threw this code into a file and load it with the “auto_prepend_file” directive in my php.ini (saves adding it to every installation of WordPress on my server)

if ( ( isset( $HTTP_RAW_POST_DATA ) || !empty( $_POST ) ) && $_SERVER[ 'REQUEST_URI' ] != '/wp-cron.php?doing_wp_cron' && $_SERVER[ 'SCRIPT_NAME' ] != '/wp-comments-post.php' && substr( $_SERVER[ 'REQUEST_URI' ], -10 ) != '/trackback' && substr( $_SERVER[ 'REQUEST_URI' ], -11 ) != '/trackback/' ) {
    mail( "MYEMAIL@gmail.com", $_SERVER[ 'HTTP_HOST' ] . " POST request: " . $_SERVER[ 'REMOTE_ADDR' ], "URL: {$_SERVER[ 'REQUEST_URI' ]}\nPOST: " . print_r( $_POST, 1 ) . "\nCOOKIES: " . print_r( $_COOKIE, 1 ) . "\nHTTP_RAW_POST_DATA: $HTTP_RAW_POST_DATA" );
}

You might also like

If you like this post then please subscribe to my full RSS feed. You can also click here to subscribe by email. There are also my fabulous photos and funny videos to explore too!

Back Top

Responses to “Why you should limit login attempts”

  1. I’d agree, Limit Login Attempts is on my “standard” list of plugins to install.

    If possible, I’ll further protect the login and admin areas with HTTP authentication to stop this kind of hammering attack before it even gets to Wordpress.

    John Girvin at July 15, 2009 10:18 am
  2. Some dude had a go at one of my sites the other day as well. I killed him with htaccess. This looks cool though, I will look at installing it.

  3. never tot of it! thanks for the info :)

    Liew Cheon Fong at July 15, 2009 10:25 am
  4. Its better to change the default username to something else then admin, that should the trick.

  5. Another vote for adding this to WP core!

  6. Thx for this plugin.
    This one should be in basic WP install. It’s really handy.

  7. BTW
    What plugin do you use for
    *Notify me of followup comments via e-mail?
    Thanks :)

  8. So doesn’t this mean that you’re emailing yourself your username and password every time you log in? That seems like a security risk that’s much more likely to be exploited than someone guessing your password at random.

  9. I just block everything from the Ukraine as well as a few other countries. It’s a drastic measure but none of my websites are aimed at those countries anyway.

    It’s been unbelievable how much it has reduced all the various crack attempts. Naturally such a measure won’t suit everyone though.

    • You block entire countries from accessing your website because you have some problems with crackers and spammers?

      Nothing on my website is “aimed at those countries” either, but I would never dream of such drastic and completely unnecessary measures. You seriously need to re-evaluate your approach there Robert.

      johnbillion at July 23, 2009 2:09 am
  10. Probably not suitable for everybody. I’ve limited access to wp-login.php and admin.php by adding an IP filter in .htaccess.

    Stilettogirl at July 15, 2009 1:20 pm
  11. Another idea is to edit your wordpress database and change the admin username from “admin” to something else. I have done that for my school district’s web site as well as local school sites. So, even if someone happens to know the password, they’ll toss and turn to figure out the username. Then, limit login will hammer it down! :)

  12. Thanks for the tip. I went and installed a similar plugin (Login Lockdown) after reading this. I’ve also done what Patrick suggested, and deleted the “admin” user after setting up another admin account with a different name.

  13. Thanks for the heads up and for sharing this useful information!

    Btw, I’ve been using a WP plugin called Login Lockdown that can limit a number of unsuccessful login attempts (brute force attacks), I guess it works just like or has the same concept as the Limit Login Attempts plugin that you’re using.

  14. Thanks for the tip Donncha! Using the plugin now :smile:

  15. Hi

    Could you go into some more detail regarding the logging of the failed login attempts. I would be interested in knowing if this is happening to me also.

    Thanks
    Will

  16. Great tip, this should be a default plugin for any Wordpress user

  17. You might also want to check out my Login Error Cleanup plugin. It doesn’t tell a user if they got the username or password wrong when they try to login. http://www.planetmike.com/plugins/lec/

    Michael Clark at July 15, 2009 5:49 pm
  18. where does this plugin store the failed logins? mysql?

    i wrote something a while back that limits logins much like this but using eaccelerator.

  19. Thanks for this tip. I isntall this plugin to my media blog. :)

  20. Wow, great plugin. fast instal and simple to use. I could write to my media blog of this plugin. Sorry, poor English. :)

  21. Brute force protection should be a standard feature of WordPress if you ask me!

    Peter Sweeney at July 15, 2009 7:13 pm
  22. I use Login Lockdown, which accomplishes pretty much the same thing — not sure which plugin is better, since I haven’t tried Limit Login Attempts.

    Lucas McDonnell at July 15, 2009 7:56 pm
    • Login Lockdown is in my list of standard plugins to use on every WP install. Very similar functionality to Limit Login Attempts from the looks of things.

      johnbillion at July 23, 2009 2:14 am
  23. We should add something like this to core IMO. It’d improve security across the board.

  24. It should indeed be core, isn’t really a massive feature but sure as hell works. Thanks for the plugin link.

    Matt Rogowski at July 15, 2009 10:57 pm
  25. Yup, hardening WP/WPMU installs always include changing admin username to something else, plus adding the “login error cleanup” plugin and the “login lockdown” plugin and the htaccess thingy :-)

  26. Unfortunately I did not have all of the Ukraine firewalled like I mentioned in my earlier comment.

    I’ve just had the same IP address trying to bruteforce my blog 3006 times in the past two hours!

    He’s blocked this time around though.

  27. Just to be extra paranoid and annoy the bots, I added a http auth login around wp-login.php on my other VPS. This one uses fastcgi which doesn’t support it unfortunately. (Yes, I could do it in a few .htaccess rules but I don’t have the time to dig into that right now!)

  28. Never knew this was not in the core of Wordpress. This is a basic feature of authentication system to block access after 3 wrong attempts.

    This SHOULD GO INTO CORE !!!!

    Ashish Mohta at July 16, 2009 12:20 pm
  29. Somebody performed similar attacks on my blog too, a week ago.
    Sad.

    Piyush Shekhar at July 16, 2009 2:32 pm
  30. It is incredible: today, my blog Journal de Cuba (in french) had been victim of the same attack and by the same IP !!! This idiot from Namibia did 593 unsuccessful attemps to login. This morning I install the plugin, thank you Donncha for the tips.

    David Chapet at July 17, 2009 7:24 pm
  31. wow! that is very dangerous.
    Have to install the plugin immediately to all my wp blog.
    thanks for the alert.

  32. IP Tried to log in as
    213.155.4.184 admin (1 lockout)

    Same IP at my site. Good i’ve installed Limit Login Attempts when i’ve saw this post.

    Thank you Donncha

  33. Add this line to your theme’s functions.php file to hide login error messages:

    add_filter(‘login_errors’,create_function(‘$a’, “return null;”));

    That way they can’t tell if they got the username or password (or both) wrong.

    Adam Pieniazek at July 23, 2009 5:41 pm
  34. Guess what? The same guy from the same IP is trying to get into my WordPress too. Detected after installing this plugin.

    Vincent Chow at July 25, 2009 1:10 pm
  35. I had the same issue from 213.155.4.184 hitting me 3,500 times. CPanel also shows this, and allows you to block ips or ip ranges.

  36. Login attempts shoud be limited to prevent any kind of intrusions.

    Piyush Shekhar at February 14, 2010 9:55 am
  1. Limit login, limita el número de logins de tu blog | aNieto2K (,July 15, 2009)

    [...] publica un interesante artículo en el que nos cuenta un problema que muchos hemos [...]

  2. Changing User Nice Name | Hugh Johnson (,July 15, 2009)

    [...] reading about Donncha’s experiences with the Limit Login Attempts plugin I decided it would be a good idea to implement it on my blog. [...]

  3. links for 2009-07-15 at So It’s Come To This: (,July 16, 2009)

    [...] Why you should limit login attempts (tags: wordpress security advice howto plugin) [...]

  4. Protecting wp-config.php files - is it possible? - WordPress Tavern Forum (,July 16, 2009)

    [...] In this situation, having a secure password and doing something to limit login attempts (per the recent post on the subject) is probably better (in terms of convenience, not security) than using an IP based access denial [...]

  5. Is your blog protected against brute force attack ? | Svetoslav Marinov's Blog (,July 17, 2009)

    [...] Donncha O Caoimh's posting has 2 really good ideas. [...]

  6. RSS Week #62: letture per il weekend - Matteo Moro (,July 25, 2009)

    [...] Why you should limit login attempts [...]

Leave a Reply

Back Top


Holy Shmoly! is Digg proof thanks to caching by WP Super Cache