Plugin Directory

Changeset 3293562


Ignore:
Timestamp:
05/14/2025 10:17:09 PM (10 months ago)
Author:
onlineada
Message:

4.19

Location:
online-accessibility
Files:
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • online-accessibility/tags/4.19/CHANGELOG.md

    r3268067 r3293562  
    11# Changelog
    22All notable changes to this project will be documented in this file.
     34.19
     4- Updated patch for arbitrary file upload vulnerability - https://patchstack.com/database/wordpress/plugin/online-accessibility/vulnerability/wordpress-accessibility-suite-plugin-4-17-arbitrary-file-upload-vulnerability?_a_id=15
     5- Updated patch for broken access control vulnerability - https://patchstack.com/database/wordpress/plugin/online-accessibility/vulnerability/wordpress-accessibility-suite-by-ability-inc-plugin-4-16-multiple-broken-access-control-vulnerability?_a_id=15
     6- Patched sql injection vulnerability - https://patchstack.com/database/wordpress/plugin/online-accessibility/vulnerability/wordpress-accessibility-suite-by-ability-inc-plugin-4-17-sql-injection-vulnerability?_a_id=15
     7- Tested up to WordPress 6.8.1
    38
    494.18
    5 - Patched arbitrary file upload vulnerability - https://patchstack.com/database/report-preview/dedfa172-1348-46f1-afdb-3ca0104afb90
    6 - Patched broken access control vulnerability - https://patchstack.com/database/report-preview/ccae245c-4b01-4081-a687-150ff6ad0627
     10- Patched arbitrary file upload vulnerability - https://patchstack.com/database/wordpress/plugin/online-accessibility/vulnerability/wordpress-accessibility-suite-plugin-4-17-arbitrary-file-upload-vulnerability?_a_id=15
     11- Patched broken access control vulnerability - https://patchstack.com/database/wordpress/plugin/online-accessibility/vulnerability/wordpress-accessibility-suite-by-ability-inc-plugin-4-16-multiple-broken-access-control-vulnerability?_a_id=15
    712- Tested up to WordPress 6.7.2
    813-
  • online-accessibility/tags/4.19/README.txt

    r3268067 r3293562  
    77Author URI: https://adaplugin.com
    88Author: Ability, Inc
    9 Tested up to: 6.7.2
    10 Stable tag: "4.18"
    11 Version 4.18
     9Tested up to: 6.8.1
     10Stable tag: "4.19"
     11Version 4.19
    1212License: GPLv2 or later
    1313License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • online-accessibility/tags/4.19/includes/ajax_functions/core.php

    r3091769 r3293562  
    1111{
    1212    Helper::verify_security($_GET);
     13
     14    // Add capability check to ensure user has proper permissions
     15    if (!current_user_can('manage_options')) {
     16        wp_send_json_error('Unauthorized access', 403);
     17        wp_die();
     18    }
     19   
     20    // Add referrer check to ensure request comes from your admin pages
     21    $referer = wp_get_referer();
     22    if (!$referer || strpos($referer, admin_url()) !== 0) {
     23        wp_send_json_error('Invalid request origin', 403);
     24        wp_die();
     25    }
     26
    1327    $scan = get_active_scan();
    1428    $details = [];
     
    89103{
    90104    Helper::verify_security($_GET);
     105
     106    // Add capability check to ensure user has proper permissions
     107    if (!current_user_can('manage_options')) {
     108        wp_send_json_error('Unauthorized access', 403);
     109        wp_die();
     110    }
     111   
     112    // Add referrer check to ensure request comes from your admin pages
     113    $referer = wp_get_referer();
     114    if (!$referer || strpos($referer, admin_url()) !== 0) {
     115        wp_send_json_error('Invalid request origin', 403);
     116        wp_die();
     117    }
     118
    91119    $scan = get_active_scan();
    92120    update_post_meta($scan->ID, '_oadaas_scan-dismissed', 1);
     
    101129{
    102130    Helper::verify_security($_POST);
     131
     132    // Add capability check to ensure user has proper permissions
     133    if (!current_user_can('manage_options')) {
     134        wp_send_json_error('Unauthorized access', 403);
     135        wp_die();
     136    }
     137   
     138    // Add referrer check to ensure request comes from your admin pages
     139    $referer = wp_get_referer();
     140    if (!$referer || strpos($referer, admin_url()) !== 0) {
     141        wp_send_json_error('Invalid request origin', 403);
     142        wp_die();
     143    }
     144
    103145    $scan = new WCAG_Scan((int)$_POST['scan_id']);
    104146
     
    129171{
    130172    Helper::verify_security($_POST);
     173
     174    // Add capability check to ensure user has proper permissions
     175    if (!current_user_can('manage_options')) {
     176        wp_send_json_error('Unauthorized access', 403);
     177        wp_die();
     178    }
     179   
     180    // Add referrer check to ensure request comes from your admin pages
     181    $referer = wp_get_referer();
     182    if (!$referer || strpos($referer, admin_url()) !== 0) {
     183        wp_send_json_error('Invalid request origin', 403);
     184        wp_die();
     185    }
    131186
    132187    $scan = get_active_scan();
     
    185240{
    186241    Helper::verify_security($_GET);
     242
     243    // Add capability check to ensure user has proper permissions
     244    if (!current_user_can('manage_options')) {
     245        wp_send_json_error('Unauthorized access', 403);
     246        wp_die();
     247    }
     248   
     249    // Add referrer check to ensure request comes from your admin pages
     250    $referer = wp_get_referer();
     251    if (!$referer || strpos($referer, admin_url()) !== 0) {
     252        wp_send_json_error('Invalid request origin', 403);
     253        wp_die();
     254    }
     255
    187256    $scan = get_active_scan();
    188257    $page = $_GET["page"];
     
    203272{
    204273    Helper::verify_security($_POST);
     274
     275    // Add capability check to ensure user has proper permissions
     276    if (!current_user_can('manage_options')) {
     277        wp_send_json_error('Unauthorized access', 403);
     278        wp_die();
     279    }
     280   
     281    // Add referrer check to ensure request comes from your admin pages
     282    $referer = wp_get_referer();
     283    if (!$referer || strpos($referer, admin_url()) !== 0) {
     284        wp_send_json_error('Invalid request origin', 403);
     285        wp_die();
     286    }
     287
    205288    $scan = get_active_scan();
    206289    $result = $scan->step_complete();
     
    365448{
    366449    Helper::verify_security($_POST);
     450
     451    // Add capability check to ensure user has proper permissions
     452    if (!current_user_can('manage_options')) {
     453        wp_send_json_error('Unauthorized access', 403);
     454        wp_die();
     455    }
     456   
     457    // Add referrer check to ensure request comes from your admin pages
     458    $referer = wp_get_referer();
     459    if (!$referer || strpos($referer, admin_url()) !== 0) {
     460        wp_send_json_error('Invalid request origin', 403);
     461        wp_die();
     462    }
     463
    367464    $scan = get_active_scan();
    368465    $step = get_post_meta($scan->ID, "_filter_step", true);
     
    376473{
    377474    Helper::verify_security($_POST);
     475
     476    // Add capability check to ensure user has proper permissions
     477    if (!current_user_can('manage_options')) {
     478        wp_send_json_error('Unauthorized access', 403);
     479        wp_die();
     480    }
     481   
     482    // Add referrer check to ensure request comes from your admin pages
     483    $referer = wp_get_referer();
     484    if (!$referer || strpos($referer, admin_url()) !== 0) {
     485        wp_send_json_error('Invalid request origin', 403);
     486        wp_die();
     487    }
     488
    378489    set_transient("_oadaas_upgrade_banner_dismissed", 1, 120 * DAY_IN_SECONDS);
    379490    wp_send_json(["message" => "success"], 200);
     
    408519function get_scan_results(){
    409520    Helper::verify_security($_POST);
     521
     522    // Add capability check to ensure user has proper permissions
     523    if (!current_user_can('manage_options')) {
     524        wp_send_json_error('Unauthorized access', 403);
     525        wp_die();
     526    }
     527   
     528    // Add referrer check to ensure request comes from your admin pages
     529    $referer = wp_get_referer();
     530    if (!$referer || strpos($referer, admin_url()) !== 0) {
     531        wp_send_json_error('Invalid request origin', 403);
     532        wp_die();
     533    }
     534
    410535    $results = Helper::get_scan_data($_POST["scan_id"], $_POST["offset"], $_POST["limit"]);
    411536    $rows = Helper::get_row_count($_POST["scan_id"]);
  • online-accessibility/tags/4.19/includes/ajax_functions/site-updates.php

    r3091769 r3293562  
    88function save_changes(){
    99    Helper::verify_security($_POST);
     10
     11    // Add capability check to ensure user has proper permissions
     12    if (!current_user_can('manage_options')) {
     13        wp_send_json_error('Unauthorized access', 403);
     14        wp_die();
     15    }
     16   
     17    // Add referrer check to ensure request comes from your admin pages
     18    $referer = wp_get_referer();
     19    if (!$referer || strpos($referer, admin_url()) !== 0) {
     20        wp_send_json_error('Invalid request origin', 403);
     21        wp_die();
     22    }
    1023   
    1124    foreach($_POST["modified"] AS $ID => $changes){
     
    98111function get_list(){
    99112    Helper::verify_security($_POST);
     113
     114    // Add capability check to ensure user has proper permissions
     115    if (!current_user_can('manage_options')) {
     116        wp_send_json_error('Unauthorized access', 403);
     117        wp_die();
     118    }
     119   
     120    // Add referrer check to ensure request comes from your admin pages
     121    $referer = wp_get_referer();
     122    if (!$referer || strpos($referer, admin_url()) !== 0) {
     123        wp_send_json_error('Invalid request origin', 403);
     124        wp_die();
     125    }
     126
    100127    global $wpdb;
    101128    $pageLength = $_POST["pageLength"];
     
    172199function get_image_count(){
    173200    Helper::verify_security($_POST);
     201
     202    // Add capability check to ensure user has proper permissions
     203    if (!current_user_can('manage_options')) {
     204        wp_send_json_error('Unauthorized access', 403);
     205        wp_die();
     206    }
     207   
     208    // Add referrer check to ensure request comes from your admin pages
     209    $referer = wp_get_referer();
     210    if (!$referer || strpos($referer, admin_url()) !== 0) {
     211        wp_send_json_error('Invalid request origin', 403);
     212        wp_die();
     213    }
     214   
    174215    $valid = $_POST["valid"];
    175216    global $wpdb;
  • online-accessibility/tags/4.19/includes/ajax_functions/sitemap.php

    r3268067 r3293562  
    126126function server_validate_upload($file)
    127127{
    128     $is_csv = true;
     128    // Verify user has appropriate permissions
     129    if (!current_user_can('manage_options')) {
     130        return "Unauthorized access";
     131    }
     132
     133    // Validate file exists and has no errors
     134    if (!isset($file) || $file['error'] !== UPLOAD_ERR_OK) {
     135        return "File upload error: " . (isset($file['error']) ? $file['error'] : 'Unknown error');
     136    }
     137
     138    // Get file extension and validate
    129139    $pathinfo = pathinfo($file['name']);
    130 
    131     if ($pathinfo["extension"] !== "csv") {
    132         $is_csv = false;
    133     }
    134 
    135     if (getimagesize($file["tmp_name"])) {
    136         return "Incorrect file format: " . $pathinfo["extension"];
    137         wp_die();
    138     }
    139 
     140    $extension = strtolower($pathinfo["extension"] ?? '');
     141   
     142    // Define allowed file formats
    140143    $supportedFormats = ['csv', 'txt', 'xml', 'xls', 'xlsx'];
    141 
    142     if (in_array($pathinfo["extension"], $supportedFormats)) {
    143         //Store the uploaded file to the server
    144         $basedir = wp_upload_dir()["basedir"];
    145         $rel_path = "/oadaas/sitemap/";
    146 
    147         $filename = "sitemap." . $pathinfo["extension"];
    148         $path = $basedir . $rel_path . $filename;
    149 
    150         if (!file_exists($basedir . $rel_path)) {
    151             wp_mkdir_p($basedir . $rel_path, 0777, true);
    152         }
    153 
    154         $success = move_uploaded_file($file["tmp_name"], $path);  // phpcs:ignore
     144   
     145    if (!in_array($extension, $supportedFormats)) {
     146        return "Incorrect file format: " . esc_html($extension);
     147    }
     148   
     149    // Additional security check - prevent image uploads disguised as other formats
     150    $finfo = new \finfo(FILEINFO_MIME_TYPE);
     151    $mime_type = $finfo->file($file["tmp_name"]);
     152    $allowed_mime_types = [
     153        'text/csv', 'text/plain', 'application/xml', 'text/xml',
     154        'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
     155    ];
     156   
     157    if (!in_array($mime_type, $allowed_mime_types)) {
     158        return "Invalid file type detected: " . esc_html($mime_type);
     159    }
     160   
     161    // Set up directory with secure permissions
     162    $basedir = wp_upload_dir()["basedir"];
     163    $rel_path = "/oadaas/sitemap/";
     164    $upload_dir = $basedir . $rel_path;
     165   
     166    // Create directory with secure permissions if it doesn't exist
     167    if (!file_exists($upload_dir)) {
     168        if (!wp_mkdir_p($upload_dir, 0755, true)) {
     169            return "Failed to create upload directory";
     170        }
     171    }
     172   
     173    // Set secure file path
     174    $filename = "sitemap." . $extension;
     175    $path = $upload_dir . $filename;
     176   
     177    // Move uploaded file
     178    if (!move_uploaded_file($file["tmp_name"], $path)) {
     179        return "Failed to move uploaded file";
     180    }
     181   
     182    // Process file based on type
     183    if ($extension === 'csv') {
     184        // Process CSV file
    155185        try {
    156             if ($success && !$is_csv) {
    157                 $new_filename = "sitemap.csv";
    158                 //Convert the file to CSV
    159                 switch ($pathinfo["extension"]) {
    160                     case "xml":
    161                         if (file_exists($path)) {
    162                             $xml = simplexml_load_file($path);
    163                             $f = fopen($basedir . $rel_path . $new_filename, 'w');  // phpcs:ignore
    164                             convert_xml_to_csv($xml, $f);
    165                             $stat = fstat($f);
    166                             ftruncate($f, $stat['size'] - 1);
    167                             fclose($f);  // phpcs:ignore
    168                             wp_delete_file($path);
    169                         }
    170                         break;
    171                 }
    172                 return "success";
    173             }
    174         }
    175         catch(\Exception $e) {
     186            $put_arr = [];
     187            $f = fopen($path, 'r');
     188            if (!$f) {
     189                wp_delete_file($path);
     190                return "Failed to open CSV file";
     191            }
     192           
     193            while (($line = fgetcsv($f, 0, ",")) !== false) {
     194                $put_arr[] = $line;
     195            }
     196            fclose($f);
     197           
     198            // Only proceed if we have data
     199            if (empty($put_arr) || empty($put_arr[0])) {
     200                wp_delete_file($path);
     201                return "CSV file is empty or invalid";
     202            }
     203           
     204            // Rewrite the CSV file securely
     205            $f = fopen($path, "w");
     206            if (!$f) {
     207                wp_delete_file($path);
     208                return "Failed to write CSV file";
     209            }
     210           
     211            foreach ($put_arr[0] as $item) {
     212                fputcsv($f, [sanitize_text_field($item)], ',', '"');
     213            }
     214           
     215            $stat = fstat($f);
     216            ftruncate($f, $stat['size'] - 1);
     217            fclose($f);
     218           
     219            return "success";
     220        } catch (\Exception $e) {
     221            // Clean up on error
     222            if (file_exists($path)) {
     223                wp_delete_file($path);
     224            }
     225            return "Error processing CSV: " . esc_html($e->getMessage());
     226        }
     227    } else if ($extension === 'xml') {
     228        // Convert XML to CSV
     229        try {
     230            if (!file_exists($path)) {
     231                return "XML file not found after upload";
     232            }
     233           
     234            // Validate XML structure before processing
     235            $xml = @simplexml_load_file($path);
     236            if ($xml === false) {
     237                wp_delete_file($path);
     238                return "Invalid XML file";
     239            }
     240           
     241            $csv_path = $upload_dir . "sitemap.csv";
     242            $f = fopen($csv_path, 'w');
     243            if (!$f) {
     244                wp_delete_file($path);
     245                return "Failed to create CSV file";
     246            }
     247           
     248            // Convert XML to CSV with proper error handling
     249            $result = convert_xml_to_csv($xml, $f);
     250            if ($result === false) {
     251                fclose($f);
     252                wp_delete_file($csv_path);
     253                wp_delete_file($path);
     254                return "Failed to convert XML to CSV";
     255            }
     256           
     257            $stat = fstat($f);
     258            ftruncate($f, $stat['size'] - 1);
     259            fclose($f);
     260           
     261            // Remove the original XML file after successful conversion
    176262            wp_delete_file($path);
    177         }
    178         if ($is_csv) {
    179             $put_arr = [];
     263           
     264            return "success";
     265        } catch (\Exception $e) {
     266            // Clean up on error
    180267            if (file_exists($path)) {
    181                 //Read and store contents of uploaded CSV file into an array
    182                 $f = fopen($path, 'r');  // phpcs:ignore
    183                 while (($line = fgetcsv($f, 0, ",")) !== false) {
    184                     $put_arr[] = $line;
    185                 }
    186                 fclose($f);  // phpcs:ignore
    187 
    188                 //Rewrite the CSV file to use '/n' after delimiter
    189                 $f = fopen($path, "w");  // phpcs:ignore
    190                 foreach ($put_arr[0] as $item) {
    191                     fputcsv($f, [$item], ',', '"');
    192                 }
    193                 $stat = fstat($f);
    194                 ftruncate($f, $stat['size'] - 1);
    195                 fclose($f);  // phpcs:ignore
    196                 return "success";
    197             }
    198         }
    199     }
    200     return "Incorrect file format: " . $pathinfo["extension"];
    201     wp_die();
    202 }
     268                wp_delete_file($path);
     269            }
     270            if (file_exists($upload_dir . "sitemap.csv")) {
     271                wp_delete_file($upload_dir . "sitemap.csv");
     272            }
     273            return "Error processing XML: " . esc_html($e->getMessage());
     274        }
     275    } else {
     276        // For other file types that need conversion but aren't implemented yet
     277        wp_delete_file($path);
     278        return "File type " . esc_html($extension) . " is supported but conversion is not implemented";
     279    }
     280}
     281
    203282
    204283function convert_xml_to_csv($xml, $f)
  • online-accessibility/tags/4.19/includes/classes/Helper.php

    r3268067 r3293562  
    9797    static function save_false_positive($scan_id, $issue_id){
    9898        global $wpdb;
    99         $table_name = $wpdb->prefix.'oada_false_positives';
    100 
    101         if(! is_admin()) {
    102             return '';
    103         }
    104 
     99        $table_name = $wpdb->prefix.'oada_false_positives';
     100   
     101        if(! is_admin()) {
     102            return '';
     103        }
     104   
     105        // Validate inputs
     106        $scan_id = absint($scan_id); // Ensure scan_id is a positive integer
     107       
     108        if (!$scan_id) {
     109            return ["status" => "failed", "msg" => "Invalid scan ID"];
     110        }
     111       
    105112        try{
    106             //Get list
    107             $list = json_decode(
    108                 $wpdb->get_results($wpdb->prepare("SELECT list FROM  $table_name WHERE scan_id = $scan_id"))[0]->list // phpcs:ignore
     113            // Get list using properly prepared query
     114            $query = $wpdb->prepare(
     115                "SELECT list FROM %i WHERE scan_id = %d",
     116                $table_name,
     117                $scan_id
    109118            );
    110 
    111             //Add to list
     119           
     120            $result = $wpdb->get_results($query);
     121           
     122            if (empty($result)) {
     123                return ["status" => "failed", "msg" => "Scan not found"];
     124            }
     125           
     126            $list = json_decode($result[0]->list);
     127           
     128            // Validate list is an array
     129            if (!is_array($list)) {
     130                $list = [];
     131            }
     132           
     133            // Add to list
    112134            $list[] = $issue_id;
    113             $list = $wpdb->_real_escape(json_encode($list));
    114 
    115             //Save new list
    116             $wpdb->query($wpdb->prepare("UPDATE $table_name SET list = '$list' WHERE scan_id =$scan_id")); // phpcs:ignore
     135           
     136            // Prepare the JSON string properly
     137            $json_list = wp_json_encode($list);
     138           
     139            // Update with properly prepared query
     140            $updated = $wpdb->update(
     141                $table_name,
     142                ['list' => $json_list],
     143                ['scan_id' => $scan_id],
     144                ['%s'],
     145                ['%d']
     146            );
     147           
     148            if ($updated === false) {
     149                return ["status" => "failed", "msg" => "Database update failed"];
     150            }
     151           
    117152            return ["status" => "success"];
    118         }catch(\Exception $e){
    119             return ["status" => "failed", "msg" => $e];
    120         }
    121     }
     153        } catch(\Exception $e){
     154            return ["status" => "failed", "msg" => $e->getMessage()];
     155        }
     156    }
     157   
    122158
    123159    static function delete_false_positive($scan_id, $issue_id){
  • online-accessibility/tags/4.19/index.php

    r3268067 r3293562  
    66 * Plugin URI:        https://adaplugin.com
    77 * Description:       The most powerful and comprehensive Accessibility Suite. Achieve and maintain ADA/WCAG compliance faster than ever before. Audit, identify, get instruction, and fix.
    8  * Version:           4.18
     8 * Version:           4.19
    99 * Author:            Ability, Inc
    1010 * Author URI:        https://adaplugin.com
  • online-accessibility/trunk/CHANGELOG.md

    r3268067 r3293562  
    11# Changelog
    22All notable changes to this project will be documented in this file.
     34.19
     4- Updated patch for arbitrary file upload vulnerability - https://patchstack.com/database/wordpress/plugin/online-accessibility/vulnerability/wordpress-accessibility-suite-plugin-4-17-arbitrary-file-upload-vulnerability?_a_id=15
     5- Updated patch for broken access control vulnerability - https://patchstack.com/database/wordpress/plugin/online-accessibility/vulnerability/wordpress-accessibility-suite-by-ability-inc-plugin-4-16-multiple-broken-access-control-vulnerability?_a_id=15
     6- Patched sql injection vulnerability - https://patchstack.com/database/wordpress/plugin/online-accessibility/vulnerability/wordpress-accessibility-suite-by-ability-inc-plugin-4-17-sql-injection-vulnerability?_a_id=15
     7- Tested up to WordPress 6.8.1
    38
    494.18
    5 - Patched arbitrary file upload vulnerability - https://patchstack.com/database/report-preview/dedfa172-1348-46f1-afdb-3ca0104afb90
    6 - Patched broken access control vulnerability - https://patchstack.com/database/report-preview/ccae245c-4b01-4081-a687-150ff6ad0627
     10- Patched arbitrary file upload vulnerability - https://patchstack.com/database/wordpress/plugin/online-accessibility/vulnerability/wordpress-accessibility-suite-plugin-4-17-arbitrary-file-upload-vulnerability?_a_id=15
     11- Patched broken access control vulnerability - https://patchstack.com/database/wordpress/plugin/online-accessibility/vulnerability/wordpress-accessibility-suite-by-ability-inc-plugin-4-16-multiple-broken-access-control-vulnerability?_a_id=15
    712- Tested up to WordPress 6.7.2
    813-
  • online-accessibility/trunk/README.txt

    r3268067 r3293562  
    77Author URI: https://adaplugin.com
    88Author: Ability, Inc
    9 Tested up to: 6.7.2
    10 Stable tag: "4.18"
    11 Version 4.18
     9Tested up to: 6.8.1
     10Stable tag: "4.19"
     11Version 4.19
    1212License: GPLv2 or later
    1313License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • online-accessibility/trunk/includes/ajax_functions/core.php

    r3091769 r3293562  
    1111{
    1212    Helper::verify_security($_GET);
     13
     14    // Add capability check to ensure user has proper permissions
     15    if (!current_user_can('manage_options')) {
     16        wp_send_json_error('Unauthorized access', 403);
     17        wp_die();
     18    }
     19   
     20    // Add referrer check to ensure request comes from your admin pages
     21    $referer = wp_get_referer();
     22    if (!$referer || strpos($referer, admin_url()) !== 0) {
     23        wp_send_json_error('Invalid request origin', 403);
     24        wp_die();
     25    }
     26
    1327    $scan = get_active_scan();
    1428    $details = [];
     
    89103{
    90104    Helper::verify_security($_GET);
     105
     106    // Add capability check to ensure user has proper permissions
     107    if (!current_user_can('manage_options')) {
     108        wp_send_json_error('Unauthorized access', 403);
     109        wp_die();
     110    }
     111   
     112    // Add referrer check to ensure request comes from your admin pages
     113    $referer = wp_get_referer();
     114    if (!$referer || strpos($referer, admin_url()) !== 0) {
     115        wp_send_json_error('Invalid request origin', 403);
     116        wp_die();
     117    }
     118
    91119    $scan = get_active_scan();
    92120    update_post_meta($scan->ID, '_oadaas_scan-dismissed', 1);
     
    101129{
    102130    Helper::verify_security($_POST);
     131
     132    // Add capability check to ensure user has proper permissions
     133    if (!current_user_can('manage_options')) {
     134        wp_send_json_error('Unauthorized access', 403);
     135        wp_die();
     136    }
     137   
     138    // Add referrer check to ensure request comes from your admin pages
     139    $referer = wp_get_referer();
     140    if (!$referer || strpos($referer, admin_url()) !== 0) {
     141        wp_send_json_error('Invalid request origin', 403);
     142        wp_die();
     143    }
     144
    103145    $scan = new WCAG_Scan((int)$_POST['scan_id']);
    104146
     
    129171{
    130172    Helper::verify_security($_POST);
     173
     174    // Add capability check to ensure user has proper permissions
     175    if (!current_user_can('manage_options')) {
     176        wp_send_json_error('Unauthorized access', 403);
     177        wp_die();
     178    }
     179   
     180    // Add referrer check to ensure request comes from your admin pages
     181    $referer = wp_get_referer();
     182    if (!$referer || strpos($referer, admin_url()) !== 0) {
     183        wp_send_json_error('Invalid request origin', 403);
     184        wp_die();
     185    }
    131186
    132187    $scan = get_active_scan();
     
    185240{
    186241    Helper::verify_security($_GET);
     242
     243    // Add capability check to ensure user has proper permissions
     244    if (!current_user_can('manage_options')) {
     245        wp_send_json_error('Unauthorized access', 403);
     246        wp_die();
     247    }
     248   
     249    // Add referrer check to ensure request comes from your admin pages
     250    $referer = wp_get_referer();
     251    if (!$referer || strpos($referer, admin_url()) !== 0) {
     252        wp_send_json_error('Invalid request origin', 403);
     253        wp_die();
     254    }
     255
    187256    $scan = get_active_scan();
    188257    $page = $_GET["page"];
     
    203272{
    204273    Helper::verify_security($_POST);
     274
     275    // Add capability check to ensure user has proper permissions
     276    if (!current_user_can('manage_options')) {
     277        wp_send_json_error('Unauthorized access', 403);
     278        wp_die();
     279    }
     280   
     281    // Add referrer check to ensure request comes from your admin pages
     282    $referer = wp_get_referer();
     283    if (!$referer || strpos($referer, admin_url()) !== 0) {
     284        wp_send_json_error('Invalid request origin', 403);
     285        wp_die();
     286    }
     287
    205288    $scan = get_active_scan();
    206289    $result = $scan->step_complete();
     
    365448{
    366449    Helper::verify_security($_POST);
     450
     451    // Add capability check to ensure user has proper permissions
     452    if (!current_user_can('manage_options')) {
     453        wp_send_json_error('Unauthorized access', 403);
     454        wp_die();
     455    }
     456   
     457    // Add referrer check to ensure request comes from your admin pages
     458    $referer = wp_get_referer();
     459    if (!$referer || strpos($referer, admin_url()) !== 0) {
     460        wp_send_json_error('Invalid request origin', 403);
     461        wp_die();
     462    }
     463
    367464    $scan = get_active_scan();
    368465    $step = get_post_meta($scan->ID, "_filter_step", true);
     
    376473{
    377474    Helper::verify_security($_POST);
     475
     476    // Add capability check to ensure user has proper permissions
     477    if (!current_user_can('manage_options')) {
     478        wp_send_json_error('Unauthorized access', 403);
     479        wp_die();
     480    }
     481   
     482    // Add referrer check to ensure request comes from your admin pages
     483    $referer = wp_get_referer();
     484    if (!$referer || strpos($referer, admin_url()) !== 0) {
     485        wp_send_json_error('Invalid request origin', 403);
     486        wp_die();
     487    }
     488
    378489    set_transient("_oadaas_upgrade_banner_dismissed", 1, 120 * DAY_IN_SECONDS);
    379490    wp_send_json(["message" => "success"], 200);
     
    408519function get_scan_results(){
    409520    Helper::verify_security($_POST);
     521
     522    // Add capability check to ensure user has proper permissions
     523    if (!current_user_can('manage_options')) {
     524        wp_send_json_error('Unauthorized access', 403);
     525        wp_die();
     526    }
     527   
     528    // Add referrer check to ensure request comes from your admin pages
     529    $referer = wp_get_referer();
     530    if (!$referer || strpos($referer, admin_url()) !== 0) {
     531        wp_send_json_error('Invalid request origin', 403);
     532        wp_die();
     533    }
     534
    410535    $results = Helper::get_scan_data($_POST["scan_id"], $_POST["offset"], $_POST["limit"]);
    411536    $rows = Helper::get_row_count($_POST["scan_id"]);
  • online-accessibility/trunk/includes/ajax_functions/site-updates.php

    r3091769 r3293562  
    88function save_changes(){
    99    Helper::verify_security($_POST);
     10
     11    // Add capability check to ensure user has proper permissions
     12    if (!current_user_can('manage_options')) {
     13        wp_send_json_error('Unauthorized access', 403);
     14        wp_die();
     15    }
     16   
     17    // Add referrer check to ensure request comes from your admin pages
     18    $referer = wp_get_referer();
     19    if (!$referer || strpos($referer, admin_url()) !== 0) {
     20        wp_send_json_error('Invalid request origin', 403);
     21        wp_die();
     22    }
    1023   
    1124    foreach($_POST["modified"] AS $ID => $changes){
     
    98111function get_list(){
    99112    Helper::verify_security($_POST);
     113
     114    // Add capability check to ensure user has proper permissions
     115    if (!current_user_can('manage_options')) {
     116        wp_send_json_error('Unauthorized access', 403);
     117        wp_die();
     118    }
     119   
     120    // Add referrer check to ensure request comes from your admin pages
     121    $referer = wp_get_referer();
     122    if (!$referer || strpos($referer, admin_url()) !== 0) {
     123        wp_send_json_error('Invalid request origin', 403);
     124        wp_die();
     125    }
     126
    100127    global $wpdb;
    101128    $pageLength = $_POST["pageLength"];
     
    172199function get_image_count(){
    173200    Helper::verify_security($_POST);
     201
     202    // Add capability check to ensure user has proper permissions
     203    if (!current_user_can('manage_options')) {
     204        wp_send_json_error('Unauthorized access', 403);
     205        wp_die();
     206    }
     207   
     208    // Add referrer check to ensure request comes from your admin pages
     209    $referer = wp_get_referer();
     210    if (!$referer || strpos($referer, admin_url()) !== 0) {
     211        wp_send_json_error('Invalid request origin', 403);
     212        wp_die();
     213    }
     214   
    174215    $valid = $_POST["valid"];
    175216    global $wpdb;
  • online-accessibility/trunk/includes/ajax_functions/sitemap.php

    r3268067 r3293562  
    126126function server_validate_upload($file)
    127127{
    128     $is_csv = true;
     128    // Verify user has appropriate permissions
     129    if (!current_user_can('manage_options')) {
     130        return "Unauthorized access";
     131    }
     132
     133    // Validate file exists and has no errors
     134    if (!isset($file) || $file['error'] !== UPLOAD_ERR_OK) {
     135        return "File upload error: " . (isset($file['error']) ? $file['error'] : 'Unknown error');
     136    }
     137
     138    // Get file extension and validate
    129139    $pathinfo = pathinfo($file['name']);
    130 
    131     if ($pathinfo["extension"] !== "csv") {
    132         $is_csv = false;
    133     }
    134 
    135     if (getimagesize($file["tmp_name"])) {
    136         return "Incorrect file format: " . $pathinfo["extension"];
    137         wp_die();
    138     }
    139 
     140    $extension = strtolower($pathinfo["extension"] ?? '');
     141   
     142    // Define allowed file formats
    140143    $supportedFormats = ['csv', 'txt', 'xml', 'xls', 'xlsx'];
    141 
    142     if (in_array($pathinfo["extension"], $supportedFormats)) {
    143         //Store the uploaded file to the server
    144         $basedir = wp_upload_dir()["basedir"];
    145         $rel_path = "/oadaas/sitemap/";
    146 
    147         $filename = "sitemap." . $pathinfo["extension"];
    148         $path = $basedir . $rel_path . $filename;
    149 
    150         if (!file_exists($basedir . $rel_path)) {
    151             wp_mkdir_p($basedir . $rel_path, 0777, true);
    152         }
    153 
    154         $success = move_uploaded_file($file["tmp_name"], $path);  // phpcs:ignore
     144   
     145    if (!in_array($extension, $supportedFormats)) {
     146        return "Incorrect file format: " . esc_html($extension);
     147    }
     148   
     149    // Additional security check - prevent image uploads disguised as other formats
     150    $finfo = new \finfo(FILEINFO_MIME_TYPE);
     151    $mime_type = $finfo->file($file["tmp_name"]);
     152    $allowed_mime_types = [
     153        'text/csv', 'text/plain', 'application/xml', 'text/xml',
     154        'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
     155    ];
     156   
     157    if (!in_array($mime_type, $allowed_mime_types)) {
     158        return "Invalid file type detected: " . esc_html($mime_type);
     159    }
     160   
     161    // Set up directory with secure permissions
     162    $basedir = wp_upload_dir()["basedir"];
     163    $rel_path = "/oadaas/sitemap/";
     164    $upload_dir = $basedir . $rel_path;
     165   
     166    // Create directory with secure permissions if it doesn't exist
     167    if (!file_exists($upload_dir)) {
     168        if (!wp_mkdir_p($upload_dir, 0755, true)) {
     169            return "Failed to create upload directory";
     170        }
     171    }
     172   
     173    // Set secure file path
     174    $filename = "sitemap." . $extension;
     175    $path = $upload_dir . $filename;
     176   
     177    // Move uploaded file
     178    if (!move_uploaded_file($file["tmp_name"], $path)) {
     179        return "Failed to move uploaded file";
     180    }
     181   
     182    // Process file based on type
     183    if ($extension === 'csv') {
     184        // Process CSV file
    155185        try {
    156             if ($success && !$is_csv) {
    157                 $new_filename = "sitemap.csv";
    158                 //Convert the file to CSV
    159                 switch ($pathinfo["extension"]) {
    160                     case "xml":
    161                         if (file_exists($path)) {
    162                             $xml = simplexml_load_file($path);
    163                             $f = fopen($basedir . $rel_path . $new_filename, 'w');  // phpcs:ignore
    164                             convert_xml_to_csv($xml, $f);
    165                             $stat = fstat($f);
    166                             ftruncate($f, $stat['size'] - 1);
    167                             fclose($f);  // phpcs:ignore
    168                             wp_delete_file($path);
    169                         }
    170                         break;
    171                 }
    172                 return "success";
    173             }
    174         }
    175         catch(\Exception $e) {
     186            $put_arr = [];
     187            $f = fopen($path, 'r');
     188            if (!$f) {
     189                wp_delete_file($path);
     190                return "Failed to open CSV file";
     191            }
     192           
     193            while (($line = fgetcsv($f, 0, ",")) !== false) {
     194                $put_arr[] = $line;
     195            }
     196            fclose($f);
     197           
     198            // Only proceed if we have data
     199            if (empty($put_arr) || empty($put_arr[0])) {
     200                wp_delete_file($path);
     201                return "CSV file is empty or invalid";
     202            }
     203           
     204            // Rewrite the CSV file securely
     205            $f = fopen($path, "w");
     206            if (!$f) {
     207                wp_delete_file($path);
     208                return "Failed to write CSV file";
     209            }
     210           
     211            foreach ($put_arr[0] as $item) {
     212                fputcsv($f, [sanitize_text_field($item)], ',', '"');
     213            }
     214           
     215            $stat = fstat($f);
     216            ftruncate($f, $stat['size'] - 1);
     217            fclose($f);
     218           
     219            return "success";
     220        } catch (\Exception $e) {
     221            // Clean up on error
     222            if (file_exists($path)) {
     223                wp_delete_file($path);
     224            }
     225            return "Error processing CSV: " . esc_html($e->getMessage());
     226        }
     227    } else if ($extension === 'xml') {
     228        // Convert XML to CSV
     229        try {
     230            if (!file_exists($path)) {
     231                return "XML file not found after upload";
     232            }
     233           
     234            // Validate XML structure before processing
     235            $xml = @simplexml_load_file($path);
     236            if ($xml === false) {
     237                wp_delete_file($path);
     238                return "Invalid XML file";
     239            }
     240           
     241            $csv_path = $upload_dir . "sitemap.csv";
     242            $f = fopen($csv_path, 'w');
     243            if (!$f) {
     244                wp_delete_file($path);
     245                return "Failed to create CSV file";
     246            }
     247           
     248            // Convert XML to CSV with proper error handling
     249            $result = convert_xml_to_csv($xml, $f);
     250            if ($result === false) {
     251                fclose($f);
     252                wp_delete_file($csv_path);
     253                wp_delete_file($path);
     254                return "Failed to convert XML to CSV";
     255            }
     256           
     257            $stat = fstat($f);
     258            ftruncate($f, $stat['size'] - 1);
     259            fclose($f);
     260           
     261            // Remove the original XML file after successful conversion
    176262            wp_delete_file($path);
    177         }
    178         if ($is_csv) {
    179             $put_arr = [];
     263           
     264            return "success";
     265        } catch (\Exception $e) {
     266            // Clean up on error
    180267            if (file_exists($path)) {
    181                 //Read and store contents of uploaded CSV file into an array
    182                 $f = fopen($path, 'r');  // phpcs:ignore
    183                 while (($line = fgetcsv($f, 0, ",")) !== false) {
    184                     $put_arr[] = $line;
    185                 }
    186                 fclose($f);  // phpcs:ignore
    187 
    188                 //Rewrite the CSV file to use '/n' after delimiter
    189                 $f = fopen($path, "w");  // phpcs:ignore
    190                 foreach ($put_arr[0] as $item) {
    191                     fputcsv($f, [$item], ',', '"');
    192                 }
    193                 $stat = fstat($f);
    194                 ftruncate($f, $stat['size'] - 1);
    195                 fclose($f);  // phpcs:ignore
    196                 return "success";
    197             }
    198         }
    199     }
    200     return "Incorrect file format: " . $pathinfo["extension"];
    201     wp_die();
    202 }
     268                wp_delete_file($path);
     269            }
     270            if (file_exists($upload_dir . "sitemap.csv")) {
     271                wp_delete_file($upload_dir . "sitemap.csv");
     272            }
     273            return "Error processing XML: " . esc_html($e->getMessage());
     274        }
     275    } else {
     276        // For other file types that need conversion but aren't implemented yet
     277        wp_delete_file($path);
     278        return "File type " . esc_html($extension) . " is supported but conversion is not implemented";
     279    }
     280}
     281
    203282
    204283function convert_xml_to_csv($xml, $f)
  • online-accessibility/trunk/includes/classes/Helper.php

    r3268067 r3293562  
    9797    static function save_false_positive($scan_id, $issue_id){
    9898        global $wpdb;
    99         $table_name = $wpdb->prefix.'oada_false_positives';
    100 
    101         if(! is_admin()) {
    102             return '';
    103         }
    104 
     99        $table_name = $wpdb->prefix.'oada_false_positives';
     100   
     101        if(! is_admin()) {
     102            return '';
     103        }
     104   
     105        // Validate inputs
     106        $scan_id = absint($scan_id); // Ensure scan_id is a positive integer
     107       
     108        if (!$scan_id) {
     109            return ["status" => "failed", "msg" => "Invalid scan ID"];
     110        }
     111       
    105112        try{
    106             //Get list
    107             $list = json_decode(
    108                 $wpdb->get_results($wpdb->prepare("SELECT list FROM  $table_name WHERE scan_id = $scan_id"))[0]->list // phpcs:ignore
     113            // Get list using properly prepared query
     114            $query = $wpdb->prepare(
     115                "SELECT list FROM %i WHERE scan_id = %d",
     116                $table_name,
     117                $scan_id
    109118            );
    110 
    111             //Add to list
     119           
     120            $result = $wpdb->get_results($query);
     121           
     122            if (empty($result)) {
     123                return ["status" => "failed", "msg" => "Scan not found"];
     124            }
     125           
     126            $list = json_decode($result[0]->list);
     127           
     128            // Validate list is an array
     129            if (!is_array($list)) {
     130                $list = [];
     131            }
     132           
     133            // Add to list
    112134            $list[] = $issue_id;
    113             $list = $wpdb->_real_escape(json_encode($list));
    114 
    115             //Save new list
    116             $wpdb->query($wpdb->prepare("UPDATE $table_name SET list = '$list' WHERE scan_id =$scan_id")); // phpcs:ignore
     135           
     136            // Prepare the JSON string properly
     137            $json_list = wp_json_encode($list);
     138           
     139            // Update with properly prepared query
     140            $updated = $wpdb->update(
     141                $table_name,
     142                ['list' => $json_list],
     143                ['scan_id' => $scan_id],
     144                ['%s'],
     145                ['%d']
     146            );
     147           
     148            if ($updated === false) {
     149                return ["status" => "failed", "msg" => "Database update failed"];
     150            }
     151           
    117152            return ["status" => "success"];
    118         }catch(\Exception $e){
    119             return ["status" => "failed", "msg" => $e];
    120         }
    121     }
     153        } catch(\Exception $e){
     154            return ["status" => "failed", "msg" => $e->getMessage()];
     155        }
     156    }
     157   
    122158
    123159    static function delete_false_positive($scan_id, $issue_id){
  • online-accessibility/trunk/index.php

    r3268067 r3293562  
    66 * Plugin URI:        https://adaplugin.com
    77 * Description:       The most powerful and comprehensive Accessibility Suite. Achieve and maintain ADA/WCAG compliance faster than ever before. Audit, identify, get instruction, and fix.
    8  * Version:           4.18
     8 * Version:           4.19
    99 * Author:            Ability, Inc
    1010 * Author URI:        https://adaplugin.com
Note: See TracChangeset for help on using the changeset viewer.