Site Overlay

WordPress Security Tips

Wordpress Security Tips
Wordpress Security Tips

As the WordPress is getting popular and used by many people, now the hackers are also being active and involved in hacking wordpress site. I have recently received lot of request to fix the WordPress hacks. I would like to list some WordPress Security Tips to help you protect from hacks.

  1. Keep up to date with the latest WordPress Version: Always keep your WordPress site updated with the latest version of WordPress. The WordPress developers do not maintain security patched for older WordPress versions. In February 02, 2016, WordPress released version 4.4.2 as the Security and Maintenance Release. Older version of WordPress is more open to hacks.

    My Tips: Regularly update your WordPress site. You can use the plugin “WordPress Automatic upgrade” or Instant Upgrade Plugin Further, you need to keep your plugin and theme to be up to date as well.

  2. Populate wp-config.php Properly: Go through each line in wp-config.php, not only the first block for database configuration.

    My Tips: Use WordPress secret key generation tool to generate random salts for WordPress cookies. These keys are used to insure better encryption of information stored in WordPress user’s cookies. To make it more secure modify the the WordPress table prefix to something other than wp_. Adding random characters and numbers to the end of wp, such as wp52sk1_ obfuscates it enough but still allows you to recognize the tables as those belong to WordPress.

  3. Correct File Permissions: You should give the correct file permission and if you give full permission to files and folders then the hackers can hack it easily.

    My Tips: Set the permission as follows:All folder permissions should be set to 755All files permissions should be set to 644Files that you want to edit in the WordPress Theme editors permissions should be set to 666. Never ever use 777 for WordPress permissions.

  4. Don’t Use the Default admin Username: WordPress is open source application and now most of people know that it has the administrator username as admin. This make it easy for hackers to to hack the password when they already know the administrator username.

    My Tips: Change the default administrator username admin to something else. Now i am going to show how to change the default admin username. You may use phpMyAdmin and paste the SQL command (the update line) to execute it.update wp52sk1_users set user_login=’myadmin’ where user_login=’admin’;wp52sk1_ is the database prefex that I change. The default prefex is wp_Alternatively, you may edit the value manually using phpMyAdmin web interface. Now your admin user is myadmin instead of admin

  5. Pick Secure Password for Admin: Changing your admin username to something else is not a guarantee that people will not be able to guess it. For instance, if you use your username as the displayed meta data in every post, or you enable author specific page in multi-author blog, you will reveal your user name to the world.

    My Tips With this assumption, you should pick secure password for your WordPress login. Combine upper and lowercase characters and numbers.

  6. Hide WordPress Version in the Header Tag: Although you have deleted the WordPress version meta data from your theme, you may still get WordPress version line in the page returned by the blog software. The culprit is, since version 2.5 WordPress has added the feature to generate this code. This will allow the hacker to know about the wordpress version you are using which will help them to hack it.

    My Tips: Add the following line to the functions.php file in your theme directory: (Create a blank PHP file with this name if your theme doesn’t already have one)

    <?php remove_action( 'wp_head', 'wp_generator' ); ?>

  7. Nobody should be allowed to search your entire server: If you allow then the hacker will find the way to hack easily.

    My Tips: Do not use the following search code in the search.php in your theme folder:

    <?php echo $_SERVER ['PHP_SELF']; ?>

    . Use the following instead:

    <?php echo esc_url( home_url( '/' ) ); ?>

    Also block WP-folder from being indexed by search engines, the best way to block them is in your robots.txt file. Add the following line to your list:

    Disallow: /wp-*

  8. Prevent directory listing: The problem in many cases, the default WordPress installation allows hackers to use their web browser as a file browser to look through the contents of the folder on your server. Normally it is harmless but some web hosts don’t even bother to turn off directory listing by default. This means that there are several things hackers can do. There might be loop hole in the theme and plugin you used for your site. The author of the plugin and theme might have made mistakes in their code that allow unexpected access, hackers can use your directory listing to find out if you have got those vulnerable files and then attack your site. Also people can browse the non-WordPress contents of your web server to discover folders and files that you might not be ready to announce that you thought were not accessible to the general public. Many directory listing feature a line in the footer telling visitors your server version. Hacker can cross-reference these version numbers with list of known vulnerabilities and bring your site down or gain illegal access.

    My Tips: Edit the .htaccess file and add the following line at the bottom.
    Options All –Indexes

  9. Protect WordPress Administration Files: WordPress administration files are in wp-admin directory of your WordPress installation, except wp-config.php.

    My Tips: Use .htaccess to restrict access and allow only specific IP address to this directory and file. If you have static IP address and you always blog from your computer, this can be an option. If you don’t know you IP address then you can find your IP my visiting the site: http://whatismyip.com/You need to put a .htaccess file in wp-admin and add the code. See the Example:
    Order Deny,Allow
    Allow from 202.79.40.130
    deny from all

    For more refer to Apache’s documentation on mod_access to see the example: Protecting The WordPress wp-admin Folder

    Alternate Solution through user and password combination: There is another way to protect wp-admin directory with user and password combination. It also adds another level of security. Apache has complete information on authentication, authorization and access control. Example:

    AuthType Basic
    AuthName "WordPress Dashboard"
    AuthUserFile /home/user/.htpasswds/blog/wp-admin/.htpasswd
    Require user adminuser

    and then generate the encrypted password using the htpasswd command.

    $ htpasswd –cm .htpassed adminuser

    If you have cPanel then it is very easy as it has a feature called Web Protect which allows you to accomplish the same thing.

    Note: if you find it hard to use it in code then just use this plugin AskApache Password Protect

    Further, I recommend the plugin Login Lockdown plugin which record the IP address and timestamp of every failed WordPress login attempt. If more than a certain number of attempts are detected within a short period of time from the same IP range, then the login function is disabled for all requests from that range. This helps to prevent brute force password discovery.

    Note: the Htaccess and Htpasswd generator helps to create the necessary files with desired values.

  10. Restrict File Access to wp-content Directory: The wp-content directory contains your theme, plugin files and uploaded. WordPress doesn’t access the PHP files in the plugins and themes directory via HTTP. the only request from web browser are for image files, javascripts, and css. For this reason you may restrict wp-content so that it only allows those file extensions but not PHP or any other file extensions. This prevents people from accessing any files directly.

    My Tips: Include the following lines in .htaccess within wp-content:
    Oder Allow, Deny
    Deny From all
    Allow from all

  11. Take regular backups of your site and Database: No matter how hard you protect your site there might be some loop for hackers. There is never 100% security when it’s online.

    My Tips: Take regular backups of your file directories as well as the database. So, if there is any problem then you can just upload the backup copy. Use WordPress Database Backup plugin or WP-DB Manager to backup your Database and User WordPress Backup Plugin to backup your upload directory (images), current theme directory, and plugins directory.

  12. Stop worrying about your wp-config.php file: During the server problem, I have seen in one of my friend blog that his wp-config.php file can be viewed in the browser and his database username and password are there and it can be hacked anytime.

    My Tips: You can secure your wp-config.php by adding the following to the .htaccess file at the top level of your WordPress install:deny from allThis will make it harder for your database username and password to fall into the wrong hands in the event of a server problem.

  13. Protect Your Blog With a Solid Password: Easy password with alphabetic and number can be hacked using the software easily.

    My Tips: Creating a strong password that is also memorable is one of the easiest defenses against being hacked. Use strong password my combining the alphabetic, numbers and symbols. There are a lot of online password strength checker that you could check.Also you might check lorelle’s article on blogherald called Protect Your Blog With a Solid Password , offering tips and tricks to help create a strong password that is also memorable, and how to deal with all the myriad passwords we seem to accumulate online.

  14. The following plugins will be very helpful:
    • WordPress Exploit Scanner: It searches the files on your website, and the posts and comments tables of your database for anything suspicious. It also examines your list of active plugins for unusual filenames.
    • AntiVirus Plugin: It is a smart and effective solution to protect your blog against exploits and spam injections.
    • WP Security Scan Plugin: It scans your WordPress installation for security vulnerabilities and suggests corrective actions.
    • Admin SSL Plugin: Recommended only for the advance users. It secures login page, admin area, posts, pages – whatever you want – using Private or Shared SSL. Once you have activated the plugin please go to the Admin SSL config page to enable SSL, and read the installation instructions.
  15. Further reading:

    Hardening WordPress

    FAQ My site was hacked

    10 Steps To Protect The Admin Area In WordPress

Published By:

Author: sakinshrestha

Hello. My name is Sakin Shrestha, and I am a technology entrepreneur from Nepal. I am passionate about helping this sector grow, for many reasons. The technology sector creates jobs for many young Nepalis who would otherwise migrate to foreign countries. It lets Nepali professionals develop skills for a fast-changing global workplace, and compete at a high level with anyone, anywhere in the world. If it grows, it will provide a viable career option for many young Nepalis, and help us reap the benefits of a global economy.

11 thoughts on “WordPress Security Tips

  1. New version 2.8.5 have been released. So, I would like to recommend that all sites are upgraded to this new version of WordPress to ensure that you have the best available protection.

    Further, you can also add WordPress Exploit Scanner. This plugin searches the files on your website, and the posts and comments tables of your database for anything suspicious. It also examines your list of active plugins for unusual filenames.

    -sakin

  2. Thank you Sakin!, very useful advices, often my WordPress sites are hijacked by malware, the only thing I did was changing cpanel username passwords. I’ll incorporate these techniques to my sites. Thanks again!

Comments are closed.