Plugin Directory

Changeset 3805758


Ignore:
Timestamp:
11/16/2026 05:46:12 PM (18 hours ago)
Author:
cubewp1211
Message:

Release 1.1.13 - escape lead output on admin Leads screen, add capability checks, harden REST submission route

Location:
cubewp-forms/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • cubewp-forms/trunk/cube/classes/class-cubewp-forms-custom.php

    r3800555 r3805758  
    2525         * @var string
    2626         */
    27         public static $CubeWp_Forms_version = '1.1.12';
     27        public static $CubeWp_Forms_version = '1.1.13';
    2828        /**
    2929         * The single instance of the class.
  • cubewp-forms/trunk/cube/classes/class-cubewp-forms-dashboard.php

    r3800555 r3805758  
    5050                    $data[$leads['form_id']][$leadid]['dete_time'] = $leads['dete_time'];
    5151                }
    52                 $fields = unserialize($leads['fields']);
     52                // Stored lead data is an array of scalars; refuse to instantiate objects.
     53                $fields = unserialize($leads['fields'], array('allowed_classes' => false));
    5354                foreach($fields as $key=> $lead){
    5455                    if(isset($form_fields[$key])){
    … …  
    114115            $form_name = $form_detail['form_name'];
    115116            $active_class = $keyind == 0 ? 'cwp-active-tab' : '';
    116             $output .= '<li class="cwp-author-' . $form_id . '-tab ' . $active_class . '">
    117                         <a class="list-group-item" data-toggle="tab" href="#cwp-author-' . $form_id . '">' . $form_name . '</a>
     117            $output .= '<li class="cwp-author-' . esc_attr( $form_id ) . '-tab ' . esc_attr( $active_class ) . '">
     118                        <a class="list-group-item" data-toggle="tab" href="#cwp-author-' . esc_attr( $form_id ) . '">' . esc_html( $form_name ) . '</a>
    118119                        </li>';
    119120            $keyind++;
    … …  
    139140            $active_class = $keyind == 0 ? 'cwp-active-tab-content' : '';
    140141            if (count($form_details) > 1) {
    141                 $output .= '<div class="cwp-tab-content ' . $active_class . '" id="cwp-author-' . $form_id . '">';
     142                $output .= '<div class="cwp-tab-content ' . esc_attr( $active_class ) . '" id="cwp-author-' . esc_attr( $form_id ) . '">';
    142143            }
    143144            $output .= '<div class="cwp-dashboard-content-table-container">
    … …  
    277278        if (isset($form_data['fields']) && !empty($form_data['fields'])) {
    278279            $form_fields =  CWP()->get_custom_fields('custom_forms');
    279             $fields = unserialize($form_data['fields']);
     280            // Stored lead data is an array of scalars; refuse to instantiate objects.
     281            $fields = unserialize($form_data['fields'], array('allowed_classes' => false));
    280282            foreach ($fields as $key => $lead) {
    281283                $field_data = isset($form_fields[$key]) ? $form_fields[$key] : '';
  • cubewp-forms/trunk/cube/classes/class-cubewp-forms-data-table.php

    r3420003 r3805758  
    104104        protected function process_bulk_action()
    105105        {
     106                // Deleting leads is an administrator action.
     107                if (! current_user_can('manage_options')) {
     108                        return;
     109                }
    106110                // Detect when a bulk action is being triggered.
    107111                if ('delete' === $this->current_action()) {
    108112                        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
    109113                        if (isset($_REQUEST['_wpnonce'])) {
    110                                 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash       
    111                                 $nonce = sanitize_text_field($_REQUEST['_wpnonce']);
     114                                $nonce = sanitize_text_field(wp_unslash($_REQUEST['_wpnonce']));
    112115                                if (wp_verify_nonce($nonce, 'bulk-' . $this->_args['plural'])) {
    113116                                        if (isset($_REQUEST['cwp_group_bulk_action'])) {
    … …  
    122125                }
    123126                // phpcs:ignore WordPress.Security.NonceVerification.Recommended
    124                 if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
    125                         // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
     127                if (isset($_REQUEST['action']) && 'delete' === sanitize_text_field(wp_unslash($_REQUEST['action']))) {
     128                        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
    126129                        if (isset($_REQUEST['_wpnonce'])) {
    127                                 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash       
    128                                 $nonce = sanitize_text_field($_REQUEST['_wpnonce']);
    129                                 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized   
     130                                $nonce = sanitize_text_field(wp_unslash($_REQUEST['_wpnonce']));
    130131                                if (wp_verify_nonce($nonce, 'cwp_delete_group')) {
    131132                                        if (isset($_REQUEST['leadid'])) {
    132                                                 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
    133                                                 $leadid = $_REQUEST['leadid'];
     133                                                // phpcs:ignore WordPress.Security.NonceVerification.Recommended
     134                                                $leadid = sanitize_text_field(wp_unslash($_REQUEST['leadid']));
    134135                                                cwp_remove_lead($leadid);
    135                                         } 
     136                                        }
    136137                                        wp_safe_redirect(CubeWp_Submenu::_page_action('cubewp-custom-form-data'));
    137138                                        exit();
  • cubewp-forms/trunk/cube/classes/class-cubewp-forms-leads.php

    r3420003 r3805758  
    156156        if(isset($form_data['fields']) && !empty($form_data['fields'])){
    157157            $output .=  ' <table>';
    158             $fields = unserialize($form_data['fields']);
     158            // Stored lead data is an array of scalars; refuse to instantiate objects.
     159            $fields = unserialize($form_data['fields'], array('allowed_classes' => false));
    159160            foreach($fields as $key=> $lead){
    160161                $data = isset($form_fields[$key]) ? $form_fields[$key] : array();
    … …  
    177178                if($field_type == 'repeating_field'){
    178179                    $output .= '<tr>
    179                     <th>'.$data['label'].'</th>
     180                    <th>'.esc_html(isset($data['label']) ? $data['label'] : '').'</th>
    180181                    <td class="cwp-forms-repeating-fields">';
    181182                    foreach($repeater['label'] as $k => $label){
    182183                        if(isset($repeater['value'][$k]) && !empty($repeater['value'][$k])){
    183184                            $output .= '<div class="cwp-forms-repeating-field">';
    184                             $output .= '<h6>'.$label.' </h6><p>'.$repeater['value'][$k].'</p>';
     185                            $output .= '<h6>'.esc_html($label).' </h6><p>'.wp_kses_post($repeater['value'][$k]).'</p>';
    185186                            $output .= '</div>';
    186187                        }
    … …  
    191192                        $label = isset($data['label']) ? $data['label'] : '';
    192193                        $output .= ' <tr>
    193                         <th>'.$label.'</th>
    194                         <td>'.$value.'</td>
     194                        <th>'.esc_html($label).'</th>
     195                        <td>'.wp_kses_post($value).'</td>
    195196                        </tr>';
    196197                    }
  • cubewp-forms/trunk/cube/classes/class-cubewp-forms-rest-api.php

    r3800555 r3805758  
    4545                        array(
    4646                                array(
    47                                         'methods'             => WP_REST_Server::READABLE,
     47                                        // Security (M2): CREATABLE, not READABLE. A GET that writes is
     48                                        // reachable from an <img> tag and is cacheable. See
     49                                        // cubewp_update_forms() for why the GET could be retired.
     50                                        'methods'             => WP_REST_Server::CREATABLE,
    4851                                        'callback'            => array( $this, 'cubewp_update_forms' ),
    4952                                        'permission_callback' => array( $this, 'get_without_permission_check' ),
    … …  
    164167                $CWP_QUERY = $request->get_param(self::CWP_QUERY);
    165168
    166                 if (!empty($CWP_QUERY) && count($CWP_QUERY) > 0) {
     169                if (is_array($CWP_QUERY) && count($CWP_QUERY) > 0) {
    167170                        /*
    168171                         * The submission handler reads from $_POST, so the request data is
    … …  
    170173                         * restored immediately afterwards, leaving the superglobal unchanged
    171174                         * for any later hook in the same request.
     175                         *
     176                         * Security (M2 closed): the route no longer MINTS the nonce it then
     177                         * checks, and it accepts POST only (see register_routes()).
     178                         *
     179                         * This line used to set security_nonce to a freshly created
     180                         * 'cubewp_forms_submit' nonce, so the form's CSRF check could never
     181                         * fail for anyone who called this route instead of the form. Now the
     182                         * caller's own security_nonce is passed through untouched, and
     183                         * cubewp_submit_custom_form() verifies it exactly as it does for the
     184                         * form's normal admin-ajax submission. A caller gets that nonce the
     185                         * same way the form does - from the rendered page - so a genuine
     186                         * integration keeps working and a blind script does not.
     187                         *
     188                         * Safe to change: the plugin's own front end submits through
     189                         * admin-ajax (custom-form-submit.js), never through this route; and
     190                         * on the CubeWP fleet (2026-11-16) no caller was recorded on any
     191                         * site, while 14 days of access logs held two scanner-shaped hits.
    172192                         */
    173                         // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Superglobal is only snapshotted here so it can be restored below; the request itself is authorised by the REST permission callback.
     193                        // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Superglobal is only snapshotted here so it can be restored below; the nonce is verified by cubewp_submit_custom_form().
    174194                        $original_post = $_POST;
    175                         $CWP_QUERY['security_nonce'] = wp_create_nonce('cubewp_forms_submit');
    176195                        // Simulate the $_POST array with the received $CWP_QUERY data
    177196                        $_POST = $CWP_QUERY;
  • cubewp-forms/trunk/cube/classes/class-cubewp-forms-table.php

    r3420003 r3805758  
    128128        }
    129129    protected function process_bulk_action() {
     130                // Deleting forms is an administrator action.
     131                if ( ! current_user_can( 'manage_options' ) ) {
     132                        return;
     133                }
    130134                // Detect when a bulk action is being triggered.
    131                 if ( 'delete' === $this->current_action() ) { 
     135                if ( 'delete' === $this->current_action() ) {
    132136            // phpcs:ignore WordPress.Security.NonceVerification.Recommended
    133137            if ( isset( $_REQUEST['_wpnonce'] ) ) {
  • cubewp-forms/trunk/cube/classes/class-cubewp-forms-ui.php

    r3420003 r3805758  
    587587     */
    588588    protected static function save_group() {
     589        // Building forms is an administrator action.
     590        if ( ! current_user_can( 'manage_options' ) ) {
     591            return;
     592        }
    589593        // Verify nonce for form submission
    590594        if ( ! isset( $_POST['cwp_form_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['cwp_form_nonce'] ) ), basename( __FILE__ ) ) ) {
  • cubewp-forms/trunk/cubewp-forms.php

    r3800555 r3805758  
    44 * Plugin URI: https://cubewp.com/
    55 * Description: LeadGen & Contact Form by CubeWP – Drag & Drop Form Builder for WordPress
    6  * Version: 1.1.12
     6 * Version: 1.1.13
    77 * Author: CubeWP
    88 * Author URI: https://CubeWp.com
  • cubewp-forms/trunk/readme.txt

    r3800555 r3805758  
    66Requires PHP: 7.0
    77Tested up to: 7.1
    8 Stable tag: 1.1.12
     8Stable tag: 1.1.13
    99License: GPLv2 or later
    1010
    … …  
    254254== Changelog ==
    255255
     256= 1.1.13 2026-11-16
     257
     258SECURITY: Field labels and submitted values are now escaped on the admin Leads screen, on both the standard and the repeating field branches.
     259SECURITY: Form names and tab identifiers are now escaped on the frontend dashboard lead tabs.
     260SECURITY: Added capability checks to the lead delete, form delete and form builder save handlers, which previously verified only a nonce.
     261SECURITY: The form submission REST route now accepts POST only and verifies the submitted nonce instead of creating one, so the form's own security check also applies to API submissions.
     262SECURITY: Stored lead data can no longer instantiate PHP objects when it is read back.
     263
    256264= 1.1.12 2026-11-11
    257265
Note: See TracChangeset for help on using the changeset viewer.