Plugin Directory

Changeset 3772665


Ignore:
Timestamp:
10/29/2026 10:44:25 AM (6 hours ago)
Author:
ithemelandco
Message:

4.6
Security: Fixed an unauthenticated arbitrary shortcode execution vulnerability in the gift popup AJAX handler.
Security: Restricted gift layouts to supported values and improved shortcode attribute validation and escaping.
Credits: Thanks to Nguyen Quang Tan and Patchstack for responsibly reporting this vulnerability.

Location:
ithemeland-free-gifts-for-woo/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ithemeland-free-gifts-for-woo/trunk/frontend/classes/shortcodes.php

    r3729325 r3772665  
    161161        );
    162162
     163        $atts_shortcode['type'] = $this->normalize_gift_layout($atts_shortcode['type']);
     164
    163165        $flag = true;
    164166        $gift_items = $this->check_rule_condition->pw_get_gift_for_cart_checkout();
    … …  
    197199        }
    198200
    199         echo wp_kses('<span class="itg-shortoces-products" data-type="' . $atts['type'] . '"  >', Sanitizer::allowed_html());
     201        echo wp_kses('<span class="itg-shortoces-products" data-type="' . esc_attr($atts_shortcode['type']) . '"  >', Sanitizer::allowed_html());
    200202
    201203        if ($flag) {
    … …  
    212214            $rule_products = [
    213215                'data_args' => itfreegift_get_gift_products_data_multilevel($args_data),
    214                 'template' => $atts['type']
     216                'template' => $atts_shortcode['type']
    215217            ];
    216218
    … …  
    221223    }
    222224
     225    /**
     226     * Only registered gift layouts may reach template selection.
     227     */
     228    private function normalize_gift_layout($type)
     229    {
     230        $type = is_string($type) ? sanitize_key($type) : '';
     231        return in_array($type, ['carousel', 'grid', 'datatable', 'dropdown'], true) ? $type : 'dropdown';
     232    }
     233
    223234    public function shortcode_show_popup()
    224235    {
    225         $type = sanitize_text_field(wp_unslash($_POST['type'])); //phpcs:ignore
    226         echo do_shortcode('[itg_gift_products type="' . $type . '"]');
     236        $raw_type = isset($_POST['type']) && is_string($_POST['type']) ? wp_unslash($_POST['type']) : '';
     237        $type = $this->normalize_gift_layout($raw_type);
     238        // Invoke our renderer directly; never parse request input as shortcode source.
     239        $this->shortcode_gift_products(['type' => $type], '');
    227240        wp_die();
    228241    }
    … …  
    235248        check_ajax_referer('jkhKJSdd4576d234Z', 'itg_security');
    236249
    237         $type = isset($_POST['type']) ? sanitize_key(wp_unslash($_POST['type'])) : 'dropdown'; //phpcs:ignore
    238         if (!in_array($type, ['carousel', 'grid', 'datatable', 'dropdown'], true)) {
    239             $type = 'dropdown';
    240         }
     250        $raw_type = isset($_POST['type']) && is_string($_POST['type']) ? wp_unslash($_POST['type']) : '';
     251        $type = $this->normalize_gift_layout($raw_type);
    241252
    242253        $this->rendering_checkout = true;
    243         echo do_shortcode('[itg_gift_products type="' . $type . '"]');
     254        $this->shortcode_gift_products(['type' => $type], '');
    244255        $this->rendering_checkout = false;
    245256        wp_die();
  • ithemeland-free-gifts-for-woo/trunk/ithemeland-free-gifts-for-woo.php

    r3767915 r3772665  
    55        Description: Free Gifts for WooCommerce allows you to offer Free Gifts to your customers whenever they make a purchase on your site.
    66        Author: iThemelandco
    7         Version: 4.5
     7        Version: 4.6
    88        Tags: woocommerce,woocommerce gift
    99        Text Domain: ithemeland-free-gifts-for-woo
    … …  
    5555//define('WGBL_WP_TESTED', '6.6');
    5656define('WGBL_WP_REQUIRE', '5.0.0');
    57 define('WGBL_VERSION', '4.5');
     57define('WGBL_VERSION', '4.6');
    5858
    5959register_activation_hook(__FILE__, ['ITFreeGift\classes\bootstrap\WGBL', 'activate']);
  • ithemeland-free-gifts-for-woo/trunk/readme.txt

    r3767915 r3772665  
    55Requires at least: 5.0
    66Tested up to: 7.1
    7 Stable tag: 4.5
     7Stable tag: 4.6
    88Requires PHP: 7.0
    99License: GPLv2 or later
    … …  
    609609
    610610== Changelog ==
     6114.6
     612* Security: Fixed an unauthenticated arbitrary shortcode execution vulnerability in the gift popup AJAX handler.
     613* Security: Restricted gift layouts to supported values and improved shortcode attribute validation and escaping.
     614Credits: Thanks to Nguyen Quang Tan and Patchstack for responsibly reporting this vulnerability.
    611615= 4.5 =
    612616* Fixed: Duplicate gift additions caused by repeated clicks, overlapping requests, or slow AJAX responses.
Note: See TracChangeset for help on using the changeset viewer.