Skip to main content
How to Prevent a WordPress Hack: 10 Practical Security Tips
4:56

If you have ever dealt with a hacked website, you know how stressful it is. WordPress powers a huge share of the web, which makes it a frequent target for automated attacks. The good news is that most successful attacks exploit basic weaknesses you can fix. Whether you run a company blog, a marketing site or a SaaS product site, these ten practices will reduce your risk significantly.

1. Keep WordPress core up to date

Each release includes bug and security fixes. Running an old version leaves known vulnerabilities open to automated scanners. Enable automatic minor updates, and apply major updates promptly after testing.

2. Choose a secure hosting provider

Your host is the foundation of your security. Before you choose one, check what protection it offers, how it monitors its network and how it responds to incidents. Look for server-level firewalls, DDoS protection, malware scanning, automated backups, isolated accounts and up-to-date server software. Shared hosting can be fine when well managed, but isolation between sites matters. Sites with high traffic or sensitive data may justify a managed or dedicated environment.

3. Use a reputable security plugin

A good security plugin adds layers of protection. Common features include a web application firewall, brute-force protection, malware and file-change scanning, login attempt limiting, IP blocking and two-factor authentication. Choose a well-maintained, well-reviewed option and avoid installing several overlapping security plugins. Sites that handle customer data should also follow broader SaaS security best practices.

4. Use strong, unique passwords and two-factor authentication

Weak and reused passwords remain a leading cause of compromised sites. Use long, unique passphrases for every account, store them in a password manager, and turn on two-factor authentication for all admin users. Remove accounts that are no longer needed, and give each person the lowest level of access they need.

5. Keep plugins and themes updated

Most WordPress vulnerabilities are found in plugins and themes rather than in core. Update them regularly, test updates in a staging environment where possible, and install only from reputable sources. Delete anything you are not using, since unused code is still an attack surface and extra plugins can slow your site down.

6. Reduce exposure of your login page

Changing the default login URL or limiting access by IP can cut down on automated brute-force attempts. This is not a substitute for strong passwords and two-factor authentication, but it reduces noise and load.

7. Disable file editing in the dashboard

WordPress includes a code editor that lets administrators edit theme and plugin files from the dashboard. If an attacker gets in, that editor makes it easy to insert malicious code. You can turn it off by adding the following line to your wp-config.php file:

define( 'DISALLOW_FILE_EDIT', true );

You can also prevent PHP files from running in the uploads folder through your server configuration. Ask your host or developer if you are unsure how to do this safely.

8. Turn on automatic updates where it makes sense

For sites that rarely change, automatic updates for plugins and themes can close security holes quickly. For complex sites, combine automatic updates with a staging site and monitoring so you notice if an update breaks something.

9. Secure and isolate your databases

Your database holds your site's content and user data. Use a separate database and database user for each site, grant only the permissions needed, use strong credentials and avoid exposing the database to the public internet. Changing the default table prefix is a small extra step, though it will not stop an attack by itself.

10. Take regular, tested backups

Backups will not prevent a hack, but they make recovery fast. Keep several copies, store at least one off-site (for example in cloud storage), automate the schedule, and test a restore from time to time, because a backup you cannot restore is no backup at all.

If your site is hacked

Take the site offline or into maintenance mode, change all passwords and keys, restore from a clean backup, update everything, scan for malware and review user accounts. Then identify how the attacker got in so you can close that door.

Wrapping up

WordPress is flexible and powerful, but that flexibility means you are responsible for keeping it patched and protected. If maintaining a self-hosted site is more work than you want, a managed CMS such as HubSpot CMS handles hosting, security and updates for you, so your team can focus on content and conversion.

If you are considering that move, or want your website, forms and CRM working together cleanly, book a 30-minute HubSpot portal review.

Post by Lucy Manole
December 5, 2021

Comments