Taking Security Seriously

Printer-friendly versionPDF version

I've had good reason to think about security on my Drupal sites lately. This site and a few others were hacked recently. The result of the hacking was a script injected into both the generated pages and the RSS feeds of the site. I picked up on the hack pretty fast because the RSS feeds on the site were not behaving correctly and that broke something else that relies on the feeds to work. I also checked the site in Internet Explorer and things weren't displaying properly.

I spent about an hour investigating the issues before I realized that the site had been hacked for sure. One of the first things I did once I realized that the site had been hacked was that I took it offline. Whatever the script that had been injected into the site was doing it couldn't have been good. Then I took steps to correct the situation.

Since multiple sites were affected I assumed that somehow an FTP user password (which I thought was obscure enough) had been compromised. So I changed every password I could think of. Then I uploaded the latest version of Drupal to all of my sites. Next I checked the directories to see if there were any suspicious files remaining. Finally I checked the site RSS feeds and pages for signs of the script that I had found when I discovered the problems. It was only after taking those steps that I brought the sites back online.

The process was time consuming and painful enough for me to cause me to remember how important security is for any type of site you put up on the web. I should've known better since I've been caught by spammers before, but it's been a long time so I got a bit complacent.

I'd like to pass on some tips (and links to related modules) that can give you an idea of some of the security features to take advantage of when you're using Drupal.

Make passwords obscure and change them periodically. Do it on your Drupal sites and also for your FTP accounts. Drupal has a nice password security feature (pictured below) in D6 that provides guidance on the obscurity of your password.

 

Password Strength Checker
 
Protect your site registration form, contact form and comments with anti-spam measures. I'm a fan of Mollom which I've been using to protect any form that allows anonymous submissions. Mollom has worked very well for me. Other options such as Akismet, Captcha and reCaptcha are available as well. The bottom line is that I would not take a site live that accepts anonymous submissions unless I had a module in place to prevent spam.
 
Mollom
Mollom Stats View
 
Block access to offending IP addresses if necessary. The Drupal logs allow you to see the IP address of people who are posting to your site. I had a commenter who was defeating the anti-spam features every time by putting in what looked like a legitimate comment with a link to a specific site. I fixed the situation by blocking the person's IP address in the Access Rules section of Drupal.
 

Access Rules

Manage input formats to only allow basic HTML (and no files) for anonymous submissions. I'm using the Better Formats module to give full HTML access to authenticated users but only limited formatting options to anonymous posters. This prevents anonymous visitors from submitting malicious code to your site.

Stay current with module and core updates.  I know that updating can be a pain, especially if you run multiple sites, but think of the possible consequences. If you keep an eye on http://drupal.org/security you will know why staying current is so important. Better to spend an hour keeping your sites current then three getting them back online after an attack. Thankfully the Drupal Status report makes the task of knowing your site status a painless one

Status Report

Drupal Status Report

I'm sure that there are many more great tips and modules that the community can offer up. So please feel free to add to the list in the (hopefully well protected) comments section.

Bookmark and Share Bookmark or Share Post

Comments

Anonymous's picture
learnbythedrop's picture

Since multiple sites were

Since multiple sites were affected I assumed that somehow an FTP user password (which I thought was obscure enough) had been compromised.

Anonymous's picture

I've heard of some

I've heard of some vulnerability from the host had made it possible for hackers to create ftp accounts and then hack sites to their hearts content. This is not related to Drupal or any of the password you might have used for your ftp account. This, I believe, has to also be considered.

learnbythedrop's picture

Notifying Web Host

One thing I did that I didn't mention in the post was to notify the web host in case the hacking was part of a larger attack. If the web host is repeatedly compromised then there's only so much I can do to protect the site. There are multiple opportunities for failure and all of them need to be adequately protected.

learnbythedrop's picture

Rootkit Hunter

I have not. I downloaded the project you linked to and will run it on the server soon. Thanks.

Post new comment

Important
All comments on this site are moderated to prevent spam. Although we also use the Mollom module we have found that some gets through and that also affects people who have subscribed to email notifications. If you would like your comment to appear immediately please login with Google Friend Connect which supports your Google, Twitter or Yahoo account.
Google Friend Connect (leave a quick comment)
Loading
The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
Mollom CAPTCHA (play audio CAPTCHA)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.