Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/motors-car-dealership-classified-listings/includes/helpers.php
+++ b/motors-car-dealership-classified-listings/includes/helpers.php
@@ -1305,6 +1305,33 @@
add_filter( 'motors_vl_dealer_logo_placeholder', 'motors_vl_dealer_logo_placeholder' );
}
+if ( ! function_exists( 'stm_mvl_is_path_within_uploads' ) ) {
+ function stm_mvl_is_path_within_uploads( $path ) {
+ if ( ! is_string( $path ) || '' === trim( $path ) ) {
+ return true;
+ }
+ $path = trim( $path );
+ $dir = wp_upload_dir();
+ if ( ! empty( $dir['error'] ) ) {
+ return false;
+ }
+ $upload_basedir = $dir['basedir'];
+ $real_upload = realpath( $upload_basedir );
+ $real_path = realpath( $path );
+ if ( false === $real_upload || false === $real_path ) {
+ return false;
+ }
+ return 0 === strpos( $real_path . DIRECTORY_SEPARATOR, $real_upload . DIRECTORY_SEPARATOR );
+ }
+}
+
+if ( ! function_exists( 'stm_mvl_filter_path_within_uploads' ) ) {
+ function stm_mvl_filter_path_within_uploads( $default, $path ) {
+ return stm_mvl_is_path_within_uploads( $path );
+ }
+ add_filter( 'stm_mvl_is_path_within_uploads', 'stm_mvl_filter_path_within_uploads', 10, 2 );
+}
+
if ( ! function_exists( 'stm_account_current_page' ) ) {
function stm_account_current_page() {
$page = 'inventory';
--- a/motors-car-dealership-classified-listings/includes/starter-theme/dashboard/wizard/includes/functions.php
+++ b/motors-car-dealership-classified-listings/includes/starter-theme/dashboard/wizard/includes/functions.php
@@ -414,11 +414,14 @@
// Install and activate child theme
add_action( 'wp_ajax_mvl_motors_starter_child_theme_install', 'mvl_motors_starter_child_theme_install' );
-add_action( 'wp_ajax_nopriv_mvl_motors_starter_child_theme_install', 'mvl_motors_starter_child_theme_install' );
function mvl_motors_starter_child_theme_install() {
check_ajax_referer( 'mvl_motors_starter_wizard_nonce', 'nonce' );
+ if ( ! current_user_can( 'manage_options' ) ) {
+ wp_die( esc_html__( 'You do not have permission to install child themes.', 'motors-starter-theme' ) );
+ }
+
$theme_url = 'https://motors-plugin.stylemixthemes.com/starter-theme-demo/motors-starter-theme-child.zip';
$theme_slug = 'motors-starter-theme-child';
$theme_dir = get_theme_root() . '/' . $theme_slug;
@@ -455,6 +458,21 @@
)
);
+ return;
+ }
+
+ require_once ABSPATH . '/wp-admin/includes/file.php';
+
+ global $wp_filesystem;
+
+ if ( empty( $wp_filesystem ) && ! WP_Filesystem() ) {
+ unlink( $zip_path );
+ wp_send_json_error(
+ array(
+ 'message' => esc_html__( 'Could not access filesystem.', 'motors-starter-theme' ),
+ )
+ );
+
return;
}
--- a/motors-car-dealership-classified-listings/includes/user-extra.php
+++ b/motors-car-dealership-classified-listings/includes/user-extra.php
@@ -118,11 +118,14 @@
<td>
<input type="text" name="stm_user_avatar" id="stm_user_avatar"
value="<?php echo esc_attr( get_the_author_meta( 'stm_user_avatar', $user->ID ) ); ?>"
- class="regular-text"/><br/>
- <input type="text" name="stm_user_avatar_path" id="stm_user_avatar_path"
- value="<?php echo esc_attr( get_the_author_meta( 'stm_user_avatar_path', $user->ID ) ); ?>"
- class="regular-text"/><br/>
- <span class="description"><?php esc_html_e( 'User avatar(stores URL and path to image)', 'stm_vehicles_listing' ); ?></span>
+ class="regular-text"/>
+ <?php if ( current_user_can( 'edit_users' ) ) : ?>
+ <br/>
+ <input type="text" name="stm_user_avatar_path" id="stm_user_avatar_path"
+ value="<?php echo esc_attr( get_the_author_meta( 'stm_user_avatar_path', $user->ID ) ); ?>"
+ class="regular-text"/><br/>
+ <span class="description"><?php esc_html_e( 'User avatar path (filesystem)', 'stm_vehicles_listing' ); ?></span>
+ <?php endif; ?>
</td>
</tr>
@@ -272,11 +275,14 @@
<td>
<input type="text" name="stm_dealer_logo" id="stm_dealer_logo"
value="<?php echo esc_attr( get_the_author_meta( 'stm_dealer_logo', $user->ID ) ); ?>"
- class="regular-text"/><br/>
- <input type="text" name="stm_dealer_logo_path" id="stm_dealer_logo_path"
- value="<?php echo esc_attr( get_the_author_meta( 'stm_dealer_logo_path', $user->ID ) ); ?>"
- class="regular-text"/><br/>
- <span class="description"><?php esc_html_e( 'Dealer logo(stores URL and path to image)', 'stm_vehicles_listing' ); ?></span>
+ class="regular-text"/>
+ <?php if ( current_user_can( 'edit_users' ) ) : ?>
+ <br/>
+ <input type="text" name="stm_dealer_logo_path" id="stm_dealer_logo_path"
+ value="<?php echo esc_attr( get_the_author_meta( 'stm_dealer_logo_path', $user->ID ) ); ?>"
+ class="regular-text"/><br/>
+ <span class="description"><?php esc_html_e( 'Dealer logo path (filesystem)', 'stm_vehicles_listing' ); ?></span>
+ <?php endif; ?>
</td>
</tr>
@@ -286,11 +292,14 @@
<td>
<input type="text" name="stm_dealer_image" id="stm_dealer_image"
value="<?php echo esc_attr( get_the_author_meta( 'stm_dealer_image', $user->ID ) ); ?>"
- class="regular-text"/><br/>
- <input type="text" name="stm_dealer_image_path" id="stm_dealer_image_path"
- value="<?php echo esc_attr( get_the_author_meta( 'stm_dealer_image_path', $user->ID ) ); ?>"
- class="regular-text"/><br/>
- <span class="description"><?php esc_html_e( 'Dealer image(stores URL and path to image)', 'stm_vehicles_listing' ); ?></span>
+ class="regular-text"/>
+ <?php if ( current_user_can( 'edit_users' ) ) : ?>
+ <br/>
+ <input type="text" name="stm_dealer_image_path" id="stm_dealer_image_path"
+ value="<?php echo esc_attr( get_the_author_meta( 'stm_dealer_image_path', $user->ID ) ); ?>"
+ class="regular-text"/><br/>
+ <span class="description"><?php esc_html_e( 'Dealer image path (filesystem)', 'stm_vehicles_listing' ); ?></span>
+ <?php endif; ?>
</td>
</tr>
@@ -389,12 +398,15 @@
$stm_show_email = isset( $_POST['stm_show_email'] ) ? '1' : '';
update_user_meta( $user_id, 'stm_show_email', $stm_show_email );
- // Avatar fields
+ // Avatar fields (path must be within WP uploads to prevent arbitrary file deletion).
if ( isset( $_POST['stm_user_avatar'] ) ) {
update_user_meta( $user_id, 'stm_user_avatar', esc_url_raw( wp_unslash( $_POST['stm_user_avatar'] ) ) );
}
if ( isset( $_POST['stm_user_avatar_path'] ) ) {
- update_user_meta( $user_id, 'stm_user_avatar_path', sanitize_text_field( wp_unslash( $_POST['stm_user_avatar_path'] ) ) );
+ $raw_path = sanitize_text_field( wp_unslash( $_POST['stm_user_avatar_path'] ) );
+ if ( apply_filters( 'stm_mvl_is_path_within_uploads', false, $raw_path ) ) {
+ update_user_meta( $user_id, 'stm_user_avatar_path', $raw_path );
+ }
}
// Social media URLs
@@ -430,18 +442,24 @@
update_user_meta( $user_id, 'stm_message_to_user', sanitize_text_field( wp_unslash( $_POST['stm_message_to_user'] ) ) );
}
- // Dealer images
+ // Dealer images (paths must be within WP uploads to prevent arbitrary file deletion).
if ( isset( $_POST['stm_dealer_logo'] ) ) {
update_user_meta( $user_id, 'stm_dealer_logo', esc_url_raw( wp_unslash( $_POST['stm_dealer_logo'] ) ) );
}
if ( isset( $_POST['stm_dealer_logo_path'] ) ) {
- update_user_meta( $user_id, 'stm_dealer_logo_path', sanitize_text_field( wp_unslash( $_POST['stm_dealer_logo_path'] ) ) );
+ $raw_path = sanitize_text_field( wp_unslash( $_POST['stm_dealer_logo_path'] ) );
+ if ( apply_filters( 'stm_mvl_is_path_within_uploads', false, $raw_path ) ) {
+ update_user_meta( $user_id, 'stm_dealer_logo_path', $raw_path );
+ }
}
if ( isset( $_POST['stm_dealer_image'] ) ) {
update_user_meta( $user_id, 'stm_dealer_image', esc_url_raw( wp_unslash( $_POST['stm_dealer_image'] ) ) );
}
if ( isset( $_POST['stm_dealer_image_path'] ) ) {
- update_user_meta( $user_id, 'stm_dealer_image_path', sanitize_text_field( wp_unslash( $_POST['stm_dealer_image_path'] ) ) );
+ $raw_path = sanitize_text_field( wp_unslash( $_POST['stm_dealer_image_path'] ) );
+ if ( apply_filters( 'stm_mvl_is_path_within_uploads', false, $raw_path ) ) {
+ update_user_meta( $user_id, 'stm_dealer_image_path', $raw_path );
+ }
}
// Location fields
--- a/motors-car-dealership-classified-listings/stm_vehicles_listing.php
+++ b/motors-car-dealership-classified-listings/stm_vehicles_listing.php
@@ -8,7 +8,7 @@
* License: GNU General Public License v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: stm_vehicles_listing
- * Version: 1.4.107
+ * Version: 1.4.108
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -50,7 +50,7 @@
define( 'STM_LISTINGS_URL', plugins_url( '', STM_LISTINGS_FILE ) );
define( 'STM_LISTINGS', 'stm_vehicles_listing' );
define( 'STM_THEME_V_NEED', '5.6.33' );
- define( 'STM_LISTINGS_V', '1.4.107' );
+ define( 'STM_LISTINGS_V', '1.4.108' );
define( 'STM_LISTINGS_DB_VERSION', '1.0.0' );
define( 'STM_LISTINGS_IMAGES', STM_LISTINGS_URL . '/includes/admin/butterbean/images/' );
}
--- a/motors-car-dealership-classified-listings/templates/user/private/become-dealer.php
+++ b/motors-car-dealership-classified-listings/templates/user/private/become-dealer.php
@@ -164,7 +164,7 @@
'exclude' => array( $user_id ),
);
$users_db = get_users( $args );
- if ( empty( $users_db ) ) {
+ if ( empty( $users_db ) && apply_filters( 'stm_mvl_is_path_within_uploads', false, $user_old_avatar ) ) {
unlink( $user_old_avatar );
}
}
--- a/motors-car-dealership-classified-listings/vendor/composer/installed.php
+++ b/motors-car-dealership-classified-listings/vendor/composer/installed.php
@@ -3,7 +3,7 @@
'name' => 'motors_vehicles_listing/plugin',
'pretty_version' => 'dev-release',
'version' => 'dev-release',
- 'reference' => 'b754d73d18a775b2cfdeee6a27abb673c57bb6c0',
+ 'reference' => '459a87555358ee0667ae64cc237d9756e4f0d505',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -13,7 +13,7 @@
'motors_vehicles_listing/plugin' => array(
'pretty_version' => 'dev-release',
'version' => 'dev-release',
- 'reference' => 'b754d73d18a775b2cfdeee6a27abb673c57bb6c0',
+ 'reference' => '459a87555358ee0667ae64cc237d9756e4f0d505',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),