Site icon The Mac Security Blog

How to Clean Up and Secure Your Hacked WordPress Site

As we often state, the Web has been the great equalizer for attackers. Everyone, regardless of operating system, uses the Internet. Therefore, a lot of software is written that is usable by anyone who uses the Web, whether it’s via smartphone, tablet, or desktop OS. You can often use the same browser on your phone as on your laptop, and the same plugins usually work on both platforms, too.

Content management systems are another commonality between various types of Internet users, with WordPress being one of the most well-known CMSes available. Because of its immense popularity, attackers know that exploiting it is just as effective as finding an exploit on the popular OSes. WordPress is an easily mined treasure trove for would be-attackers.

How can you protect your WordPress-powered blog or website from being compromised? In this post we’ll talk about what kinds of attacks take advantage of content management systems and what you can do to protect yourself.

How Do Threats Infiltrate WordPress?

WordPress offers a couple options for using their product. You can either opt to let them host it and deal with applying updates, or you can choose to host it yourself. Many people choose to host their own WordPress installation or hire a third party to host for them, for the flexibility and customization that it allows. WordPress updates are fairly frequent (like most web-related software) and each release generally includes several security improvements. And, unfortunately, a lot of people are pretty slow about updating.

While the rate of Oracle and Adobe CVEs assigned is a whole lot higher than WordPress, Oracle and Adobe’s update processes are also a lot louder and potentially more automated for most users. (One of the dangers of marketing products as easy and newb-friendly: If you don’t also automate security updates, they likely won’t happen.) And then there’s the plethora of plugins and themes that are available out there; it’s one of the biggest draws for users, but it also presents a fairly large attack surface. Much as more moving parts in a machine means more things to break, more modules in a website (especially those that are not thoroughly vetted) can mean more ways to break into your blog.

Because WordPress is web-facing, it’s fairly trivial for attackers to use Google as a tool to scour the Web for insecure installations or modules. So all those blogs out there that have failed to do timely updates are all lined up, waiting for attackers to have their way with them. It’s no surprise when malware that uses this tactic is wildly successful. Beyond that, there’s also the good old-fashioned breaking-and-entering approach, which could mean breaking into your machine directly, or stealing your account credentials in some way. It’s sort of the familiar theme with all things security-related: If your software is outdated, or your administration-hygiene is not so great, attackers will get in and make your life unpleasant.

What Do They Do?

There are two main types of modifications attackers make on insecure installations. The first is kind of like a burglar sticking something very small and discreet in a doorjamb to keep the lock from catching, so that they can return whenever they please to do whatever they please. In short, they amend your page to add a backdoor. The second type is meant to affect the visitor’s experience, usually in a way that brings the attacker money. This can either include redirects (such as to an ad or malware on another site) or drive-by downloads that silently install malware on visitors’ machines. It could also be a simple defacement that’s the digital equivalent of spray painting graffiti on a wall, but those tend to be easy to spot and fix. Whether the modifications are creating a backdoor or affecting vulnerable visitors, they do this by adding scripts to your pages. These are usually very tiny (so you would hardly notice the change), or heavily obfuscated (so that it’s hard to tell what it’s doing). Unless you regularly check the source code for all your various website bits and pieces, you might not notice that something was amiss until people start complaining of strange behavior.

How Can I Stop Them?

As you might have gleaned from my earlier description, this is mostly solvable by simple security precautions. But it’s somewhat complicated for a couple of reasons. If you’re relying on a third party to host your installation, it can be difficult to motivate them to do the right thing, if they’re not already so inclined. This is one of those times where “voting with your pocketbook” can be very effective; if your current host is unwilling or unable to protect your site, it may be time to find a new one. If you’re hosting it yourself but your neighbor’s cousin set it up as a one-time deal, and you know nothing about how to properly secure your installation, it may be time to hire someone who can manage your site securely. But if you’re somewhere in the middle and are willing and able to do a little work to tighten up your security, here’s a few tips:

How Can I Clean Up?

If you’re reading this in the aftermath of a compromise without recent backups, you may be in for quite a bit of work. If you had the foresight to duplicate your data beforehand, this is where your present-self is going to want to give your past-self a big high five for being so terribly clever. Assuming you’ve not made a good backup, you will need to take a more careful and thorough approach. Google has posted a fantastic, easy-to-understand description of what to do if your website has been hacked, which works excellently well for any sort of webserver, not just WordPress.

With a good backup, you can take a more scorched-earth approach, and replace scanning and checking everything with simply clearing off your machine. After taking your machine offline, it’s now time to…

Whether you restore from backup or reinstall from the ground up, you will now need to harden your installation to make sure this doesn’t happen again. And you’ll still want to go on a password-changing spree to make sure all your bases are covered before bringing your site back up. In the end, it’s a sucky fact of life that information security is getting so complicated, and that it’s disproportionately affecting the people that will find it most painful to recover from an attack. Having your website hacked can be a difficult and time-consuming thing to deal with. Hopefully this guide will help you prevent such a thing from happening, or help you get your blog back up and running as quickly as possible.

Share this: