WordPress is renowned for its usability and ease of access, however it’s popularity also makes it an attractive target for bad actors. This WordPress security guide is an introduction into how to protect visitors, mitigate threats, and create a more secure WordPress site.
Recent statistics show that over 28% of website administrators across the web use WordPress. Its popularity comes at a price; often targeted by malicious hackers and spammers who seek to leverage insecure websites to their advantage.
WordPress security is about risk reduction, not risk elimination. Because there will always be risk, securing your WordPress site will remain a continuous process, requiring frequent assessment of these attack vectors.
The question of whether WordPress is secure or not depends entirely on you, the website owner. Website security is about risk reduction. Follow our WordPress security best practices to harden and protect your website from threats.
This guide is intended to educate WordPress administrators on basic security techniques and actionable steps that will help to secure your WordPress site and reduce the risk of a compromise.
In This Guidex
The WordPress security team works diligently to provide important security updates and vulnerability patches. However, the use of third-party plugins and themes exposes users to additional security threats.
By regularly installing the latest versions of core WordPress files and extensions, you can ensure that your website possesses all of the prevailing security patches and your WordPress site is more secure.
Plugins and themes can become deprecated, obsolete, or include bugs that pose serious security risks to your WordPress website.
To secure your WordPress installation and improve security, we recommend that you audit your plugins and themes on a regular basis.
Assess Your Plugin Security
You can assess the security of WordPress plugins and themes by reviewing a couple of important indicators:
Carefully read the Terms of Service – it may include unwanted extras that the authors didn’t advertise on their homepage. If the plugin or theme doesn’t meet any of these requirements or has recently changed owners before the latest update, you may want to look for a more secure solution for your WordPress site.
Sometimes bad actors will purchase a plugin to add malicious or unwanted functionality. Exercise caution when installing plugins that have recently changed owners before the latest update.
Remove Unused WordPress Plugins & Themes
When it comes to unused plugins, less is more. Storing unwanted plugins in your WordPress installation increases the chance of a compromise, even if they are disabled and not actively being used in your installation. Removing unused plugins and themes helps improve security and protects WordPress from hacking.
Not using that WordPress plugin? Remove it from your installation.
When a new WordPress update is available, you’ll be notified in the Dashboard > Updates menu.
You should always apply updates as soon as possible to keep your WordPress site safe & secure. Logging into your site on a frequent basis will ensure that you’re aware of updates as they are released. If you cannot update your site for any reason, consider using a website firewall to virtually patch the problem and minimize the risk.
To set up automatic updates in WordPress:
Some updates can break your website, so be sure to verify your site is fully operational after an update is applied.
Advanced users can refer to the WordPress Codex’s guide on updates using subversion.
To manually apply updates in WordPress:
Before updating your website to the latest version of WordPress, we recommend taking the following precautionary steps:
Keep WordPress Plugins Updated
WordPress may not be able to update the extension if it has been downloaded from a third-party website. If this is the case, you may need to manually update the plugin using FTP or use an included updater to keep your WordPress secure.
To manually apply updates for plugins in WordPress:
Keep WordPress Themes Updated
Keeping themes updated is another important aspect of WordPress security. If you are not using a child/parent theme for customizations, you’ll need to copy your modifications to a new theme folder, then update it to FTP.
To manually update themes in WordPress:
If you are using a customized child theme that is inheriting functionality from a parent theme, then updating your theme is fairly straightforward. Simply overwrite your copy of the parent theme with the latest version from the official source. Your customizations will remain intact in the child theme.
Attackers frequently exploit weak user credentials to obtain access to WordPress websites. Locking down your WP Admin access can prevent hacking and secure your WordPress site.
Increase security to your WordPress website by utilizing strong, unique passwords restricting the privileges available to users through assigned roles, enabling two-step or multi-factor authentication and limiting user sessions, you can reduce the risk of a website compromise by a bad actor.
Remove Default WP-Admin
A large majority of attacks target the wp-admin, wp-login.php, and xmlrpc.php access points by using a combination of common usernames and passwords.
By using a unique username and removing the default admin account in your WordPress installation, you make it much more difficult for attackers to guess (brute force) their way into your website.
How to replace the default “admin” account:
Create a nickname that’s different from your existing username and set it as your public display name. This will make it more difficult for attackers to brute force your login credentials.
User Roles & the Principle of Least Privilege
The principle of least privilege is composed of two very simple steps:
With this concept in mind, WordPress includes built-in roles for Administrators, Authors, Editors, Contributors, and Subscribers. These roles specify what can and cannot be accomplished by a user.
Follow these access control recommendations to secure your WordPress:
WordPress password security is an important factor in hardening your website and increasing your WP admin security. Password lists are often used by attackers to brute force WordPress websites. This is why you should always use strong, unique passwords for all of your accounts to improve the security of your WP site.
Strong passwords should meet the following standards:
Using a password generator to generate a randomized string of letters and numbers is one of the simplest ways to create a secure password.
Use Two Factor Identification (2FA) / Multi Factor Identification (MFA)
Two-factor authentication provides a second level of security for your WordPress account. This feature requires a user to approve a login via an app and protects your WordPress account in the event that someone is able to guess your password.
How to add 2FA to WordPress using Google Authenticator:
Sucuri’s Website Security Platform includes a feature that helps you easily password protect or implement 2FA on any page of your website.
To add 2FA to any page on your website using Sucuri:
WordPress allows users to attempt a login unlimited times by default, but this leaves your site vulnerable to brute force attacks as hackers try to attempt different password combinations.
You can add an extra layer of security by limiting the number of login attempts against an account through a plugin, or by using a Web Application Firewall (WAF).
The acronym stands for Completely Automated Public Turing test to tell Computers and Humans Apart. This feature is extremely useful for stopping automated bots from accessing your WordPress dashboard, as well as submitting unwanted spam through forms.
Limiting the access to your WordPress login page to only authorized IP’s will prevent unauthorized entries and better secure your site.
There are plugins available that can do this. If you are using a cloud-based WAF like the Sucuri Firewall, you can restrict access to these URL’s via your dashboard without having to mess around with .htaccess files.
In the field of Information Security (InfoSec) we like to use the phrase defense in depth.
To appreciate this ideology, you have to subscribe to a very simple principle: There is no 100% complete solution capable of protecting any environment.
In this section, we’ve listed a number of solutions you can employ on your WordPress website to provide an effective defense in depth strategy. By layering these defensive controls, you’ll be able to identify and mitigate attacks against your website.
If you go to the official WordPress repository and do a quick search for Security, you will find over 4,298 plugins with distinct categorizations and feature sets. If you’re looking for a smaller list, be sure to check out our list of the best WordPress security plugins to help keep your website safe.
We’ll break down the categories and explain their importance so you can find the right solutions for your needs.
WordPress Security Plugin – Prevention Category
These plugins look to provide some level of prevention, otherwise known as a perimeter defense for your website. Their objective is to stop hacks from happening by filtering incoming traffic.
Prevention plugins are often limited to working at the application layer, meaning the attack has to hit the WordPress application for them to respond. Attacks against server software cannot be prevented with security plugins, which is why we recommend considering a cloud-based WAF instead.
WordPress Security Plugin – Detection Category
Protection is great for known issues, but not so great for the unknown. Being able to detect anything that gets past your perimeter defense is extremely valuable, which is where detection comes into play.
These plugins will attempt to identify intruders through File Integrity Checks, scanning for indicators of compromise, or a combination of the two mechanisms.
The effectiveness of these plugins is strictly determined by the order in which they are installed. For instance, if the plugin is based on integrity checks, then it needs to be installed on a fresh, known-good environment so that it can create a baseline to check from to keep your WordPress secure.
Some plugins may compare known third-party themes and plugins to their own repository in order to work with websites that have already been compromised, but these are not compatible with customized or little-known files.
Detection plugins are important in identifying if something has gone wrong on your website. These tools ensure that you’re informed when a security incident occurs.
WordPress Security Plugin – Auditing Category
Contrary to popular belief, WordPress security is not a set it and forget it undertaking. You have to invest time into the process and get acclimated with what is going on, who is logging in, what is changing, and when the changes are being made.
Auditing plugins can help you answer the questions above by offering basic administration features that help you identify, thwart, or respond to a compromise.
WordPress Security Plugin – Utility Category
This is perhaps the most diverse bucket of the entire WordPress Security Plugin ecosystem. Some plugins are those we consider to be the Swiss Army knives of the security landscape. These utility plugins have a much smaller set of functionality.
These plugins can be exhaustive in their security configuration options. They have every possible configuration you could or might ever want to employ and are best suited for users who like to tinker or want the ability to configure specific options to meet their needs. For example, some security plugins simply disable XML-RPC or move your login page.
We also reserve this category for toolsets like backups or maintenance plugins that address specific security functions.
Website hosting security has matured in recent years, and it’s a complex topic.
Most hosts provide the security you require at various levels in the stack, but not for the website itself. There are a number of hosting providers that offer security for an additional fee, but unless you’ve purchased a security product from them, it’s unlikely that they’ll resolve a compromise for you.
There are four main hosting environments that can be used for your WordPress installation:
In theory, the environments that remove the most dependency from the user will offer the most security. If you have the time and skill to secure your own environment, then you have more options but also more responsibility.
In reality, however, the type of hosting environment you choose should be dictated by your needs and expertise:
You can also initiate a conversation with your hosting provider to identify what their stance is on security. Some key points should be addressed:
Use carefully isolated FTP and user accounts on Shared Server environments to prevent cross-site contamination.
Secure file transfer to and from your server is an important facet of website security in your hosting environment. Encryption ensures that any data sent is protected from prying eyes who may be sniffing your network traffic.
We recommend using one of the following methods to connect to your server and keep your WordPress secure:
SSH: Secure Socket Shell is a secure network protocol and the most common way of safely administering remote servers. With Secure Socket Shell, any kind of authentication, including password authentication and file transfers, is completely encrypted.
SFTP: SSH File Transfer Protocol is an extension of SSH and allows authentication over a secure channel. If you are using FileZilla or some other FTP client, you can often select SFTP instead. The default port for SFTP in most FTP services is 22.
Maintaining backups of your WordPress site should be one of the most important recurring tasks for an administrator in order to improve security.
A good set of backups can save your website when absolutely everything else has gone wrong. If a malicious attacker decides they want to wipe all your site files or corrupts your site files with their buggy scripts, the damage can be undone by restoring your site from your backups.
There are four key requirements for employing a successful backup solution:
There are a number of tools you can use to help identify when something has gone wrong on your website. To help you respond quickly to a security breach, employ a tool that includes the following services.
Integrity checks are an important aspect of auditing your WordPress installation and can give you an early warning of an intrusion on your website.
File Integrity Monitoring tools are normally installed on a server where they create a baseline cryptographic checksum of the critical files and registry entries. If a file or record is modified in any way, you’ll receive a notification of the changes.
You can install the free Sucuri Scanner plugin for WordPress to use our core file integrity monitoring system.
Auditing / Alerts
Auditing tools give you visibility into user activity on the website.
As the administrator of your website you should be asking questions like:
We cannot stress enough the importance of logging activity. Use a tool that logs and alerts you of any actions taken on your website, including:
Create a Response and Recovery Plan
Response and recovery aren’t just about responding to a compromise or incident, it’s about analyzing the impacts of an attack to understand what happened, and implementing controls to prevent it from happening again.
We actively maintain a free WordPress Security Plugin that includes all of the features listed above to enhance security and identify indicators of compromise.
If you believe your WordPress site has been hacked, read our How to Clean a WordPress Hack guide or reach out to our Malware Removal team. Our professional Security Analysts are available 24/7/365.
Caution: The following recommendations are for server administrators with knowledge of how these files work. If you do not feel comfortable with these suggestions, we recommend using a website firewall that includes virtual hardening instead.
The .htaccess file is what most vendors will modify when they say they are hardening your WordPress environment.
This critical configuration file is specific for web servers running on Apache. If you’re running your WordPress instance on a LAMP stack using Apache, then we recommend hardening your site by updating your .htaccess file with the following rules.
Some of the rules below are dependent on the version of Apache you are running. In those cases, we have included instructions for both versions 2.2 and 2.4 of Apache Server.
This rule is generated by WordPress if it has write access to your server, most notably to fix issues with pretty permalinks.
If it isn’t at the top of your file, place at the top of your .htaccess file. Any other rules should go after the # BEGIN WordPress and # END WordPress statements.
Restrict Logins to IP Range
This rule restricts access to wp-login.php to an IP, protecting you from unauthorized login attempts in other locations. Even if you do not have a static IP, you can still restrict logins to your ISP common range.
Use this same entry on other authenticated URLs that you’d like to restrict, including /wp-admin. If you are using a dynamic IP, you can refer to our instructions: How to lock down WordPress Admin Panel with a dynamic IP
This rule restricts visitors from accessing your wp-config.php file, which contains sensitive information about the database, including name, host, username and password. This file is also used to define advanced settings, security keys and developer options.
Prevent Directory Browsing
This rule prevents attackers from viewing the folder contents of your website, restricting the information they have to exploit your website.
Prevent Image Hotlinking
This rule prevents other websites from using images hosted on your website. While hotlinking won’t get your site hacked, it can result in a damaging exploitation of your server resources. Change example.com to your website.
This rule prevents attackers from accessing any files that start with “hta” – this ensures that .htaccess files are protected in all of the directories of your server.
This rule blocks hackers from inserting malicious files into any of the four primary folders used for includes:
If you run a multisite instance of WordPress, these directives may cause issues. Always test and use caution.
Prevent PHP Backdoors
This rule prevents hackers from placing PHP backdoors in the /wp-includes/ and /wp-content/uploads/ folders, two popular locations for malicious file uploads.
Move WP-Config outside the root folder
The wp-config.php file is a very important configuration file containing sensitive information about your WordPress site, including database connections.
If the wp-config.php file does not exist in the root folder, WordPress will automatically look for this file in the folder above the root directory. Moving this file out of the root folder prevents wp-config.php from being accessible from the Internet.
Setup Salts & Keys
The wp-config file includes a section dedicated to authentication salts and keys. These salts and keys improve the security of cookies and passwords that are in transit between your browser and the web server.
You can set up your keys by including or editing these lines after the other define statements in your wp-config.php file:
define(‘AUTH_KEY’, ‘include salt here’);
define(‘SECURE_AUTH_KEY’, ‘include salt here’);
define(‘LOGGED_IN_KEY’, ‘include salt here’);
define(‘NONCE_KEY’, ‘include salt here’);
You can easily generate your salts by navigating to the wordpress.org salt generator or using the reset salts + keys option in our WordPress Plugin.
If you suspect that the secret keys have been compromised, regenerate them as soon as possible. All users will need to re-authenticate.
Disable File Editing
By default, file changes can be made through Appearance > Editor from the WordPress dashboard.
You can increase your WordPress security by disabling file editing from the dashboard. This prevents an attacker from changing your files through the backend or wp-admin. You will still be able to make changes via SFTP/SSH.
To disable file editing from the dashboard, include the following two lines of code at the end of your wp-config.php file:
## Disable Editing in Dashboard
Some plugins disable file editing as part of their hardening process, or as an extra setting.
Virtual hardening is part of a defense-in-depth strategy that protects your web server and database from vulnerability exploitation. Virtual hardening is the act of adding multiple layers of protection to a website to reduce the attack surface.
If a security patch is released but you are unable to update your site, it becomes an easy target for hackers. One effective way to mitigate this risk is to employ a virtual patching service on your website.
Virtual patching can be accomplished through the use of a Web Application Firewall, where vulnerabilities are patched automatically to protect against known security threats.
One of the easiest ways to protect your WordPress website from hackers is to employ the use of a Web Application Firewall (WAF) like the Sucuri Firewall.
Website firewalls work to identify, filter, and block malicious traffic from reaching your site. All HTTP/HTTPS traffic is inspected. If a malicious bot or hacker tool attempts an attack, the website firewall blocks it automatically to protect your WordPress website before it even reaches your server.
There are a number of professional services that take care of your website security needs for you. Not all services are the same – some charge more to fix complex hacks, and others provide different tiered feature sets. You should choose the one that best fits your needs.
If your host provides security services, take some time to research exactly what features they include. They’re normally happy to advise you on ways you can complement their baseline feature sets with additional services.
The benefit to employing a cloud-based security service like Sucuri is that it provides complete end-to-end website security. This means protection, detection, and response services are included with an all-in-one platform and no hidden fees.
Our high availability Globally Distributed Anycast Network (GDAN) ensures that websites can efficiently service their global audiences while mitigating DDoS attacks.
SSL has become increasingly important to WordPress security in the past couple of years, not only for securely transmitting information to and from your website, but also to increase visibility and lower the chances of being penalized.
SSL allows a website to be accessed over HTTPS, which encrypts the data sent between visitors and web servers. Since 2014, SSL has been a ranking signal for SEO and Google has now started to flag non-HTTPS websites that transmit password and credit card data.
We’ve put together a free guide on how to implement SSL on your website and a tutorial on how to move your WordPress site to https. If you need assistance, you can reach out to us and learn how we can help you activate SSL/HTTPS via our cloud-based WAF.
WordPress website owners can increase their security by practicing strong password security and access control. You should keep all software and third-party components up to date with the latest security patches to prevent vulnerabilities, and employ proactive WordPress security principles for an effective defense strategy.
We also encourage website owners to prevent attacks and protect their WordPress websites from hackers with a web application firewall (WAF) that automatically blocks website attacks and hacks.
The Sucuri Security WordPress plugin offers a variety of helpful security features, including activity auditing, file integrity monitoring, remote malware scanning, and blacklist monitoring to identify and protect your website from threats.
Other useful plugins include backup, auditing, and utility plugins which address a variety of security functions.
One of the easiest ways to protect your WordPress website from hackers is to employ the use of a WordPress firewall (WAF), which can block malicious traffic from ever reaching your server.
We’ve put together a helpful guide on how to clean a WordPress hack to help website owners walk through the process of identifying and cleaning up malware from a compromised website. This guide also includes post-hack instructions to help you protect your site from future infections.
If you need assistance, our security analysts are here to help. We remove malware from thousands of WordPress websites every week.
SSL certificates do not protect your website, but they help defend data in transit between the host (web server or firewall) and the client (web browser). SSL works as a barrier to prevent data visibility or modification by intruders.
To install an SSL certificate on a WordPress website, you’ll need to either purchase one from a certificate authority, such as GoDaddy, or use a free certificate from Let’s Encrypt.
We’ve written an extensive guide that instructs you on how to add a Let’s Encrypt SSL certificate to your WordPress website and encrypt its data with HTTPS.
Sucuri offers free SSL on the firewall to ensure that visitors reach your website via HTTPS by default.