WordPress Brute Force Attacks
WordPress’ popularity not only attracts bloggers but also hackers. Hackers try to compromise
WordPress installations to send spam, setup phishing exploits or launch other attacks.
While there are many sophisticated attacks against WordPress, hackers often use a simple brute force password attack. In these attacks, botnets try to guess your admin password. We’ve seen this happen on servers of our Managed WordPress Hosting customers.
You may think that such attacks would fail, but they exploit one of the weakest links in the security chain: You.
People don’t like complex passwords. As a result, low security passwords get put into production. Even if you have good password policies and use password management tools (I use LastPass), simple passwords slip through. This is why I like security in-depth.
By adding an extra layer of security to your systems, you can stop WordPress brute force attacks.
Stop Attacks with HTTP AUTH
WordPress actually has a great list of WordPress hardening tips. Some of these are complex and require server level or code level changes. However, in my experience brute-force and XSS attacks against WordPress are common exploit tactics. Simply by blocking access to the login and admin areas using HTTP Authentication, you can add an additional layer of security.
You are probably already familiar with HTTP AUTH. Many people refer to it simply as password protecting a directory or site with .htaccess. Technically, when you add these directives to .htacess you are enabling the HTTP authentication tools built into the Apache web server.
By setting up a htaccess to limit access to WordPress login functions, you can stop most brute force attacks.
Setting up HTTP AUTH
I recommend limiting access to the wp-login.php to stop WordPress brute force attacks.
You can do this easily by setting up htaccess password protection.
There are plenty of tutorials online about how to set up htaccess files and generate the password files. Plesk, cPanel and other systems often have this built into their control panels. So I am going to assume you know how to set up htaccess and setup a htpasswd file (if not Google is your friend).
Also, I recommend you use different usernames and passwords for the htaccess and your blog.
Once you have your password file setup, you need to add the following to your htaccess file:
# Protect wp-login <Files wp-login.php> AuthUserFile ~/.htpasswd AuthName “Private access” AuthType Basic require user mysecretuser </Files>
These settings will cause an additional HTTP pop-up before you login to WordPress.
You will need to enter the username and password you setup in your htpasswd file to get passed this box. Once you login to here, you will then see the normal WordPress login screen.
Note that the username and passwords used in your htaccess files have nothing to do with those used in WordPress. If you have multiple bloggers, you could use a single username and password for the HTTP Authentication phase and then have the bloggers use their own access details to log into WordPress.
How this Stops Brute Force Attacks
Brute force attacks against WordPress often simply post username and password directly into the wp-login.php script. You can spot this easily by checking your logs:
126.96.36.199 - - [16/Jan/2014:02:08:13 -0700] "POST /wp-login.php HTTP/1.1" 302 4477 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 7.1; Trident/5.0)" 188.8.131.52 - - [16/Jan/2014:02:08:15 -0700] "POST /wp-login.php HTTP/1.1" 302 4479 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 7.1; Trident/5.0)" 184.108.40.206 - - [16/Jan/2014:02:08:15 -0700] "POST /wp-login.php HTTP/1.1" 302 4487 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)" 220.127.116.11 - - [16/Jan/2014:02:08:15 -0700] "POST /wp-login.php HTTP/1.1" 302 4643 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)"
In this case, the 18.104.22.168 IP address is repeatedly trying to login to WordPress.
With the HTTP Authentication added, you block the attack. The POST request above will succeed only if they guess the HTTP AUTH username and password.
You may ask, “Well couldn’t they just try to brute force the HTTP AUTH?” Yes they can. But most botnets are not setup to do this. Also, for these types of attacks, it would be more efficient for them just to move on to another server then try to hack through two passwords.
For more details, check out WordPress’s own Brute force attack section.
Why Not Use a Security Plugin?
There are many WordPress security plugins that attempt to automatically block such brute-force attacks. While these may work, I generally do not recommend them unless they provide significant other benefits.
- The plugins still rely on PHP code. The protection is only as good as the code.
- The brute force attack still executes through the PHP layer. Under high rates of attack, this can cause load issues.
- Security in-depth. The likelihood of an exploit occurring simultaneously Apache’s authentication methods and in WordPress is low.
If you implement HTTP Auth on your login page, you can basically block brute force attacks on WordPress. While there are plenty of other security concerns, you can not worry about a WordPress brute force attack Want more tips? Though getting a bit old check out our 7 Tips for a Fast and Secure WordPress Blog.
A tool we use is ManageWP. This tool lets you monitor, update and even post to multiple blogs from one location. Be sure to check it out if you manage multiple sites.