Penetration Testing for WordPress Websites
A penetration test, alternatively referred to as a pen test, involves conducting a simulated cyber attack on your computer system to assess and identify potential vulnerabilities that could be exploited.
Many websites on the Internet run on the WordPress platform. Therefore, it should come as no surprise that skilled attackers and “script-kiddies” like WordPress websites as targets. It usually helps to be aware of common security errors attackers frequently exploit, whether you’re a webmaster or a security professional entrusted with evaluating the security posture of a WordPress website. Utilizing the appropriate penetration testing tools is also crucial.
In this article, we will go over several typical security flaws, errors, and helpful information that many WordPress installs contain. Additionally, we will highlight a few tools you may utilize to assist in automating the WordPress penetration test.
Regular WordPress security mistakes & difficulties
Outdated WordPress Code Versions:
Undoubtedly one of the most frequent security problems with WordPress is running outdated versions of the WordPress core that have security flaws. Although upgrading to the most recent version of WordPress is made simple by newer versions, older WordPress sites frequently lag behind.
Running an outdated version of WordPress online is dangerous. Many outdated WordPress versions have security flaws. Attackers frequently mass exploit several of these security flaws. This is normally one of the first things you’d want to examine when assessing a WordPress website for security flaws.
Fortunately for attackers, WordPress automatically adds an HTML meta tag with the current WordPress version. If an attacker is aware that a WordPress installation is using an outdated version, they may be able to exploit a known vulnerability.
Themes & Plugins For WordPress That Are Outdated:
The core of WordPress is highly safe. Numerous people, including malevolent hackers, test and carefully examine the code. This indicates that security flaws are typically discovered and addressed before being exploited by attackers. It is not impervious to security flaws, though. Unfortunately, the countless WordPress plugins and themes do not fall under this.
A theme or plugin can be submitted by anyone and made accessible for usage by any WordPress administrator. Of course, this does not imply that all WordPress plugins are insecurely coded or vulnerable in any way. However, when running a WordPress penetration test, you should be aware of the significant attack surface that known vulnerabilities expose.
WPScan:
WPScan is the quickest and, perhaps, most complete tool for identifying insecure WordPress plugins and themes.
A WPScan Vulnerability Database API key must be obtained and set up before utilizing WPScan during a pentest. The newest known vulnerabilities and their corresponding versions are kept up to date in the WPScan Vulnerability Database, which is a database maintained by the WPScan developers.
Outdated Web Servers & PHP Versions:
Because WordPress is a PHP web application, all PHP security recommended practices also apply to it. This is one of the very first things to look for during a WordPress penetration test. The website may be vulnerable to a variety of assaults if WordPress installations are using outdated versions of PHP or web server software (such as Nginx, Apache HTTP Server, IIS…).
Finding out what web server and PHP version a WordPress website is using is fairly simple. In many instances, all an attacker needs to do is carefully examine the HTTP response headers that the website returns. With curl, you can independently send a request:
$ curl -s -D – http://167.71.67.124/ -o /dev/null | grep -i “Server\|X-Powered-By”
Look for the Server and X-Powered-By HTTP headers in the response
Server: Apache/2.4.29 (Ubuntu)
X-Powered-By: PHP/5.5.9
An attacker might be able to utilize known vulnerabilities to learn more about a target depending on the version and settings of the website. Such details may be used to escalate an attack or even to provide commands to the web server.
List of WordPress Usernames:
WordPress is susceptible to user enumeration attacks by default unless a system administrator has taken precautions to stop it. Look for minute variations in how WordPress reacts to specific requests to identify WordPress user enumeration attacks. An attacker may utilize this knowledge as part of a bigger attack based on the answer, which will reveal whether a user is present.
Errors with web server configuration
Misconfiguration of the web server’s directory and other services:
Along with obsolete software, prospective web server configuration issues must constantly be investigated. The WordPress website could be exploited by a web server with a bad configuration. Even if the web server is using the most recent software, this can still occur. Here are a few frequent web server configuration errors:
Directory listing enabled:
An extremely frequent misconfiguration is directory listing. This is enabled by default on Apache web servers, however that does not assist. When there is no index file, directory listing simply displays the files and folders on a web server in a graphical interface.
While not very damaging in and of itself, this gives an attacker the ability to traverse the directory on your web server. He might be able to view every file on your website, including backups, passwords, and configuration files—most of which are accessible to the public but shouldn’t be.
Backup Documents:
Another all-too-common web server setting error is backup files. These typically happen when system administrators modify files manually on production systems.
Backups of PHP files may be an example of a backup file that exposes potentially sensitive data. Important configuration information can occasionally be found in PHP files, such as the wp-config.php file used by WordPress.
Consider the situation where a WordPress administrator needs to modify wp-config.php. They create a backup copy of the live wp-config.php and give it the name wp-config.php.bak rather than adhering to recommended practices and maintaining a copy of the file somewhere else than the web server. Now let’s suppose the sysadmin neglected to delete this file, which occurs more frequently than we believe.
Now, a hacker only needs to make a request to http://www.example.com/wp-config.php.bak to view the file. Because the file no longer has a.php extension, the attacker may read it. The web server then serves it as a text file while the PHP engine ignores it. The hacker now has access to the secret tokens, WordPress database credentials, and any other private configuration data you may have put in that file.
Temporary Documents:
Temporary files in the incorrect location can reveal potentially sensitive data, much as backup files. again using wp-config.php as an illustration. There’s a good risk that the text editor would leave temporary files if a system administrator had to edit this file using a text editor and for some reason the programme did not exit cleanly. For instance, the well-known command-line editor Vim maintains backup files with the *.ext file extension alongside a *.ext.swp file. As a lock file, the swp files are employed. Additionally, they include all the undo/redo history and other internal data that Vim requires.
Because it doesn’t have a *.php file extension, Vim leaves behind a wp-config.php.ext file that might be accessible in plain text like backup files in the event of a crash. This type of temporary file is not unique to Vim; several other tools, including Emacs (another well-known command-line text editor), save comparable temporary files.
Consider MySQL:
One of the worst mistakes a system administrator might do is leaving their WordPress MySQL database server accessible via the Internet. While this may seem absurd, it probably occurs more frequently than you realise.
Naturally, simply because MySQL is accessible through the Internet does not automatically grant access to the WordPress database. However, it can result in a catastrophe if combined with additional assaults, such as guessing a weak password or obtaining a password leak from a backup of wp-config.php.
A WordPress installation is doomed if someone gains access to the database. An administrator password reset is all that is required of an attacker. Then, by installing malicious plugins on purpose, attackers essentially seize control of your WordPress website and possibly even the server it is hosted on.
Performing Pointless Services:
The default configuration is another frequent issue with incorrect web server settings. Many administrators use the default configuration and do not shut down any unnecessary services. Most of the time, default installations run a tonne of useless services, many of which, if unprotected, expose the web server to assaults.
WordPress penetration testers and security experts can use pentesting tools
Numerous tools are used by penetration testers to automate their processes. A security assessment or penetration test can be completed faster using automation.
Kali Linux:
One employs a wide variety of tools. It depends on what you want and what the issue is. However, having a selection of tools readily available and pre-installed is a smart place to start.
The preferred open-source Linux distribution for penetration testing is Kali Linux, previously BackTrack. Many pre-installed and pre-configured tools are included with Kali Linux. Both expert penetration testers and inexperienced users wishing to get started quickly can benefit from it. Running on a virtual machine, Kali Linux is accessible for free.
Nmap:
One of the most important and functional scanners in every pentester’s toolkit is this free one. Nmap’s main function is port scanning. However, thanks to its NSE scripting language, it may be expanded to perform a wide variety of scanning.
WPScan:
WPScan is an open-source WordPress security scanner, which was previously covered in this post. It checks for known WordPress vulnerabilities in the core code of the platform as well as in plugins and themes.
WPScan can run several black box tests. Without having access to the source code, that is. WPScan is hence excellent for quickly and correctly identifying low-hanging WordPress vulnerabilities.
OWASP ZAP:
A free, open-source tool for online application penetration testing is OWASP Zed Attack Proxy (ZAP). These tools are maintained by the Open Web Application Security Project (OWASP). Cross-site Scripting (XSS) and SQL Injection (SQLi) are only two examples of the many vulnerabilities that the OWASP ZAP is specifically made to test web applications for. ZAP is fundamentally a proxy. In order to intercept and examine the requests exchanged between the pentester’s browser and the website, it sits in between the two.
ZAP can fuzz a range of inputs in addition to serving as a proxy and automatically testing for several vulnerabilities. Fuzzing is a security testing approach that involves feeding erroneous or unexpected input into an application with the goal of finding security flaws.
WordPress Penetration Testing
Evaluating Security Status of Your Website:
Security in WordPress requires ongoing maintenance. Based on four guiding concepts, it is an ongoing process: Improve > Harden > Monitor > Test. The test principle is addressed with penetration testing. Specifically, you assess your website’s level of security. Afterward, based on your discoveries, you can take the necessary actions to enhance the setup.
Final Words
As a result, regular WordPress website penetration testing ought to be included in your security strategy. You decide how often you ought to conduct penetration tests. You should conduct frequent tests if you frequently modify your website. However, if your website isn’t updated frequently, a quarterly penetration test works well.