Plugin Directory

Changeset 3484577


Ignore:
Timestamp:
03/17/2026 08:56:11 AM (11 days ago)
Author:
prosolution
Message:

2.0.0

  • UPDATE:
    • SECURITY UPDATE: add security validation to prevent arbitrary files upload on side dish page
Location:
prosolution-wp-client
Files:
597 added
3 edited

Legend:

Unmodified
Added
Removed
  • prosolution-wp-client/trunk/README.txt

    r3378552 r3484577  
    44Tags: profession, occupation, application, education, experience, expertise, attachment
    55Requires at least: 5.9
    6 Tested up to: 6.5
     6Tested up to: 6.9.4
    77Requires PHP: 7.0
    8 Stable tag: 1.9.9
     8Stable tag: 2.0.0
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6565
    6666== Changelog ==
     67= 2.0.0 =
     68* UPDATE:
     69  - SECURITY UPDATE: add security validation to prevent arbitrary files upload on side dish page
     70
    6771= 1.9.9 =
    6872* UPDATE:
  • prosolution-wp-client/trunk/prosolwpclient.php

    r3378552 r3484577  
    1717     * Plugin URI:        https://prosolution.com/produkte-und-services/workexpert.html
    1818     * Description:       WordPress client for ProSolution
    19      * Version:           1.9.9
     19     * Version:           2.0.0
    2020     * Author:            ProSolution
    2121     * Author URI:        https://www.prosolution.com
     
    4242
    4343    defined('PROSOLWPCLIENT_PLUGIN_NAME') or define('PROSOLWPCLIENT_PLUGIN_NAME', 'prosolwpclient');
    44     defined('PROSOLWPCLIENT_PLUGIN_VERSION') or define('PROSOLWPCLIENT_PLUGIN_VERSION', '1.9.9');
     44    defined('PROSOLWPCLIENT_PLUGIN_VERSION') or define('PROSOLWPCLIENT_PLUGIN_VERSION', '2.0.0');
    4545    defined('PROSOLWPCLIENT_BASE_NAME') or define('PROSOLWPCLIENT_BASE_NAME', plugin_basename(__FILE__));
    4646    defined('PROSOLWPCLIENT_ROOT_PATH') or define('PROSOLWPCLIENT_ROOT_PATH', plugin_dir_path(__FILE__));
  • prosolution-wp-client/trunk/public/class-prosolwpclient-public.php

    r3331282 r3484577  
    996996            //if the upload dir for prosolwpclient is not created then then create it
    997997            $dir_info = $this->proSol_checkUploadDir();
    998             $submit_data  = $_FILES["files"];
    999             $mime_type   = isset( $submit_data['type'] ) ? $submit_data['type'][0] : '';
    1000             $ext = proSol_mimeExt($mime_type);
     998            $submit_data  = $_FILES["files"] ?? null;
     999
     1000            //this is for if someone somehow able to run this function without file
     1001            if ( ! $submit_data ) {
     1002                die(__("No file uploaded", "prosolwpclient"));
     1003            }
     1004
     1005            // get file name and temp file location and sanitize them
     1006            $org_filename = isset( $submit_data['name'][0] ) ? sanitize_file_name( $submit_data['name'][0] ) : '';
     1007            $tmp_fileloc = isset( $submit_data['tmp_name'][0] ) ? $submit_data['tmp_name'][0] : '';
     1008
     1009            // if file name or location empty, process must be aborted
     1010            if ( empty( $org_filename ) || empty( $tmp_fileloc ) || ! is_uploaded_file( $tmp_fileloc ) ) {
     1011                die(__("Invalid file", "prosolwpclient"));
     1012            }
     1013            //check file extension for uploaded "up" file
     1014            $up_fileext = strtolower( pathinfo( $org_filename, PATHINFO_EXTENSION ) );
     1015
     1016            //since most of cv or profile picture are typically using this format, we should whitelist these extension only.
     1017            //do not use proSol_mimeExt function, it allow all kind of extension including big nono one like php or other programming language.
     1018            $whitelist_ext = array( 'jpg', 'jpeg', 'png', 'gif', 'webp', 'pdf', 'doc', 'docx' );
     1019
     1020            //check extension first
     1021            if ( ! in_array( $up_fileext, $whitelist_ext, true ) ) {
     1022                die(__("File type not allowed", "prosolwpclient"));
     1023            }
     1024
     1025            //check for REAL mime type, $submit_data['type'] only check for surface-level.
     1026            $finfoObj = new finfo( FILEINFO_MIME_TYPE );
     1027            $true_mmime = $finfoObj->file( $tmp_fileloc );
     1028
     1029            //syntax below is big nono, don't use it to check mime!!!
     1030            //$mime_type   = isset( $submit_data['type'] ) ? $submit_data['type'][0] : '';
     1031            //again do not use prosol_mimeext, they will allow script or programming language
     1032            //$ext = proSol_mimeExt($mime_type);
     1033
     1034            $wp_mime_chk = wp_check_filetype( $org_filename );
     1035            if ( $wp_mime_chk['type'] == false ) {
     1036                die(__("File type is not allowed.", "prosolwpclient"));
     1037            }
     1038
     1039            //only listed mimes type are allow
     1040            $whitelist_mimes = array(
     1041                'jpg'  => 'image/jpeg',
     1042                'jpeg' => 'image/jpeg',
     1043                'png'  => 'image/png',
     1044                'gif'  => 'image/gif',
     1045                'webp' => 'image/webp',
     1046                'pdf'  => 'application/pdf',
     1047                'doc'  => 'application/msword',
     1048                'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
     1049            );
     1050
     1051            //check for real hidden mimes type
     1052            if ( ! isset( $whitelist_mimes[ $up_fileext ] ) || $true_mmime !== $whitelist_mimes[ $up_fileext ] ) {
     1053                die(__("File content does not match its extension", "prosolwpclient"));
     1054            }
     1055
     1056            if ( in_array( $up_fileext, array( 'jpg', 'jpeg', 'png', 'gif', 'webp' ), true ) ) {
     1057                //for image upload we can also verified image via dimension size like height and width, fake image file will be false result
     1058                $img_dimension = @getimagesize( $tmp_fileloc );
     1059                if ( $img_dimension === false ) {
     1060                    die(__("Invalid image dimension", "prosolwpclient"));
     1061                }
     1062            }
    10011063           
    1002             if ( in_array( $ext, proSol_imageExtArr() ) || in_array( $ext, proSol_documentExtArr() ) ) {
    1003                 if ( is_array( $dir_info ) && sizeof( $dir_info ) > 0 && array_key_exists( 'folder_exists', $dir_info ) && $dir_info['folder_exists'] == 1 ) {
    1004                     $options = array(
    1005                         'script_url'     => admin_url( 'admin-ajax.php' ),
    1006                         'upload_dir'     => $dir_info['prosol_base_dir'],
    1007                         'upload_url'     => $dir_info['prosol_base_url'],
    1008                         'print_response' => false,
    1009                     );
     1064            if ( is_array( $dir_info ) && sizeof( $dir_info ) > 0 && array_key_exists( 'folder_exists', $dir_info ) && $dir_info['folder_exists'] == 1 ) {
     1065                $options = array(
     1066                    'script_url'     => admin_url( 'admin-ajax.php' ),
     1067                    'upload_dir'     => $dir_info['prosol_base_dir'],
     1068                    'upload_url'     => $dir_info['prosol_base_url'],
     1069                    'print_response' => false,
     1070                );
    10101071   
    1011                     $upload_handler = new CBXProSolWpClient_UploadHandler( $options );
     1072                $upload_handler = new CBXProSolWpClient_UploadHandler( $options );
    10121073   
    1013                     $response_obj = $upload_handler->response['files'][0];
    1014                     if ( $response_obj->name != '' ) {
    1015                         if ( ! session_id() ) {
    1016                             session_start();
    1017                         }
     1074                $response_obj = $upload_handler->response['files'][0];
     1075
     1076                //change $response_obj->name != '' to !empty( $response_obj->name )
     1077                if ( ! empty( $response_obj->name ) ) {
     1078                    if ( ! session_id() ) {
     1079                        session_start();
     1080                    }
    10181081   
    1019                         $attached_file_name = $response_obj->name;
     1082                    $attached_file_name = $response_obj->name;
    10201083   
    1021                         $extension = pathinfo( $attached_file_name, PATHINFO_EXTENSION );
     1084                    //check final result extension, and make it universal lowercase
     1085                    $fin_ext = strtolower( pathinfo( $attached_file_name, PATHINFO_EXTENSION ) );
     1086                   
     1087                    //check it one last time on the result
     1088                    if ( ! in_array( $fin_ext, $whitelist_ext, true ) ) {
     1089                        die(__("File type mismatch after upload", "prosolwpclient"));
     1090                    }
    10221091   
    1023                         $newfilename                 = wp_create_nonce( session_id() . time() ) . '.' . $extension;
    1024                         $rename_status               = rename( $dir_info['prosol_base_dir'] . $attached_file_name, $dir_info['prosol_base_dir'] . $newfilename );
    1025                         $response_obj->newfilename   = $newfilename;
    1026                         $response_obj->rename_status = $rename_status;
    1027                         $response_obj->extension     = $extension;
     1092                    $newfilename                 = wp_create_nonce( session_id() . time() ) . '.' . $fin_ext;
     1093                    $rename_status               = rename( $dir_info['prosol_base_dir'] . $attached_file_name, $dir_info['prosol_base_dir'] . $newfilename );
     1094                    $response_obj->newfilename   = $newfilename;
     1095                    $response_obj->rename_status = $rename_status;
     1096                    $response_obj->extension     = $fin_ext;
    10281097   
    1029                         $return_response = array( 'files' => array( 0 => $response_obj ) );
    1030                         echo json_encode( $return_response );
    1031                         wp_die();
    1032                     }
    1033                 }
    1034             }
     1098                    $return_response = array( 'files' => array( 0 => $response_obj ) );
     1099                    //success return
     1100                    echo json_encode( $return_response );
     1101                    wp_die();
     1102                }
     1103            }
     1104
     1105            //default return
     1106            wp_send_json_error( array( 'error' => 'Upload failed' ) );
     1107            wp_die();
     1108           
    10351109        }
    10361110
Note: See TracChangeset for help on using the changeset viewer.