WordPress powers 43% of the web — which makes it the most targeted CMS on the planet. Most successful attacks exploit default configurations and neglected updates, not sophisticated zero-days. Here are 15 concrete steps to harden any WordPress installation.
Enable automatic background updates for minor WordPress releases. Review plugins weekly — outdated plugins account for 52% of WordPress hacks.
// wp-config.php
define('WP_AUTO_UPDATE_CORE', 'minor');
define('AUTOMATIC_UPDATER_DISABLED', false);
The username admin is targeted in every brute-force script. Create a new administrator with a unique username, then delete the original admin account.
Enable WordPress Application Passwords for REST API authentication. Install a 2FA plugin (Wordfence, WP 2FA) for all administrator accounts.
# Move one level up from public_html/
mv /var/www/html/wp-config.php /var/www/wp-config.php
# WordPress finds it automatically
# Directories
find /var/www/html -type d -exec chmod 755 {} \;
# Files
find /var/www/html -type f -exec chmod 644 {} \;
# wp-config.php — restrictive
chmod 400 /var/www/wp-config.php
# Nginx
location ~* ^/xmlrpc\.php$ {
deny all;
}
# Or via functions.php
add_filter('xmlrpc_enabled', '__return_false');
Install Limit Login Attempts Reloaded or configure Nginx rate limiting to block brute-force attacks at the server level.
# Nginx rate limiting
limit_req_zone $binary_remote_addr zone=login:10m rate=1r/m;
location ~* ^/wp-login\.php$ {
limit_req zone=login burst=3 nodelay;
}
// functions.php
remove_action('wp_head', 'wp_generator');
add_filter('the_generator', '__return_empty_string');
// wp-config.php
define('DISALLOW_FILE_EDIT', true);
define('DISALLOW_FILE_MODS', true); // also blocks plugin/theme install
// wp-config.php
define('FORCE_SSL_ADMIN', true);
# Nginx redirect
server {
listen 80;
return 301 https://$host$request_uri;
}
wp_ table prefix during installation (hard to change later)Options -Indexes to .htaccessX-Frame-Options, X-Content-Type-Options, and Content-Security-Policy headers via Nginx or a pluginSecurity is a process, not a checklist. Implement these steps, then subscribe to the WordPress Security Team blog and the WPScan vulnerability database to stay ahead of emerging threats.