Securing WordPress against hackers
-
I am helping a friend who has a small computer repair shop with his website, and in recent months his site has come under repeated attack by hackers who installed a webshell to launch attacks on others. If we cannot stop this recurring, his provider will cancel his account, and we have even received a warning from the cyber crime department of our local police department.
I have set up the site again on a freshly installed CentOS 7.6 server with a clean install of the latest version (5.1.1) of WordPress, and have taken the following measures to prevent or at least promptly detect any hacking. I would appreciate comments and further suggestions.
- SSH access is limited via iptables to a couple of IP addresses of those who need to have this access.
- The entire site directory is owned by root rather than the webserver user. Since there is normally no need to upload files, even the upload directory does not need to be writeable by the webserver.
- I have stored several properties of all files that make up the site in a database, and check for changes every five minutes. After any legitimate changes the database is updated. If any discrepancies are discovered (new files, changes to size, md5sum or mtime of existing files) both myself and my friend are notified.
- Access to wp-admin and wp-includes, as well as to phpMyAdmin, is limited, via Apache config file, to the same limited set of IP addresses as SSH access.
- Access to *.php files in the uploads folder is denied via a .htaccess file.
I realize that in theory at least some of these measures are redundant; I also realize that some of them duplicate functionality that is already present in the OS (i.e. I could let SELINUX take care of monitoring for file changes, but I have never wrapped my mind around SELINUX so the db solution was easier).
The server currently runs PHP 5.4 because that’s what comes with CentOS 7.6 and because we have another application that we have yet to port to/verify with PHP 7, but upgrading to PHP 7 is definitely on the to-do list. Everything else is up-to-date.
I am not posting the site URL, since I don’t want to let anyone make the connection between this site and these preventive measures. If someone needs the URL to make constructive suggestions please pm me.
- The topic ‘Securing WordPress against hackers’ is closed to new replies.