Page 1 of 3 123 LastLast
Results 1 to 10 of 28

Thread: Site Hacked

  1. #1
    dgwyer's Avatar
    dgwyer is online now Tavern Regular
    Join Date
    Jun 2010
    Location
    London, UK
    Posts
    230

    Icon4 Site Hacked

    Our site got hacked yesterday, which was a bit of a wake up call. Just wanted to canvas others on what levels of protection/Plugins etc. you use to prevent such attacks?

    I tried to password protect the wp-admin folder, but when I activate this in CPanel I then get a 404 error message when trying to access the WordPress admin. I gather this is something to do with WordPress permalinks (reading some similar WP forum threads)?

    I also installed the 'Limit Login Attempts' Plugin as an extra temporary measure.

  2. #2
    chipbennett's Avatar
    chipbennett is offline WordPress Legend
    Join Date
    Feb 2009
    Location
    St. Louis, MO
    Posts
    1,997

    Default

    Quote Originally Posted by dgwyer View Post
    Our site got hacked yesterday, which was a bit of a wake up call. Just wanted to canvas others on what levels of protection/Plugins etc. you use to prevent such attacks?

    I tried to password protect the wp-admin folder, but when I activate this in CPanel I then get a 404 error message when trying to access the WordPress admin. I gather this is something to do with WordPress permalinks (reading some similar WP forum threads)?

    I also installed the 'Limit Login Attempts' Plugin as an extra temporary measure.
    Some idiot in Amsterdam keeps trying to brute-force my "admin" username account on my primary site. I know, because I've gotten four "lockout" email notifications over the past couple of days.

    (And, yes: "admin" account. It's a bit of a honeypot. I've left it, as user ID 1, as "subscriber" user level. It attracts the script kiddies, and 1) keeps them from bothering with my real accounts, and 2) even if they brute-forced it, they'd get in, and not be able to do anything.)
    WP TurnKey - Turn-Key WordPress installation and maintenance services
    WordPress user since 2005 | @chip_bennett | chipbennett.net | cbnet Plugins

  3. #3
    Ipstenu's Avatar
    Ipstenu is offline Big Tipper
    Join Date
    Feb 2010
    Posts
    368

    Default

    One thing to bear in mind is you need to sort out what the vector of attack was.

    Most of my protection is server level. Mod Security, firewall stuff, securing my PHP settings, etc. I trust in the basic WP to be 'safe' from injections etc, keep tabs on my plugin security, and I use secure passwords.

  4. #4
    Ryan's Avatar
    Ryan is offline WordPress Legend
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,801

    Default

    We'd need more information about your site to be helpful.

    There's bazaillions of attack vectors but none of them should be usable if you are running on a secure host and with an unmodified up to date core (and no other software) and with secure plugins and themes.

  5. #5
    Ryan's Avatar
    Ryan is offline WordPress Legend
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,801

    Default

    The only thing I could see on your site that I knew was coded by you guys, was the Twist of Ten theme, so I went to check out the code to see if there was anything odd in there, but it all seems fine bar a minor issue with the form validation of your admin page. But it's pretty minor and is a problem present in many other themes and plugins too so is highly unlikely to be causing the problem you experienced.

    When validating forms like you have done in the functions.php, it's generally best to only pass the specific input fields you intended to enter through the validation function, whereas what you have done is to actually pass all of them without filtering except one.

    So the following:
    PHP Code:
    // Sanitize and validate input. Accepts an array, return a sanitized array.
    function tot_validate_options($input) {
         
    // strip html from textboxes
        
    $input['front_page_message'] = wp_filter_nohtml_kses($input['front_page_message']);
        return 
    $input;

    Should look something like this (note how $input goes into the function, but $output is what is returned)
    PHP Code:
    // Sanitize and validate input. Accepts an array, return a sanitized array.
    function tot_validate_options($input) {
         
    // strip html from textboxes
        
    $output['front_page_message'] = wp_filter_nohtml_kses($input['front_page_message']);
        return 
    $output;

    You could also revalidate the options on serving them onto the admin page too, just in case something nasty was injected. Some people do this, some don't. And the skill level of those who don't is often quite high (ie: Otto). Personally I err on the side of caution and prefer to over-sanitize the heck out of things like this just in case I screw up somewhere else and can at least mitigate the damage done if something does get hacked. To revalidate them you would just change the following line in your functions.php file:
    PHP Code:
    <?php $options get_option('tot_options'); ?>
    to this:
    PHP Code:
    <?php $options tot_validate_optionsget_option('tot_options') ); ?>



    As an aside (unrelated to security issues), you also use get_bloginfo( 'stylesheet_directory' ) whereas the recommended function is get_stylesheet_directory_uri() or get_stylesheet_directory() I think. You also have if ( ! function_exists( 'twistoften_setup' ) ): wrapped around one of your functions, which I find confusing since I wouldn't have thought that function would be present in anything but that theme.

  6. #6
    Ryan's Avatar
    Ryan is offline WordPress Legend
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,801

    Default

    I can see a major security flaw in one of the plugins you are using which would allow someone to launch an XSS attack on you if you had allowed them editor access. I'll PM you with the name of the plugin.

    EDIT: Sorry, it turns out that plugin has now been fixed.

  7. #7
    Ryan's Avatar
    Ryan is offline WordPress Legend
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,801

    Default

    Ok, via one of your plugins (with editor access) I can inject the following into your site.

    <script>alert('you have been hacked');</script>

    However, it is being injected into a link tag which I'm having difficulties breaking out of. But I'm sure someone with more technical knowledge (or a little more caffeine in their system) could figure out how to hack you via that fairly easily.

  8. #8
    dgwyer's Avatar
    dgwyer is online now Tavern Regular
    Join Date
    Jun 2010
    Location
    London, UK
    Posts
    230

    Default

    Quote Originally Posted by chipbennett View Post
    And, yes: "admin" account. It's a bit of a honeypot. I've left it, as user ID 1, as "subscriber" user level. It attracts the script kiddies, and 1) keeps them from bothering with my real accounts, and 2) even if they brute-forced it, they'd get in, and not be able to do anything.
    Good idea about leaving 'admin' account as a subscriber level! I will do that.

  9. #9
    dgwyer's Avatar
    dgwyer is online now Tavern Regular
    Join Date
    Jun 2010
    Location
    London, UK
    Posts
    230

    Default

    Quote Originally Posted by Ryan View Post
    Ok, via one of your plugins (with editor access) I can inject the following into your site.

    <script>alert('you have been hacked');</script>

    However, it is being injected into a link tag which I'm having difficulties breaking out of. But I'm sure someone with more technical knowledge (or a little more caffeine in their system) could figure out how to hack you via that fairly easily.
    Thanks Ryan, I'll check it out. I would have thought such a Plugin with massive download stats would be a little more secure!

  10. #10
    Ryan's Avatar
    Ryan is offline WordPress Legend
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,801

    Default

    There is an entire forum thread here dedicated to that issue. It doesn't look like it will ever be fixed.

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •