Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/gmap-embed/admin/includes/wpgmap_settings.php
+++ b/gmap-embed/admin/includes/wpgmap_settings.php
@@ -39,11 +39,13 @@
<!--Settings Tabs-->
<div class="wgm-settings-menu">
<ul>
- <li class="active" data-tab="wgm_general_settings"><a href="#wgm_general_settings">General Settings</a></li>
- <li data-tab="wgm_advanced_settings"><a href="#wgm_advanced_settings">Advanced Settings</a></li>
- <li data-tab="wgm_export_settings"><a href="#wgm_export_settings">Export</a></li>
- <li data-tab="wgm_import_settings"><a href="#wgm_import_settings">Import</a></li>
- <li data-tab="wgm_marker_settings"><a href="#wgm_marker_settings">Marker Settings</a></li>
+ <li class="active" data-tab="wgm_general_settings"><a href="#wgm_general_settings"><?php esc_html_e('General Settings', 'gmap-embed'); ?></a></li>
+ <li data-tab="wgm_advanced_settings"><a href="#wgm_advanced_settings"><?php esc_html_e('Advanced Settings', 'gmap-embed'); ?></a></li>
+ <li data-tab="wgm_marker_settings"><a href="#wgm_marker_settings"><?php esc_html_e('Marker Settings', 'gmap-embed'); ?></a></li>
+ <?php if (current_user_can('manage_options')) : ?>
+ <li data-tab="wgm_export_settings"><a href="#wgm_export_settings"><?php esc_html_e('Export', 'gmap-embed'); ?></a></li>
+ <li data-tab="wgm_import_settings"><a href="#wgm_import_settings"><?php esc_html_e('Import', 'gmap-embed'); ?></a></li>
+ <?php endif; ?>
</ul>
</div>
<div id="gmap_container_inner" style="margin-top: 0;border-top: none;">
@@ -168,6 +170,7 @@
</form>
</div>
+ <?php if (current_user_can('manage_options')) : ?>
<div class="wgm_settings_tabs" id="wgm_export_settings" style="display: none; padding: 20px 25px 25px 25px; position: relative;">
<?php if (!_wgm_is_premium()) : ?>
<!-- Pro Upgrade Banner for Export -->
@@ -487,5 +490,6 @@
<?php endif; ?>
</div>
+ <?php endif; ?>
</div>
</div>
No newline at end of file
--- a/gmap-embed/includes/Classes/Bootstrap.php
+++ b/gmap-embed/includes/Classes/Bootstrap.php
@@ -116,8 +116,9 @@
add_action('admin_init', function () {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$page = isset($_GET['page']) ? sanitize_text_field(wp_unslash($_GET['page'])) : '';
- if (!empty($page) && (strpos($page, 'wpgmapembed') !== false || $page === 'gmap-embed')) {
- if (!current_user_can($this->capability)) {
+ if (!empty($page) && (strpos($page, 'wpgmapembed') !== false || $page === 'gmap-embed' || $page === 'wgm_setup_wizard')) {
+ $required_cap = ($page === 'wpgmapembed-settings' || $page === 'wgm_setup_wizard') ? 'manage_options' : $this->capability;
+ if (!current_user_can($required_cap)) {
// Escape output for XSS protection
wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'gmap-embed'));
}
@@ -179,7 +180,7 @@
// Preview import (AJAX) - returns a small sample preview of uploaded content
add_action('wp_ajax_wgm_import_preview', function () {
- if (!current_user_can($this->capability)) {
+ if (!current_user_can('manage_options')) {
wp_send_json_error(['message' => esc_html__('Unauthorized', 'gmap-embed')], 403);
}
// delegate to class method for easier testing
--- a/gmap-embed/includes/Traits/ImportExport.php
+++ b/gmap-embed/includes/Traits/ImportExport.php
@@ -26,7 +26,7 @@
// Nonce validation
check_admin_referer('wgm_export_nonce', '_wgm_export_nonce');
- if (!current_user_can($this->capability)) {
+ if (!current_user_can('manage_options')) {
wp_die(esc_html__('You do not have permission to export data.', 'gmap-embed'));
}
@@ -229,7 +229,7 @@
$redirect_with_error('invalid_nonce', 'Invalid import request.');
}
- if (!current_user_can($this->capability)) {
+ if (!current_user_can('manage_options')) {
$redirect_with_error('no_permission', 'You do not have permission to import data.');
}
@@ -345,41 +345,77 @@
// 1. Import Categories
$created_cats = 0;
$matched_cats = 0;
- if (!empty($categories)) {
+ $temp_parent_map = []; // new_id => old_parent_id
+ if (!empty($categories) && is_array($categories)) {
foreach ($categories as $cat) {
+ if (!is_array($cat)) {
+ continue;
+ }
$old_id = isset($cat['id']) ? intval($cat['id']) : 0;
- // remove id to auto-increment, remove dates to use current
- unset($cat['id'], $cat['created_at'], $cat['updated_at']);
-
- // Sanitize
- $cat['name'] = sanitize_text_field($cat['name']);
- $cat['icon'] = sanitize_text_field($cat['icon']);
-
+ $old_parent_id = isset($cat['parent_id']) ? intval($cat['parent_id']) : 0;
+ $cat_name = isset($cat['name']) ? sanitize_text_field($cat['name']) : '';
+
+ if (empty($cat_name)) {
+ continue;
+ }
+
// Check for existing category by name
- $lower_name = strtolower($cat['name']);
+ $lower_name = strtolower($cat_name);
if (isset($cat_name_to_id[$lower_name])) {
- if ($old_id) $cat_id_map[$old_id] = $cat_name_to_id[$lower_name];
+ if ($old_id) {
+ $cat_id_map[$old_id] = $cat_name_to_id[$lower_name];
+ }
$matched_cats++;
continue;
}
- // Parent ID logic is tricky if IDs change.
- // Simplified: Reset parent to 0 for now to avoid broken trees, or try to map if parent imported first.
- // Ideally we should do a second pass potential parents, but for now lets default 0 if mapping not found.
- $cat['parent_id'] = 0;
-
if (!$dry_run) {
+ // Strictly whitelisted schema columns to prevent SQL injection via crafted JSON object keys
+ $insert_cat = [
+ 'name' => $cat_name,
+ 'icon' => isset($cat['icon']) ? sanitize_text_field($cat['icon']) : '',
+ 'parent_id' => 0, // Set to 0 initially, resolved in Pass 2
+ 'created_at' => current_time('mysql'),
+ 'updated_at' => current_time('mysql'),
+ ];
+
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
- $wpdb->insert($categories_table, $cat);
+ $wpdb->insert(
+ $categories_table,
+ $insert_cat,
+ ['%s', '%s', '%d', '%s', '%s']
+ );
$new_id = $wpdb->insert_id;
- if ($old_id) $cat_id_map[$old_id] = $new_id;
+ if ($old_id) {
+ $cat_id_map[$old_id] = $new_id;
+ }
// Add to local cache to prevent duplicates in same file
- $cat_name_to_id[strtolower($cat['name'])] = $new_id;
+ $cat_name_to_id[$lower_name] = $new_id;
+
+ // Store parent ref for Pass 2 if it exists
+ if ($old_parent_id) {
+ $temp_parent_map[$new_id] = $old_parent_id;
+ }
}
$created_cats++;
}
-
- // Fix parents if possible (if we had improved logic we'd do a second pass update here using $cat_id_map)
+
+ // Pass 2: Update Parents
+ if (!$dry_run && !empty($temp_parent_map)) {
+ foreach ($temp_parent_map as $child_new_id => $old_parent_id) {
+ if (isset($cat_id_map[$old_parent_id])) {
+ $new_parent_id = $cat_id_map[$old_parent_id];
+ // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
+ $wpdb->update(
+ $categories_table,
+ ['parent_id' => $new_parent_id],
+ ['id' => $child_new_id],
+ ['%d'],
+ ['%d']
+ );
+ }
+ }
+ }
}
// 2. Import Maps
@@ -456,7 +492,11 @@
if (!$dry_run) {
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
- $wpdb->insert($markers_table, $insert);
+ $wpdb->insert(
+ $markers_table,
+ $insert,
+ array('%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%d')
+ );
}
$inserted_markers++;
}
@@ -552,7 +592,11 @@
];
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
- $wpdb->insert($categories_table, $insert);
+ $wpdb->insert(
+ $categories_table,
+ $insert,
+ ['%s', '%s', '%d', '%s', '%s']
+ );
$new_id = $wpdb->insert_id;
if ($old_id) {
@@ -631,20 +675,24 @@
if (!$dry_run && $target) {
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
- $wpdb->insert($markers_table, array(
- 'map_id' => $target,
- 'marker_name' => isset($item['marker_name']) ? sanitize_text_field($item['marker_name']) : '',
- 'lat_lng' => isset($item['lat_lng']) ? sanitize_text_field($item['lat_lng']) : '',
- 'address' => isset($item['address']) ? sanitize_text_field($item['address']) : '',
- 'category_id' => $cat_id,
- 'icon' => isset($item['icon']) ? sanitize_text_field($item['icon']) : '',
- 'animation' => isset($item['animation']) ? sanitize_text_field($item['animation']) : '',
- 'have_marker_link' => isset($item['have_marker_link']) ? sanitize_text_field($item['have_marker_link']) : '0',
- 'marker_link' => isset($item['marker_link']) ? sanitize_text_field($item['marker_link']) : '',
- 'marker_link_new_tab' => isset($item['marker_link_new_tab']) ? intval($item['marker_link_new_tab']) : 0,
- 'show_desc_by_default' => isset($item['show_desc_by_default']) ? intval($item['show_desc_by_default']) : 0,
- 'marker_desc' => isset($item['marker_desc']) ? $sanitize_meta('marker_desc', $item['marker_desc']) : ''
- ));
+ $wpdb->insert(
+ $markers_table,
+ array(
+ 'map_id' => $target,
+ 'marker_name' => isset($item['marker_name']) ? sanitize_text_field($item['marker_name']) : '',
+ 'lat_lng' => isset($item['lat_lng']) ? sanitize_text_field($item['lat_lng']) : '',
+ 'address' => isset($item['address']) ? sanitize_text_field($item['address']) : '',
+ 'category_id' => $cat_id,
+ 'icon' => isset($item['icon']) ? sanitize_text_field($item['icon']) : '',
+ 'animation' => isset($item['animation']) ? sanitize_text_field($item['animation']) : '',
+ 'have_marker_link' => isset($item['have_marker_link']) ? sanitize_text_field($item['have_marker_link']) : '0',
+ 'marker_link' => isset($item['marker_link']) ? sanitize_text_field($item['marker_link']) : '',
+ 'marker_link_new_tab' => isset($item['marker_link_new_tab']) ? intval($item['marker_link_new_tab']) : 0,
+ 'show_desc_by_default' => isset($item['show_desc_by_default']) ? intval($item['show_desc_by_default']) : 0,
+ 'marker_desc' => isset($item['marker_desc']) ? $sanitize_meta('marker_desc', $item['marker_desc']) : ''
+ ),
+ array('%d', '%s', '%s', '%s', '%d', '%s', '%s', '%s', '%s', '%d', '%d', '%s')
+ );
}
$inserted++;
}
@@ -674,7 +722,7 @@
wp_send_json_error(['message' => __('Invalid security nonce. Please reload the page.', 'gmap-embed')]);
}
- if (!current_user_can($this->capability)) {
+ if (!current_user_can('manage_options')) {
wp_send_json_error(['message' => __('You do not have permission to preview imports.', 'gmap-embed')]);
}
--- a/gmap-embed/includes/Traits/MapCRUD.php
+++ b/gmap-embed/includes/Traits/MapCRUD.php
@@ -657,6 +657,8 @@
$marker['updated_by'] = get_current_user_id();
$new_marker_data = wp_parse_args($marker, $marker_defaults);
+ // Intersect with known marker default keys to guarantee no unexpected or injected columns can reach $wpdb->insert
+ $new_marker_data = array_intersect_key($new_marker_data, $marker_defaults);
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$wpdb->insert("{$wpdb->prefix}wgm_markers", $new_marker_data);
}
--- a/gmap-embed/includes/Traits/MarkerCRUD.php
+++ b/gmap-embed/includes/Traits/MarkerCRUD.php
@@ -595,7 +595,10 @@
$marker['created_by'] = get_current_user_id();
$marker['updated_by'] = get_current_user_id();
- $new_marker_data = wp_parse_args($marker, $this->get_marker_default_values());
+ $marker_defaults = $this->get_marker_default_values();
+ $new_marker_data = wp_parse_args($marker, $marker_defaults);
+ // Intersect with known marker default keys to guarantee no unexpected or injected columns can reach $wpdb->insert
+ $new_marker_data = array_intersect_key($new_marker_data, $marker_defaults);
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$inserted = $wpdb->insert("{$wpdb->prefix}wgm_markers", $new_marker_data);
--- a/gmap-embed/includes/Traits/Menu.php
+++ b/gmap-embed/includes/Traits/Menu.php
@@ -102,7 +102,7 @@
'wpgmapembed',
esc_html__('Quick Setup', 'gmap-embed'),
esc_html__('Quick Setup', 'gmap-embed'),
- $this->capability,
+ 'manage_options',
'wgm_setup_wizard',
array(
$this,
@@ -129,7 +129,7 @@
'wpgmapembed',
esc_html__('Settings', 'gmap-embed'),
esc_html__('Settings', 'gmap-embed'),
- $this->capability,
+ 'manage_options',
'wpgmapembed-settings',
array(
$this,
@@ -250,6 +250,9 @@
public function wgm_settings()
{
+ if (!current_user_can('manage_options')) {
+ wp_die(esc_html__('You do not have permission to access this page.', 'gmap-embed'));
+ }
require WGM_PLUGIN_PATH . 'admin/includes/wpgmap_settings.php';
}
--- a/gmap-embed/includes/Traits/Settings.php
+++ b/gmap-embed/includes/Traits/Settings.php
@@ -478,7 +478,7 @@
{
check_admin_referer('wgm_settings_api_key_update', '_wp_nonce');
- if (!current_user_can($this->capability)) {
+ if (!current_user_can('manage_options')) {
wp_die(esc_html__('You do not have permission to update settings.', 'gmap-embed'));
}
@@ -500,7 +500,7 @@
{
check_admin_referer('wgm_settings_lc_key_update', '_wp_nonce');
- if (!current_user_can($this->capability)) {
+ if (!current_user_can('manage_options')) {
wp_die(esc_html__('You do not have permission to update settings.', 'gmap-embed'));
}
--- a/gmap-embed/includes/Traits/SetupWizard.php
+++ b/gmap-embed/includes/Traits/SetupWizard.php
@@ -15,6 +15,9 @@
*/
public function wpgmap_setup_wizard()
{
+ if (!current_user_can('manage_options')) {
+ wp_die(esc_html__('You do not have permission to access this page.', 'gmap-embed'));
+ }
require WGM_PLUGIN_PATH . 'admin/includes/wpgmap_setup_wizard.php';
}
@@ -27,7 +30,7 @@
{
check_ajax_referer('wpgmapembed_save_setup_wizard', 'nonce');
- if (!current_user_can($this->capability)) {
+ if (!current_user_can('manage_options')) {
echo wp_json_encode(['responseCode' => 403, 'message' => esc_html__('Unauthorized access.', 'gmap-embed')]);
die();
}
--- a/gmap-embed/srm_gmap_embed.php
+++ b/gmap-embed/srm_gmap_embed.php
@@ -7,7 +7,7 @@
Text Domain: gmap-embed
Domain Path: /languages
Author URI: https://www.wpgooglemap.com?utm_source=gmap-embed&utm_medium=wordpress-plugin&utm_campaign=branding&utm_content=author-uri
- Version: 1.9.9
+ Version: 2.0.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
@@ -18,8 +18,8 @@
exit;
}
-define('WGM_PLUGIN_VERSION', '1.9.9');
-define('WGM_PLUGIN_DEV_VERSION', '20261109');
+define('WGM_PLUGIN_VERSION', '2.0.0');
+define('WGM_PLUGIN_DEV_VERSION', '20261120');
define('WGM_PLUGIN_PATH', trailingslashit(plugin_dir_path(__FILE__)));
define('WGM_PLUGIN_URL', trailingslashit(plugins_url('/', __FILE__)));
define('WGM_ICONS_DIR', WGM_PLUGIN_PATH . 'admin/assets/images/markers/icons/');