Seeing if your WordPress install has been compromised is easy. Simply view the source of your homepage and look for any code that does not belong. Check near the top and near the bottom of the file as this is the place I’ve found the hidden links to mostly exist. They’re also usually wrapped in HTML comments.
<span style=”display: none; text-decoration: underline;”>
<a href=”some_url”>Some website 1</a>
<a href=”some_url”>Some website 2</a> …
<a href=”some_url”>Some website n</a>
If you see code like that, chances are, you are a victim of the WordPress Hidden Link Injection exploit.
How are “they” doing this?
Apparently, there was a security hole in WordPress versions 2.8.x that allowed outside users to hijack the /wp-admin/upload.php file and insert files on your server that could be used for all sorts of malicious purposes. One of those purposes is the hidden link injection. WordPress 2.9 fixed this hole, however, simply upgrading is not enough. Outside users will no longer be able to hijackupload.php but the files that they have already inserted will still orchestrate the attack.
That’s why simply removing the links from header.php or footer.php (the two places I’ve seen the links) is not enough. You’ll notice that the links will simply reappear. We’ve got to treat the disease now, not just the symptom.
Fixing the problem
First and foremost, always keep your WordPress install up-to-date! Updating could not be any easier. Simply click on the alert that appears at the top of your Dashboard and follow the instructions. It takes literally 10 seconds.
Next, change the admin WordPress user’s password. Also change your MySQL user’s password.
Lastly, find the files that have been inserted by the exploit via upload.php. I have found two separate instances of these files, both located in the wp-includes folder. Check the permissions of each of the files in wp-includes and investigate any file that has 777 permission (that’s your first clue that something is wrong). class-rss.php and feed-atom2.php are two files that I have seen cause issues. Cleverly named files. These two files are not native to the WordPress codebase and can be safely removed. If you were to open either of these files and know a bit of PHP, you’ll see that these files are certainly the culprit.
Going through these steps should safeguard your WordPress installation against the hidden link injection exploit.
Just because we’ve fixed this does not guarantee that you’ll be immune forever. Hackers are constantly looking for newer and better ways to tear stuff up. WordPress has been exceptionally good at patching security issues, but someone somewhere has to be the guinea pig to get hit with an attack – and then report it to WordPress.
One great plugin I’ve begun to use is WordPress File Monitor. This plugin scans your WordPress installation and reports if any files have been added, deleted, or changed. The plugin is customizable to run on a schedule that you set. You can also exclude directories from the plugin’s reporting so that you’re not alerted every time you upload a picture to insert into a post. I, however, recommend that you do not exclude directories as that directory may be the next location of the next exploit.